How can I hide files from Solution Explorer by name in VS2015?

天涯浪子 提交于 2019-11-29 02:19:02

问题


I am writing a website in VS2015 using the ASP.NET Preview template. Unfortunately, Dropbox has added a bunch of .dropbox.attr files in each folder of my project, which the Solution Explorer is displaying:

Note that I have not added them to the project manually, (they are not referenced in my Web.xproj,) and I do not have "Show All Files" selected. I have already added them to my .gitignore. There is no "Remove" option when selecting the file:

Lastly, I have tried adding them to my project.json's exclude section:

...

"publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc",
    ".dropbox.attr"
],

"exclude": [
    "wwwroot",
    "node_modules",
    "bower_components",
    ".dropbox.attr"
]

...

Is there any way to get all files with this name to not appear in my Solution Explorer?

I'm not sure exactly of the interaction between VS2015 and the new project structure, so it could be a result of any of those factors.


回答1:


You can modify the .xproj file of your project and add the following to exclude folders:

<ItemGroup>
    <DnxInvisibleFolder Include="wwwroot\jspm_packages\" />
    <DnxInvisibleFolder Include="wwwroot\node_modules\" />

    <DnxInvisibleContent Include="wwwroot\tsd.json" />
</ItemGroup>

You can use DnxInvisibleFolder for folders and DnxInvisibleContent for files. Some folders (like node_modules) have sometimes thousands of folders/files which seem to pose a major problem for VS2015 to scan and load.




回答2:


In a DNX project in visual Studio 2015 the solution explorer does not use the project.json to determine what is shown. The "exclude" properties in project.json are used by dnx to determine which folders/files should be excluded from compilation or publishing but this does not affect Visual Studio's solution explorer.

Generally speaking "everything" is shown but that isn't exactly true as VS excludes certain folders (such as .git, .vs, artifacts, etc). It also adds back others (i.e. bower components is excluded by default from compilation but VS adds it back as a meta folder under dependencies). The "filter" for Solution Explorer is not exposed to the user so it can't be edited or changed by configuration file.

Your best bet would be to request via user voice that some method of configuration be added. Really the functionality is already there it just needs to be made customizable by the user.




回答3:


With the latest Visual Studio you just need to right-click the folder/file and chose "Hide from Solution Explorer".

That will change the "xproj" this way like Corneliu wrote before:

<ItemGroup>
    <DnxInvisibleFolder Include="wwwroot\" />
</ItemGroup>


来源:https://stackoverflow.com/questions/30175235/how-can-i-hide-files-from-solution-explorer-by-name-in-vs2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!