Aspnetcore: [Blazor-WASM 3.2 Preview 2] Separate UI from hosting model

Created on 12 Mar 2020  路  9Comments  路  Source: dotnet/aspnetcore

Until wasm 3.2 preview 2 I was able to extract the UI part into a separate razor class library and reference it in the Wasm client.

Today I am unable to upgrade my projects to this preview because of this aspect:

Duplicate base paths '/' for content root paths 'D:\user\gitRepos\BlazorApp1\UI\wwwroot\' and 'D:\user\gitRepos\BlazorApp1\BlazorApp1\Client\bin\Debug\netstandard2.1\wwwroot\'. ('D:\user\gitRepos\BlazorApp1\UI\wwwroot\css\bootstrap\bootstrap.min.css', 'D:\user\gitRepos\BlazorApp1\BlazorApp1\Client\obj\Debug\netstandard2.1\blazor\serviceworkerassets.js') BlazorApp1.Client C:\Program Files\dotnet\sdk\3.1.200-preview-015002\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets

Here is the structure:

image

UI project is a netstandard2.1 razor class library.

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

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
    <AssemblyVersion>1.0.3.20072</AssemblyVersion>
    <FileVersion>1.0.3.20072</FileVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview2.20160.5" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview2.20160.5" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="3.2.0-preview2.20160.5" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\BlazorApp1\Shared\BlazorApp1.Shared.csproj" />
  </ItemGroup>

</Project>

Any tips on how to make this work again?

Author Feedback area-blazor blazor-wasm

Most helpful comment

@mihaimyh

Thank you, adding sdk 3.1.102 and other tweaks made it work again.

Could you please tell a little bit more about the other tweaks you made. I got the same problem. Adding Global.json did not help.

@uwefms

Did you change the package references of your Razor class library .csproj to use the Microsoft.AspNetCore.Components.WebAssembly 3.2 preview bits? I did that and ran into the duplicate base paths '/' error. The preview web assembly stuff is only needed for the client project - the Razor class library can stay on 3.1:

<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.2" />
    <!-- NOTE: DON'T INCLUDE THESE!
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview2.20160.5" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview2.20160.5" />    
    -->
  </ItemGroup>
</Project>

In my case, I didn't need the global.json, I just needed to leave my Razor class library unchanged!

All 9 comments

Thanks for contacting us, @mihaimyh.
@javiercn can you please look into this? Thanks!

@mihaimyh It looks like you are using a preview version of an SDk. Can you create a globa.json file at the top of your solution folder and point it to the 3.1.102 sdk with dotnet new globaljson --sdk-version 3.1.102 after that you should have no problem.

Let us know if you still run into issues and provide a minimal repro project if that is the case. You might need to close and open visual studio for the changes to take effect (as well as have the 3.1.102 SDK installed).

@javiercn Thank you, adding sdk 3.1.102 and other tweaks made it work again.

@mihaimyh

Thank you, adding sdk 3.1.102 and other tweaks made it work again.

Could you please tell a little bit more about the other tweaks you made. I got the same problem. Adding Global.json did not help.

Duplicate base paths '/' for content root paths
'J:__Blazor_Core_3.2_SP2_RTM\CSLA\ref\BlazorMultiHead-master\BlazorMultiHead\Ui\bin\Debugnetstandard2.1\wwwroot\' and
'J:__Blazor_Core_3.2_SP2_RTM\CSLA\ref\BlazorMultiHead-master\BlazorMultiHead\Client\bin\Debugnetstandard2.1\wwwroot\'.
('J:__Blazor_Core_3.2_SP2_RTM\CSLA\ref\BlazorMultiHead-master\BlazorMultiHead\Ui\obj\Debugnetstandard2.1\BlazorMultiHead.Ui.dll',
'J:__Blazor_Core_3.2_SP2_RTM\CSLA\ref\BlazorMultiHead-master\BlazorMultiHead\Client\obj\Debugnetstandard2.1\BlazorMultiHead.Client.dll')
BlazorMultiHead.Client
C:\Program Files\dotnet\sdk\3.1.200-preview-015002\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets
195

regards

  Uwe

@mihaimyh

Thank you, adding sdk 3.1.102 and other tweaks made it work again.

Could you please tell a little bit more about the other tweaks you made. I got the same problem. Adding Global.json did not help.

@uwefms

Did you change the package references of your Razor class library .csproj to use the Microsoft.AspNetCore.Components.WebAssembly 3.2 preview bits? I did that and ran into the duplicate base paths '/' error. The preview web assembly stuff is only needed for the client project - the Razor class library can stay on 3.1:

<Project Sdk="Microsoft.NET.Sdk.Razor">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components" Version="3.1.2" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="3.1.2" />
    <!-- NOTE: DON'T INCLUDE THESE!
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview2.20160.5" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.2.0-preview2.20160.5" />    
    -->
  </ItemGroup>
</Project>

In my case, I didn't need the global.json, I just needed to leave my Razor class library unchanged!

I also have this strange issue with duplicate paths...
Thanks @entitycontext you saved me!. I only have the Microsoft.AspNetCore.Components.WebAssembly stuff in the clientweb project, then in the Razor class libraries Im doing like you suggested - It work like a charm

Why is it closed? Its an issue...

Same problem here.

Hi.

It looks like you are posting on a closed issue!
We're very likely to lose track of your bug/feedback/question unless you:

  1. Open a new issue
  2. Explain very clearly what you need help with
  3. If you think you have found a bug, include detailed repro steps so that we can investigate the problem
Was this page helpful?
0 / 5 - 0 ratings

Related issues

fayezmm picture fayezmm  路  3Comments

UweKeim picture UweKeim  路  3Comments

rbanks54 picture rbanks54  路  3Comments

markrendle picture markrendle  路  3Comments

BrennanConroy picture BrennanConroy  路  3Comments