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:
- 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
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.