[英]How do you change the icon of the `wwwroot` folder in a .NET Core project?
In Visual Studio 2017, when I want to create an ASP.NET Core Web Application from scratch using either one of these standard .NET Core project templates:在 Visual Studio 2017 中,当我想使用以下任一标准 .NET Core 项目模板从头开始创建 ASP.NET Core Web 应用程序时:
These project templates;这些项目模板; obviously would not include the wwwroot
folder.显然不会包括wwwroot
文件夹。 So, when I add the folder to my project it will look like (and behave like) a standard folder:因此,当我将文件夹添加到我的项目时,它将看起来(并且表现得像)一个标准文件夹:
When you create it using the ASP.NET Core Web Application project template, the wwwroot
folder looks like this:使用ASP.NET Core Web 应用程序项目模板创建它时, wwwroot
文件夹如下所示:
Question - Appearance (Icon)问题 - 外观(图标)
How do you change the icon of the
wwwroot
folder to look like the one found in the ASP.NET Core Web Application project template?如何将wwwroot
文件夹的图标更改为在ASP.NET Core Web 应用程序项目模板中找到的图标?
Additional Question - Behavior (Copying Files to Output Directory)附加问题 - 行为(将文件复制到输出目录)
In the standard .NET Core project, I would have to add this to my .csproj
file:在标准的 .NET Core 项目中,我必须将它添加到我的.csproj
文件中:
<ItemGroup>
<Content Include="wwwroot\**" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
so that it copies all my files from the wwwroot
folder to the output directory similar to the ASP.NET Core Web Application project.以便它将我的所有文件从wwwroot
文件夹复制到类似于 ASP.NET Core Web 应用程序项目的输出目录。 I looked in the ASP.NET Core Web Application's .csproj
file and didn't see anything like that.我查看了 ASP.NET Core Web 应用程序的.csproj
文件,但没有看到类似的内容。
I'm assuming the answer to the main question will also provide the answer for this one, as the project templates are obviously different.我假设主要问题的答案也将为这个问题提供答案,因为项目模板显然不同。 I can't seem to find the resources online to help me manually edit this myself.我似乎无法在网上找到资源来帮助我自己手动编辑它。
Thanks in advance.提前致谢。
After reading this page that announced the new tooling in Visual Studio 2017, I found out that it was in fact possible. 在阅读了宣布Visual Studio 2017中新工具的页面后,我发现它实际上是可行的。
I noticed that the ASP.NET Core Web Application project uses a different value under the
Project
node in the.csproj
file. 我注意到ASP.NET Core Web Application项目在.csproj
文件的Project
节点下使用了不同的值。<Project Sdk="Microsoft.NET.Sdk.Web">
Whereas the standard project templates used Microsoft.NET.Sdk
like this: 而标准项目模板使用Microsoft.NET.Sdk
如下:
<Project Sdk="Microsoft.NET.Sdk"> ← ← ← ← //change this to Microsoft.NET.Sdk.Web
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
</Project>
Once I changed the value to Microsoft.NET.Sdk.Web
and saved the csproj
file, the project upgraded itself, and the wwwroot
folder was added to my project automatically (but excluded) , like this: 一旦我将值更改为 Microsoft.NET.Sdk.Web
并保存了csproj
文件,项目就自行升级,并且wwwroot
文件夹自动添加到我的项目中(但不包括在内) ,如下所示:
Then I included it into the project and now: 然后我将它包含在项目中,现在:
Great! 大! I hope this answer helps others. 我希望这个答案有助于其他人。
确保此行包含在下面的ItemGroup中
<Folder Include="wwwroot\" />
我遇到了同样的问题,但最好不要将其称为问题,因为带有图标的 wwwroot 文件夹和没有图标的文件夹之间没有区别,您必须首先找到文件 yourproject.csproj 文件,它由一些标签填充在这个文件的顶部,你会看到它被赋值的标签,像这样 Sdk=Microsoft.NET.Sdk 尝试像这样重新赋值 Sdk="Microsoft.NET.Sdk.web然后尝试删除不寻常的 wwwroot 文件夹并重新生成文件夹和这次将其命名为 wwwroot 它将具有您喜欢的图标
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.