My Visual studio 2015 solution explorer doesn't refresh when I change files on disk and there is (as far as I can see) no refresh button anymore.
In explorer everything looks as it should and after performing my "refresh"-methods below all files shows again.
My solutions so far:
This is especially annoying when running builds with gulp which is adding, changing and removing files.
Am I missing something obvious?
Ps. It does not have to do with option "Show All Files". The doesn't show as "transparen" not-included-files either.
There is a refresh icon option in the top row of solution explorer.
When the files are added or deleted outside of Visual Studio, touch the project file. Visual Studio notices this and pops up a confirmation dialog asking do you want to reload the project. Click Reload/Reload All, and the project is reloaded, and the file modifications show now on the Solution Explorer.
You can navigate there quickly using Visual Studio Quick Launch (Ctrl + Q). Just type 'Track active' and you will get the quick link to the setting. Keep it checked, and off you go, the solution explorer and the current file will be in sync.
In Solution Explorer, select the projects you want to load (press Ctrl while clicking to select more than one project), and then right-click on the project and choose Reload Project. Visual Studio will remember which projects are loaded the next time you open the solution locally.
Click on the show all files icon on the top of the solution explorer. You can then choose the files you want to include in the project.
See the answer here:
Refresh button in Visual Studio Solution Explorer not working
I've banged my head quite a lot for figuring out how to do this as well and the answer is that I don't think Visual Studio handles this kind of scenario.
What I've done is a workaround and not an optimal one, but I'll post it here in case it might help others.
You can trigger Visual Studio to notice file changes like this:
I use two node packages. Chokidar to watch file system events and touch to touch project file
Chokidar is nice, you can set which files and folders to watch, what to ignore and so on. And touch offers very easy way to change the timestamp of the file.
Here's a working code sample which you can tune to suit your needs:
var chokidar = require('chokidar');
var touch = require("touch");
console.log("Starting - Initial files are ignored");
var projectFile = "C:\\projects\\GitHub\\testing-touch\\TestingTouch\\TestingTouch.csproj";
var watcher = chokidar.watch('C:\\projects\\GitHub\\testing-touch\\TestingTouch\\tests', {
ignored: /[\\/\\]\./,
ignoreInitial: true,
persistent: true
});
var log = console.log.bind(console);
watcher
.on('add', function(path) {
log('File', path, 'has been added');
touch.sync(projectFile, { time: new Date(), force: false });
})
.on('change', function(path) { log('File', path, 'has been changed'); })
.on('unlink', function(path) { log('File', path, 'has been removed'); })
// More events.
.on('addDir', function(path) { log('Directory', path, 'has been added'); })
.on('unlinkDir', function(path) { log('Directory', path, 'has been removed'); })
.on('error', function(error) { log('Error happened', error); })
.on('ready', function() { log('Initial scan complete. Ready for changes.'); })
.on('raw', function(event, path, details) { log('Raw event info:', event, path, details); })
// 'add', 'addDir' and 'change' events also receive stat() results as second
// argument when available: http://nodejs.org/api/fs.html#fs_class_fs_stats
watcher.on('change', function(path, stats) {
if (stats) console.log('File', path, 'changed size to', stats.size);
});
The negative sides of this workaround are that you'll have to setup the file watcher, and you'll need to click the annoying confirmation dialogue.
There is a refresh option on the bottom of 'view' tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With