Skip to content

Conversation

ilonatommy
Copy link
Member

Fixes #77174.

@ilonatommy ilonatommy self-assigned this Sep 25, 2025
@ilonatommy ilonatommy added arch-wasm WebAssembly architecture area-Build-mono labels Sep 25, 2025
@JakeYallop
Copy link
Contributor

Its also worth pointing that dotnet.d.ts is currently explicitly removed from the build via:

_WasmBuildFilesToRemove:

<Output TaskParameter="FilesToRemove" ItemName="_WasmBuildFilesToRemove" />

Which is an output from the ComputeWasmBuildAssets task, in that task:

if (AssetsComputingHelper.ShouldFilterCandidate(candidate, TimeZoneSupport, InvariantGlobalization, LoadFullICUData, CopySymbols, customIcuCandidateFilename, EnableThreads, EnableDiagnostics, EmitSourceMap, out var reason))

".ts" when fromMonoPackage && fileName == "dotnet.d" => "dotnet type definition is not used by Blazor",

@ilonatommy ilonatommy marked this pull request as ready for review October 3, 2025 16:01
@Copilot Copilot AI review requested due to automatic review settings October 3, 2025 16:01
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

Adds an opt-in MSBuild property to copy the generated dotnet.d.ts TypeScript definition file into a WebAssembly project's wwwroot during build, addressing issue #77174.

  • Introduces WasmEmitTypeScriptDefinitions property (default false) in relevant .targets.
  • Adds MSBuild target _EnsureDotnetTypeScriptDefinitions to perform the conditional copy.
  • Adds a test validating the file copy on build (Debug/Release).

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/mono/wasm/build/WasmApp.Common.targets Documents and defines the new WasmEmitTypeScriptDefinitions property.
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets Adds property default again and new target to copy dotnet.d.ts into wwwroot.
src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTests.cs Adds test ensuring dotnet.d.ts is copied on build when the property is enabled.

<WasmStripILAfterAOT Condition="'$(WasmStripILAfterAOT)' == ''">true</WasmStripILAfterAOT>
<WasmRuntimeAssetsLocation Condition="'$(WasmRuntimeAssetsLocation)' == ''">_framework</WasmRuntimeAssetsLocation>
<MetricsSupport Condition="'$(MetricsSupport)' == ''">false</MetricsSupport>
<WasmEmitTypeScriptDefinitions Condition="'$(WasmEmitTypeScriptDefinitions)' == ''">false</WasmEmitTypeScriptDefinitions>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<WasmEmitTypeScriptDefinitions Condition="'$(WasmEmitTypeScriptDefinitions)' == ''">false</WasmEmitTypeScriptDefinitions>

There is no need to set the property here as well

Copy link
Member Author

Choose a reason for hiding this comment

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

Because src\mono\wasm\build\WasmApp.Common.targets is imported in workloads and src\mono\nuget\Microsoft.NET.Sdk.WebAssembly.Pack\build\Microsoft.NET.Sdk.WebAssembly.Browser.targets is imported generally in runtime pack?

Copy link
Member Author

Choose a reason for hiding this comment

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

If so, then this doc in the top of workload-shipped targets should keep WasmEmitTypeScriptDefinitions. Right?

@ilonatommy
Copy link
Member Author

WBT fail, even though manual run of dotnet build on the WBT project succeeds:
log dotnet.d.ts should be created at /root/helix/work/workitem/e/wbt artifacts/tsdefs_Debug_False_h1qa4fpe_vyr_鿀蜒枛遫䡫煉/wwwroot/dotnet.d.ts after the build with WasmEmitTypeScriptDefinitions=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-Build-mono

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet.d.ts should be include in the wasmbrowser template

4 participants