Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static web assets have different 'ContentRoot' metadata values when packing Blazor project. #20991

Closed
montyclt opened this issue Apr 19, 2020 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly

Comments

@montyclt
Copy link

Describe the bug

Error when packing Blazor webassembly application that has static assets (wwwroot) and reference to RCL package with static assets.

The error appear after updating from Blazor Webassembly Preview 1 to Preview 3, and remain after updating to Preview 4.

The reason why I pack my Blazor app into NuGet package is because it is the core of my application, and you can develop extensions referencing the core application. Today it is not implemented, but the idea is add the ability of loading extensions at runtime using reflection.

To Reproduce

  1. Add reference to RCL package that include Razor components.
  2. Add wwwroot files to your Blazor application.
  3. Remove manually obj and bin folders. (optionally, the error happens doing it and without doing it)
  4. Build.
  5. Pack your Blazor application into NuGet package.

If I remove my wwwroot folder or I remove reference to Blazored.Typeahead, then I can pack it without any problems.

Severity Code Description Project File Line Suppression State
Error Static web assets have different 'ContentRoot' metadata values 'C:\Users\Trabajo\source\repos\core\Vadavo.Vicim.Core.Blazor\wwwroot' and 'C:\Users\Trabajo\source\repos\core\Vadavo.Vicim.Core.Blazor\bin\Debug\netstandard2.1\wwwroot' for 'C:\Users\Trabajo\source\repos\core\Vadavo.Vicim.Core.Blazor\wwwroot\css\open-iconic\FONT-LICENSE' and 'C:\Users\Trabajo\source\repos\core\Vadavo.Vicim.Core.Blazor\obj\Debug\netstandard2.1\blazor\unlinked\Vadavo.Vicim.Core.Blazor.dll'. Vadavo.Vicim.Core.Blazor C:\Program Files\dotnet\sdk\3.1.201\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 415

Further technical details

  • ASP.NET Core version: Blazor webassembly 3.2 Preview 3 and 4
  • Include the output of dotnet --info:
PS C:\Users\Trabajo> dotnet --info
SDK de .NET Core (reflejando cualquier global.json):
 Version:   3.1.201
 Commit:    b1768b4ae7

Entorno de tiempo de ejecución:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.201\

Host (useful for support):
  Version: 3.1.3
  Commit:  4a9f85e9f8

.NET Core SDKs installed:
  3.1.201 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version: The error happens in Visual Studio 16.5.4 in Windows and dotnet cli in Ubuntu (docker, CI/CD deployment)
  • csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
    <IsPackable>true</IsPackable>
    <Version>1.1.17-beta</Version>
    <BlazorWebAssemblyEnableLinking>false</BlazorWebAssemblyEnableLinking>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="System.Net.Http.Json" Version="3.2.0-preview5.20210.3" />
    <PackageReference Include="Blazored.Typeahead" Version="4.3.0" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview4.20210.8" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview4.20210.8" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview4.20210.8" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="3.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
    <PackageReference Include="MontyClt.Bui" Version="1.0.8-alpha" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Vadavo.Vicim.Core.Client\Vadavo.Vicim.Core.Client.csproj" />
  </ItemGroup>

</Project>
  • Project structure:
    image
@montyclt
Copy link
Author

As temporally workaround, I moved the wwroot directory to Vadavo.Vicim project that is a ASP.NET Core server app that host the Blazor webassembly application, but I don't like it as solution.

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Apr 19, 2020
@javiercn
Copy link
Member

@montyclt thanks for contacting us.

Packing blazor webassembly applications as nuget packages is not a feature we support.

@javiercn javiercn added the feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly label Apr 20, 2020
@montyclt
Copy link
Author

@montyclt thanks for contacting us.

Packing blazor webassembly applications as nuget packages is not a feature we support.

Hi Javier, thanks for your response. That was working on Preview 1.

@ghost ghost locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-wasm This issue is related to and / or impacts Blazor WebAssembly
Projects
None yet
Development

No branches or pull requests

3 participants