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.
Asked
Active
Viewed 3,743 times
10

Zachscs
- 3,353
- 7
- 27
- 52
-
I am still facing the issue. – Mohammed Gadi Feb 02 '20 at 11:43
3 Answers
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
-
1I 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
-
-
-
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