Skip to content

_ReplaceFingerprintedBlazorJsForPublish incorrectly computes assets #119886

Closed

Description

@Denny09310

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I created a project consisting of a Blazor WebAssembly Standalone frontend and a Web API backend hosting the client application.
Everything runs correctly during development, but when attempting to publish, the process fails both with net9.0 and net10.0

Expected Behavior

The project should publish successfully without errors.

Steps To Reproduce

  1. Navigate to the Server project folder

  2. Run:

    dotnet publish

Exceptions (if any)

Restore completed (0.9s)
info NETSDK1057: You are using a preview version of .NET. See https://aka.ms/dotnet-support-policy
Client succeeded (13.9s) → {PROJECT_ROOT}\Client\bin\Release\net10.0\wwwroot
Client failed with 3 errors (6.4s)
C:\Program Files\dotnet\sdk\10.0.100-rc.1.25451.107\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(175,5): error No 'BasePath' metadata present for element '.' and no default value was provided.
C:\Program Files\dotnet\sdk\10.0.100-rc.1.25451.107\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(175,5): error No 'ContentRoot' metadata present for element '.' and no default value was provided.
C:\Program Files\dotnet\sdk\10.0.100-rc.1.25451.107\Sdks\Microsoft.NET.Sdk.BlazorWebAssembly\targets\Microsoft.NET.Sdk.BlazorWebAssembly.6_0.targets(175,5): error
System.InvalidOperationException: There is no file for the resource in either the locations '{PROJECT_ROOT}\Client' or '.'.
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.StaticWebAsset.ResolveFile(String identity, String originalItemSpec)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssets.ResolveFileDetails(String originalItemSpec, String identity)
   at Microsoft.AspNetCore.StaticWebAssets.Tasks.DefineStaticWebAssets.Execute()
Server failed (3.0s) → bin\Release\net10.0\Server.dll

.NET Version

.NET 10.0.100-rc.1.25451.107

Anything else?

Full environment details:

.NET SDK:
 Version:           10.0.100-rc.1.25451.107
 Commit:            2db1f5ee2b
 Workload version:  10.0.100-rc.1.25458.2
 MSBuild version:   17.15.0-preview-25451-107+2db1f5ee2

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.26100
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\10.0.100-rc.1.25451.107\

Installed .NET Workloads:
 [android]
   Source: SDK 10.0.100-rc.1, VS 18.0.11012.119
   Manifest versions: 36.0.0-rc.1.285/10.0.100-rc.1
   Manifest path:     C:\Program Files\dotnet\sdk-manifests\10.0.100-rc.1\microsoft.net.sdk.android\36.0.0-rc.1.285\WorkloadManifest.json
   Install type:      MSI

 [ios]
   Source: SDK 10.0.100-rc.1, VS 18.0.11012.119
   Manifest versions: 18.5.10727-net10-rc.1/10.0.100-rc.1
   Manifest path:     C:\Program Files\dotnet\sdk-manifests\10.0.100-rc.1\microsoft.net.sdk.ios\18.5.10727-net10-rc.1\WorkloadManifest.json
   Install type:      MSI

 [maccatalyst]
   Source: SDK 10.0.100-rc.1, VS 18.0.11012.119
   Manifest versions: 18.5.10727-net10-rc.1/10.0.100-rc.1
   Manifest path:     C:\Program Files\dotnet\sdk-manifests\10.0.100-rc.1\microsoft.net.sdk.maccatalyst\18.5.10727-net10-rc.1\WorkloadManifest.json
   Install type:      MSI

 [maui-windows]
   Source: SDK 10.0.100-rc.1, VS 18.0.11012.119
   Manifest versions: 10.0.0-rc.1.25452.6/10.0.100-rc.1
   Manifest path:     C:\Program Files\dotnet\sdk-manifests\10.0.100-rc.1\microsoft.net.sdk.maui\10.0.0-rc.1.25452.6\WorkloadManifest.json
   Install type:      MSI

 [wasm-tools]
   Source: SDK 10.0.100-rc.1
   Manifest versions: 10.0.100-rc.1.25451.107/10.0.100-rc.1
   Manifest path:     C:\Program Files\dotnet\sdk-manifests\10.0.100-rc.1\microsoft.net.workload.mono.toolchain.current\10.0.100-rc.1.25451.107\WorkloadManifest.json
   Install type:      MSI

Configured to use workload sets when installing new manifests.

Host:
  Version:      10.0.0-rc.1.25451.107
  Architecture: x64
  Commit:       2db1f5ee2b

.NET SDKs installed:
  10.0.100-rc.1.25451.107 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 9.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 10.0.0-rc.1.25451.107 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 9.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 10.0.0-rc.1.25451.107 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 8.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 9.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 10.0.0-rc.1.25451.107 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
  DOTNET_REACTOR                           [C:\Program Files (x86)\Eziriz\.NET Reactor]
  DOTNET_REACTOR_CMD                       [C:\Program Files (x86)\Eziriz\.NET Reactor\dotNET_Reactor.Console.exe]

global.json file:
  Not found

blazor-app-1.zip

Activity

  1. javiercn commented on Sep 19, 2025

    @javiercn
    Member

    @Denny09310 thanks for contacting us.

    The issue is not with either MapStaticAssets nor with StaticWebAssets from what I can tell, but in how the Web assembly SDK is computing something (as per the image below).

    Image

    I'll transfer this to the runtime repo for triaging there and adjust the title accordingly

  2. javiercn commented on Sep 19, 2025

    @javiercn
    Member

    Somewhere around here seems to be the problem.

      <Target Name="_ReplaceFingerprintedBlazorJsForPublish" DependsOnTargets="ProcessPublishFilesForWasm" Condition="'$(WasmBuildingForNestedPublish)' != 'true' and '$(BlazorFingerprintBlazorJs)' == 'true'">
        <PropertyGroup>
          <_BlazorJSFileNames>;@(_BlazorJSFile->'%(FileName)');</_BlazorJSFileNames>
        </PropertyGroup>
        <ItemGroup>
          <_BlazorJSJSStaticWebAsset Include="@(StaticWebAsset)" Condition="$(_BlazorJSFileNames.Contains(';%(FileName);')) and '%(Extension)' == '.js'" />
          <_BlazorJSPublishCandidate Include="%(_BlazorJSJSStaticWebAsset.RelativeDir)%(_BlazorJSJSStaticWebAsset.FileName).%(_BlazorJSJSStaticWebAsset.Fingerprint)%(_BlazorJSJSStaticWebAsset.Extension)" />
          <_BlazorJSPublishCandidate Remove="@(_BlazorJSPublishCandidate)" Condition="'%(Extension)' == '.map'" />
          <_BlazorJSPublishCandidate>
            <RelativePath>_framework/$([System.IO.Path]::GetFileNameWithoutExtension('%(Filename)'))%(Extension)</RelativePath>
          </_BlazorJSPublishCandidate>
        </ItemGroup>
  3. changed the title [-]Can't publish Blazor WASM hosted when using 'MapStaticAssets'[/-] [+]_ReplaceFingerprintedBlazorJsForPublish incorrectly computes assets[/+] on Sep 19, 2025
  4. transferred this issue fromdotnet/aspnetcoreon Sep 19, 2025
  5. added
    untriaged
    on Sep 19, 2025
  6. added
    arch-wasm
    on Sep 19, 2025
  7. added
    needs-area-label
    on Sep 19, 2025
  8. added and removed
    needs-area-label
    on Sep 20, 2025
  9. maraf commented on Sep 20, 2025

    @maraf
    Member

    Work in progress

    1. The $(BlazorWebAssemblyJSPath) is computed correctly in _ResolveBlazorWasmOutputs
    2. The @(_BlazorJSFile) is created based on BlazorWebAssemblyJSPath as well
    3. So it @(_BlazorJSStaticWebAsset)
    4. But when _ReplaceFingerprintedBlazorJsForPublish is executed the is empty @(_BlazorJSFile)

    @(StaticWebAssets) is preserved between Client project builds, but @(_BlazorJSFile) is not. Re-running _ResolveBlazorWasmOutputs causes SWA to contain 2 instances of blazor.webassembly.js

  10. added this to the 10.0.0 milestone on Sep 20, 2025
  11. added
    os-browser
    and removed
    untriaged
    on Sep 20, 2025
  12. self-assigned this
    on Sep 20, 2025
  13. maraf commented on Sep 26, 2025

    @maraf
    Member
  14. locked and limited conversation to collaborators on Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-Build-monoos-browser

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions