简体   繁体   English

Visual Studio 2015解决方案资源管理器不刷新文件?

[英]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. 当我更改磁盘上的文件时,我的Visual Studio 2015解决方案资源管理器不刷新,并且(据我所见)没有刷新按钮了。

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 刷新Visual Studio

This is especially annoying when running builds with gulp which is adding, changing and removing files. 当使用gulp运行构建时,这尤其令人讨厌,因为gulp正在添加,更改和删除文件。

Am I missing something obvious? 我错过了一些明显的东西吗

Ps. PS。 It does not have to do with option "Show All Files". 它与选项“显示所有文件”无关。 The doesn't show as "transparen" not-included-files either. 它也不显示为“透明”未包含文件。

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截图

See the answer here: 看到答案:

Refresh button in Visual Studio Solution Explorer not working Visual Studio解决方案资源管理器中的刷新按钮无效

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. 为了弄清楚如何做到这一点,我已经打了很多脑筋,答案是我认为Visual Studio不会处理这种情况。

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: 您可以触发Visual Studio注意文件更改,如下所示:

  • When the files are added or deleted outside of Visual Studio, touch the project file 在Visual Studio外部添加或删除文件时,请触摸项目文件
  • Visual Studio notices this and pops up a confirmation dialog asking do you want to reload the project Visual Studio会注意到这一点并弹出一个确认对话框,询问您是否要重新加载项目
  • Click Reload/Reload All, and the project is reloaded, and the file modifications show now on the Solution Explorer 单击Reload / Reload All,重新加载项目,文件修改现在显示在Solution Explorer上

I use two node packages. 我使用两个节点包。 Chokidar to watch file system events and touch to touch project file Chokidar观看文件系统事件和触摸触摸项目文件

Chokidar is nice, you can set which files and folders to watch, what to ignore and so on. Chokidar很不错,你可以设置要观看的文件和文件夹,要忽略的内容等等。 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. 此解决方法的负面影响是您必须设置文件观察器,并且您需要单击恼人的确认对话框。

I was also in a similar situation whilst trying to add my pre-existing 'assets' folder to a Web Project in Visual Studio 2015. 在尝试将预先存在的“assets”文件夹添加到Visual Studio 2015中的Web项目时,我也遇到了类似的情况。

  1. Right click on your Project item in the Solution Explorer and create a New Folder eg 'assets' 右键单击解决方案资源管理器中的项目项,然后创建一个新文件夹,例如'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. 在Windows资源管理器中,将要传输的文件夹的内容拖到VS Solution Explorer窗口中的新“assets”文件夹中,然后等待复制过程完成。

  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. 这对我有用,我希望它可以帮助任何有同样问题的人。

“视图”标签底部有一个刷新选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 bower.json未在Visual Studio 2015解决方案资源管理器中显示 - bower.json doesn't show in Visual Studio 2015 solution explorer Visual Studio 解决方案资源管理器找不到所有内容 - Visual Studio Solution Explorer doesn't find everything 我无法在解决方案资源管理器Visual Studio Community 2015中运行多个文件 - I cannot run multiple files within solution explorer Visual Studio Community 2015 在Visual Studio 2015中更改解决方案资源管理器工具窗口的标题 - Changing the title of the Solution Explorer tool window in visual studio 2015 Visual Studio 2015项目存在,但不再显示在解决方案资源管理器中 - Visual Studio 2015 Project exists but no longer shown in Solution Explorer Visual Studio 2015 Update 3 无法打开 .cs 文件 - Visual Studio 2015 Update 3 doesn't open .cs files Visual Studio 2015解决方案资源管理器树视图中缺少文件图标 - File Icons are missing in Visual Studio 2015 Solution Explorer Tree View Visual Studio 2015 - 缺少解决方案资源管理器分支中的内容 - Visual Studio 2015 - missing content in solution explorer branches Visual Studio 2015团队资源管理器未看到现有的本地存储库克隆 - Visual Studio 2015 Team Explorer doesn't see existing local repository clone Visual Studio 2015:源代码管理资源管理器不会下载文件/项目 - Visual Studio 2015: source control explorer won't download files/projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM