2
votes

I'm trying to have to 2 client projects and 1 server project in Blazor. So I created a new Blazor WebAssembly App, with https,asp.net Core hosted and Progressive Web Application checks checked.

Now I have 3 autogenerated projects , the client , the server and the shared project.

Let's assume that I need another client project that has to communicate with the same server.

I add a new blazor project ,I choose Blazor WebAssembly App but this time I uncheck ASP.NET Core Hosted and Progressive Web Application (I don't need that this application works offline).

So now I have 2 clients ,1 server , 1 shared project.

The next thing that I do is to add a reference from my server to the new client project.

Everything seems fine until this error appears:

Blazor static assets - conflicting assets with the same path

I've found this discussion on github: https://github.com/dotnet/aspnetcore/issues/20580

They say that you have to write <StaticWebAssetBasePath>clientA</StaticWebAssetBasePath> <StaticWebAssetBasePath>clientB</StaticWebAssetBasePath> into your client projects.

When I click on the error visual studio show me a file named Microsoft.Net.Sdk.Razor.StaticWebAssets.targets and bring me on the line 191 that is:

 <ValidateStaticWebAssetsUniquePaths
      StaticWebAssets="@(_ReferencedStaticWebAssets)"
      WebRootFiles="@(_WebRootFiles)" />

I don't think that I have to modify this file , so what should I modify?

1

1 Answers

4
votes

Ok I may have found where I had to write the tags , and I think that this will be helpful for other people. I opened the csproj of my 2 clients and under the PropertyGroup tag I wrote:

<PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
    <StaticWebAssetBasePath>.clientA</StaticWebAssetBasePath>
  </PropertyGroup>

And for my client B

<PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
    <StaticWebAssetBasePath>.clientB</StaticWebAssetBasePath>
  </PropertyGroup>

Now the error is gone.