10

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

Zachscs
  • 3,353
  • 7
  • 27
  • 52

3 Answers3

14

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.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • 1
    I have opened an issue on GitHub for this problem - https://github.com/aspnet/templating/issues/559 – Matt Ward Jun 08 '18 at 18:18
  • 1
    Issue logged a year ago, still having this issue in Aug 2019. – Yini Aug 15 '19 at 11:14
  • The problem is the fix was not backported to .NET Core 2.1 SDK. – Matt Ward Aug 15 '19 at 15:36
  • I had the issue Jan 2020 XD – Ivan Lopez Feb 12 '20 at 01:34
  • Visual Studio 8.5 hides duplicate files in the Solution window so this problem goes away even if the SDK is not updated. This fix may be backported to 8.4 but right now it is not available in 8.4. There is a different problem with .NET Core 3 since it defines some MSBuild multiple times with a condition which is not handled by older VS Mac versions. – Matt Ward Feb 12 '20 at 14:31
1

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.

Zachscs
  • 3,353
  • 7
  • 27
  • 52
1

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

<ItemGroup>
    <None Include="**/*" />
</ItemGroup>
Meer
  • 678
  • 6
  • 12