35

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.

Jonas Stensved
  • 14,378
  • 5
  • 51
  • 80
  • I think you must be missing something because I've just generated a .less file using gulp and it showed immediately and then, using Windows Explorer, copied it, and again it showed immediately in VS 2015. So afaik the solution auto-refreshes, and there's no need for a refresh button. – Ralph Lavelle May 05 '16 at 21:18
  • Yes, but when it doesn't work with auto-refresh a refresh button would have been more convenient than reloading the entire solution, right? – Jonas Stensved Jun 19 '16 at 09:26
  • 2
    This feature was reliable in VS 2013. In 2015, it seems broken. When I switch branches in git, VS 2015 doesn't detect changes like VS 2013 did. It still seems to keep the old version of the .csproj and web.config loaded, so things break. Steer clear of this version if you can. According to this, it's fixed in 2017 RC: https://developercommunity.visualstudio.com/content/problem/1415/visual-studio-15-is-not-detecting-file-changes.html – Triynko Feb 13 '17 at 21:54
  • I'm having the same problem in VS 2017 (Community). I use VS alongside Vim, and VS isn't picking up changes made by Vim until I unload and reload. Really irritating. I'm not sure if I can get 2013 Community Edition... –  Mar 22 '17 at 03:33
  • Possible duplicate of [Refresh button in Visual Studio Solution Explorer not working](https://stackoverflow.com/questions/14815786/refresh-button-in-visual-studio-solution-explorer-not-working) – C-Pound Guru Jun 06 '17 at 17:43

4 Answers4

21

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

JakeD
  • 2,788
  • 2
  • 20
  • 29
2

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.

jjokela
  • 337
  • 2
  • 8
  • 1
    Instead of touching the project files to get it to notice a change you can right click on the project and buried in all the options is "Unload project" . Select that and after the project is unloaded, you can right click on it again to "reload" it. – Paul Gorbas Jan 13 '17 at 19:23
  • Just manually `touch`ing project file from command line was enough for my use case. Thanks – superjos Feb 28 '18 at 21:12
1

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

Difster
  • 3,264
  • 2
  • 22
  • 32
  • Could please explain to me where is that? Thanks – superjos Feb 28 '18 at 21:11
  • click on your project in the solutions explorer(not the solution itself, but the project), then click on the view tab on the tab list on top of the visual studio. tabs go: file, edit, view, project... on the bottom of view tab refresh option will appear. – Gervasius Twinklewinkleson Mar 02 '18 at 08:00
0

I was also in a similar situation whilst trying to add my pre-existing 'assets' folder to a Web Project in Visual Studio 2015.

  1. Right click on your Project item in the Solution Explorer and create a New Folder e.g. 'assets'

  2. In Windows Explorer, drag the contents of the folder you wish to transfer into the new 'assets' folder in the VS Solution Explorer window and wait for the copying process to complete.

  3. Click on the 'Show All Files' icon on the toolbar at the top of the Solution Explorer. You should see your folder structure including the files you need.

  4. Highlight the files/folders, right click and select 'Include In Project'.

This worked for me and I hope it helps anyone with the same issue.

leighhydes
  • 77
  • 1
  • 2
  • 8