Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Console App (.NET Core)
  • Class Library (.NET Core)

These project templates; obviously would not include the wwwroot folder. So, when I add the folder to my project it will look like (and behave like) a standard folder:

.NET Core Console App

When you create it using the ASP.NET Core Web Application project template, the wwwroot folder looks like this:

ASP.NET Core Web Application

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?


Additional Question - Behavior (Copying Files to Output Directory)
In the standard .NET Core project, I would have to add this to my .csproj file:

<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. I looked in the ASP.NET Core Web Application's .csproj file and didn't see anything like that.

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.

like image 521
Svek Avatar asked Jun 11 '17 03:06

Svek


1 Answers

After reading this page that announced the new tooling in Visual Studio 2017, I found out that it was in fact possible.

I noticed that the ASP.NET Core Web Application project uses a different value under the Project node in the .csproj file.

<Project Sdk="Microsoft.NET.Sdk.Web">

Whereas the standard project templates used Microsoft.NET.Sdk like this:

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

Step1

Then I included it into the project and now:

Step2

Great! I hope this answer helps others.

like image 97
Svek Avatar answered Oct 05 '22 01:10

Svek