如何在VS2015中按名称隐藏解决方案资源管理器中的文件?

时间:2022-11-25 19:24:14

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:

我正在使用ASP.NET预览模板在VS2015中编写一个网站。不幸的是,Dropbox在我的项目的每个文件夹中添加了一堆.dropbox.attr文件,解决方案资源管理器正在显示这些文件:

如何在VS2015中按名称隐藏解决方案资源管理器中的文件?

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:

请注意,我没有手动将它们添加到项目中(它们未在我的Web.xproj中引用),并且我没有选择“显示所有文件”。我已将它们添加到我的.gitignore中。选择文件时没有“删除”选项:

如何在VS2015中按名称隐藏解决方案资源管理器中的文件?

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

最后,我尝试将它们添加到我的project.json的排除部分:

...

"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.

我不确定VS2015与新项目结构之间的相互作用,因此它可能是任何这些因素的结果。

3 个解决方案

#1


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

您可以修改项目的.xproj文件,并添加以下内容以排除文件夹:

<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.

您可以将DnxInvisibleFolder用于文件夹,将DnxInvisibleContent用于文件。有些文件夹(如node_modules)有时会有数千个文件夹/文件,这似乎是VS2015扫描和加载的主要问题。

#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.

在Visual Studio 2015的DNX项目中,解决方案资源管理器不使用project.json来确定显示的内容。 project.json中的“exclude”属性由dnx用于确定应从编译或发布中排除哪些文件夹/文件,但这不会影响Visual Studio的解决方案资源管理器。

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.

一般来说,显示“一切”,但这并不完全正确,因为VS排除了某些文件夹(例如.git,.vs,工件等)。它还会添加其他内容(例如,默认情况下,bower组件会从编译中排除,但VS会将其作为依赖项下的元文件夹添加回来)。解决方案资源管理器的“过滤器”不会向用户公开,因此配置文件无法对其进行编辑或更改。

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".

使用最新的Visual Studio,您只需右键单击文件夹/文件,然后选择“从解决方案资源管理器中隐藏”。

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

这会像Corneliu之前写的那样改变“xproj”:

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

#1


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

您可以修改项目的.xproj文件,并添加以下内容以排除文件夹:

<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.

您可以将DnxInvisibleFolder用于文件夹,将DnxInvisibleContent用于文件。有些文件夹(如node_modules)有时会有数千个文件夹/文件,这似乎是VS2015扫描和加载的主要问题。

#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.

在Visual Studio 2015的DNX项目中,解决方案资源管理器不使用project.json来确定显示的内容。 project.json中的“exclude”属性由dnx用于确定应从编译或发布中排除哪些文件夹/文件,但这不会影响Visual Studio的解决方案资源管理器。

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.

一般来说,显示“一切”,但这并不完全正确,因为VS排除了某些文件夹(例如.git,.vs,工件等)。它还会添加其他内容(例如,默认情况下,bower组件会从编译中排除,但VS会将其作为依赖项下的元文件夹添加回来)。解决方案资源管理器的“过滤器”不会向用户公开,因此配置文件无法对其进行编辑或更改。

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".

使用最新的Visual Studio,您只需右键单击文件夹/文件,然后选择“从解决方案资源管理器中隐藏”。

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

这会像Corneliu之前写的那样改变“xproj”:

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