Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate client-side files in solution explorer with Visual Studio for Mac

Using dotnet cli v2.1.4 I downloaded the Spa templates using dotnet new --install Microsoft.DotNet.Web.Spa.ProjectTemplates::2.0.0. I then created an angular project using dotnet new angular -o my-project. I then opened Visual Studio for Mac and opened the .csproj file generated by the cli for the aforementioned project. The solution was rendered but sadly the client side files were all duplicated even though only one copy of each file appears in the finder or using ls in the directory. I found serveral threads with related issues that advised unloading the project, etc. I tried these solutions but sadly the issue remains, see attached picture. Server side files are not duplicated. Screenshot of duplicate files

like image 843
Zachscs Avatar asked Jun 07 '18 03:06

Zachscs


3 Answers

The problem is that there are duplicate None items defined by the Angular project file. Visual Studio for Mac will not hide these duplicate items, unlike Visual Studio on Windows.

If you edit the .csproj file and add <None Remove="$(SpaRoot)**" /> then the duplicate files will not be shown in the Solution window in Visual Studio for Mac.

<ItemGroup>
  <!-- Don't publish the SPA source files, but do show them in the project files list -->
  <Content Remove="$(SpaRoot)**" />
  <None Remove="$(SpaRoot)**" /> <!-- This has been added -->
  <None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
</ItemGroup>

In the above ItemGroup only the Content items were removed from the SpaRoot directory which is the ClientApp folder.

like image 184
Matt Ward Avatar answered Oct 22 '22 21:10

Matt Ward


I had the following in my .csproj file, removing it fixed for me:

<ItemGroup>
    <None Include="**/*" />
</ItemGroup>
like image 21
Meer Avatar answered Oct 22 '22 20:10

Meer


I was able to solve this by moving the folder ClientApp out of the project directory, then deleting it from the project. I then moved it back and included it in the project again, this time the files were no longer duplicated.

like image 30
Zachscs Avatar answered Oct 22 '22 20:10

Zachscs