[英]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: 到目前为止我的解
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.
然后,您可以选择要包含在项目中的文件。
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注意文件更改,如下所示:
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项目时,我也遇到了类似的情况。
Right click on your Project item in the Solution Explorer and create a New Folder eg 'assets' 右键单击解决方案资源管理器中的项目项,然后创建一个新文件夹,例如'assets'
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”文件夹中,然后等待复制过程完成。
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.
您应该看到您的文件夹结构,包括您需要的文件。
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.