Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio 2015 solution explorer doesn't refresh files?

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:

  1. Unload and reload project
  2. Refresh Visual Studio

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.

like image 537
Jonas Stensved Avatar asked Aug 03 '15 15:08

Jonas Stensved


People also ask

How do I refresh a Solution Explorer in Visual Studio?

There is a refresh icon option in the top row of solution explorer.

How do I reload a project in Visual Studio 2015?

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.

How do I sync Solution Explorer in Visual Studio?

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.

How do I refresh a Visual Studio project?

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.


3 Answers

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.

Solution Explorer screenshot

See the answer here:

Refresh button in Visual Studio Solution Explorer not working

like image 135
balaji polakampalli Avatar answered Sep 27 '22 18:09

balaji polakampalli


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.

like image 20
jjokela Avatar answered Sep 25 '22 18:09

jjokela


There is a refresh option on the bottom of 'view' tab.

like image 25
Gervasius Twinklewinkleson Avatar answered Sep 27 '22 18:09

Gervasius Twinklewinkleson