Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 30, 2025

This PR fixes an issue where web applications referencing Sdk.WebAssembly projects fail to build with the error "The UpdateExternallyDefinedStaticWebAssets task failed unexpectedly". The error occurs because the WasmSdk was missing the StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute property that is already present in the BlazorWebAssembly SDK.

The fix adds the missing property to /src/WasmSdk/Sdk/Sdk.props:

<StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute Condition="'$(StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute)' == ''">true</StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute>

This ensures consistency between the WasmSdk and BlazorWebAssembly SDK implementations and allows static web assets to resolve file paths correctly when processing externally defined assets.

The property includes a conditional check to avoid overriding any user-defined values, following the same pattern used in the BlazorWebAssembly SDK.

Fixes dotnet/runtime#118393, dotnet/aspnetcore#62915


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Make sure StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute for wasm apps is not empty Add StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute property to WasmSdk Jul 30, 2025
@Copilot Copilot AI requested a review from ilonatommy July 30, 2025 12:31
Copilot finished work on behalf of ilonatommy July 30, 2025 12:31
@ilonatommy ilonatommy marked this pull request as ready for review July 30, 2025 12:32
@Copilot Copilot AI review requested due to automatic review settings July 30, 2025 12:32
@ilonatommy ilonatommy added this to the 11.0.1xx milestone Jul 30, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a build failure in web applications that reference Sdk.WebAssembly projects by adding a missing property to the WasmSdk. The error "The UpdateExternallyDefinedStaticWebAssets task failed unexpectedly" occurred because the WasmSdk lacked a property that was already present in the BlazorWebAssembly SDK.

  • Adds StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute property to WasmSdk
  • Ensures consistency between WasmSdk and BlazorWebAssembly SDK implementations
  • Includes conditional check to avoid overriding user-defined values
Comments suppressed due to low confidence (1)

src/WasmSdk/Sdk/Sdk.props:29

  • This property addition should include test coverage to verify that it resolves the build failure when web applications reference Sdk.WebAssembly projects. Consider adding a test that validates the property is set correctly and that the UpdateExternallyDefinedStaticWebAssets task succeeds.
    <StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute Condition="'$(StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute)' == ''">true</StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute>

@ilonatommy ilonatommy modified the milestones: 11.0.1xx, 10.0.1xx Jul 30, 2025
@pavelsavara
Copy link
Member

There are more defaults. Should we use them all ?

<!-- Static web assets defaults -->
<StaticWebAssetProjectMode Condition="'$(StaticWebAssetProjectMode)' == ''">Root</StaticWebAssetProjectMode>
<StaticWebAssetsAdditionalPublishProperties>$(StaticWebAssetsAdditionalPublishProperties);_PublishingBlazorWasmProject=true</StaticWebAssetsAdditionalPublishProperties>
<StaticWebAssetsAdditionalEmbeddedPublishProperties>$(StaticWebAssetsAdditionalEmbeddedPublishProperties);_PublishingBlazorWasmProject=true</StaticWebAssetsAdditionalEmbeddedPublishProperties>
<StaticWebAssetStandaloneHosting Condition="'$(StaticWebAssetStandaloneHosting)' == '' and '$(StaticWebAssetProjectMode)' == 'Root'">true</StaticWebAssetStandaloneHosting>
<StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute Condition="'$(StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute)' == ''">true</StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute>
<StaticWebAssetsGetEmbeddedPublishAssetsTargets>ComputeFilesToPublish;GetCurrentProjectEmbeddedPublishStaticWebAssetItems</StaticWebAssetsGetEmbeddedPublishAssetsTargets>

@ilonatommy
Copy link
Member

ilonatommy commented Jul 30, 2025

There are more defaults. Should we use them all ?

<!-- Static web assets defaults -->
<StaticWebAssetProjectMode Condition="'$(StaticWebAssetProjectMode)' == ''">Root</StaticWebAssetProjectMode>
<StaticWebAssetsAdditionalPublishProperties>$(StaticWebAssetsAdditionalPublishProperties);_PublishingBlazorWasmProject=true</StaticWebAssetsAdditionalPublishProperties>
<StaticWebAssetsAdditionalEmbeddedPublishProperties>$(StaticWebAssetsAdditionalEmbeddedPublishProperties);_PublishingBlazorWasmProject=true</StaticWebAssetsAdditionalEmbeddedPublishProperties>
<StaticWebAssetStandaloneHosting Condition="'$(StaticWebAssetStandaloneHosting)' == '' and '$(StaticWebAssetProjectMode)' == 'Root'">true</StaticWebAssetStandaloneHosting>
<StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute Condition="'$(StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute)' == ''">true</StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute>
<StaticWebAssetsGetEmbeddedPublishAssetsTargets>ComputeFilesToPublish;GetCurrentProjectEmbeddedPublishStaticWebAssetItems</StaticWebAssetsGetEmbeddedPublishAssetsTargets>

Good question. StaticWebAssetsAdditionalPublishProperties and StaticWebAssetsAdditionalEmbeddedPublishProperties look like blazor-specific. The rest can probably be added for pure wasm.

Edit:
some of them are already set in https://github.com/dotnet/runtime/blob/123627ba0f80c268cbde5beb6db42dc5c12d150d/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.props#L34
Now I'm not that confident if I'm making the change in the right place. It should probably be with other default props in the runtime.

Props that do not look blazor-specific and are not set, neither in sdk nor in runtime:

  • StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute
  • StaticWebAssetsGetEmbeddedPublishAssetsTargets

I would wait for @maraf with the decision.

Comment on lines +28 to +30
<!-- Static web assets defaults -->
<StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute Condition="'$(StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute)' == ''">true</StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute>

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are similar properties in the Blazor WebAssembly SDK, we should remove them from there since that SDK imports this SDK and they are no longer needed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot fix it

@javiercn
Copy link
Member

javiercn commented Aug 5, 2025

No, we don't care about the remaining defaults, they are Blazor specific

Copy link
Member

@maraf maraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move the setting to https://github.com/dotnet/runtime/blob/main/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.props#L32-L39 if having the property set only after the nuget packages are restored is early enough

@ilonatommy ilonatommy closed this Aug 5, 2025
@javiercn
Copy link
Member

javiercn commented Aug 5, 2025

We should move the setting to https://github.com/dotnet/runtime/blob/main/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.props#L32-L39 if having the property set only after the nuget packages are restored is early enough

It should be

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make sure StaticWebAssetMakeReferencedAssetOriginalItemSpecAbsolute for wasm apps is not empty
5 participants