From da45bd0bf2e54dac11e815ae6706c3ea51500224 Mon Sep 17 00:00:00 2001 From: Radek Doulik Date: Tue, 14 Apr 2026 15:23:53 +0200 Subject: [PATCH] Enable webcil V1 for CoreCLR wasm builds Add WebcilVersion property to ConvertDllsToWebcil MSBuild task and plumb it through to the WebcilConverter. The SDK targets default to V1 when RuntimeFlavor is CoreCLR, V0 otherwise. Users can override via the WasmWebcilVersion property. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../build/Microsoft.NET.Sdk.WebAssembly.Browser.targets | 7 +++++-- .../ConvertDllsToWebCil.cs | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets index 74e652d5c9bef5..3a89fbcc2d9d15 100644 --- a/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets +++ b/src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets @@ -203,6 +203,9 @@ Copyright (c) .NET Foundation. All rights reserved. <_WasmEnableWebcil>$(WasmEnableWebcil) <_WasmEnableWebcil Condition="'$(_TargetingNET80OrLater)' != 'true'">false <_WasmEnableWebcil Condition="'$(_WasmEnableWebcil)' == ''">true + <_WasmWebcilVersion Condition="'$(_WasmWebcilVersion)' == ''">$(WasmWebcilVersion) + <_WasmWebcilVersion Condition="'$(_WasmWebcilVersion)' == '' and '$(RuntimeFlavor)' == 'CoreCLR'">1 + <_WasmWebcilVersion Condition="'$(_WasmWebcilVersion)' == ''">0 <_BlazorWebAssemblyJiterpreter>$(BlazorWebAssemblyJiterpreter) <_BlazorWebAssemblyRuntimeOptions>$(BlazorWebAssemblyRuntimeOptions) <_WasmInlineBootConfig Condition="'$(_WasmInlineBootConfig)' == '' and '$(_TargetingNET100OrLater)' == 'true'">true @@ -353,7 +356,7 @@ Copyright (c) .NET Foundation. All rights reserved. <_WasmBuildTmpWebcilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'tmp-webcil')) - + @@ -791,7 +794,7 @@ Copyright (c) .NET Foundation. All rights reserved. <_WasmPublishTmpWebcilPath>$([MSBuild]::NormalizeDirectory($(IntermediateOutputPath), 'tmp-webcil', 'publish')) - + diff --git a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs index b214fb74573fe4..582bd7d3098093 100644 --- a/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs +++ b/src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs @@ -23,6 +23,8 @@ public class ConvertDllsToWebcil : Task [Required] public bool IsEnabled { get; set; } + public int WebcilVersion { get; set; } + [Output] public ITaskItem[] WebcilCandidates { get; set; } @@ -133,7 +135,7 @@ private TaskItem ConvertDll(string tmpDir, ITaskItem candidate) { var tmpWebcil = Path.Combine(tmpDir, webcilFileName); var logAdapter = new Microsoft.WebAssembly.Build.Tasks.LogAdapter(Log); - var webcilWriter = Microsoft.WebAssembly.Build.Tasks.WebcilConverter.FromPortableExecutable(inputPath: dllFilePath, outputPath: tmpWebcil, logger: logAdapter); + var webcilWriter = Microsoft.WebAssembly.Build.Tasks.WebcilConverter.FromPortableExecutable(inputPath: dllFilePath, outputPath: tmpWebcil, logger: logAdapter, webcilVersion: WebcilVersion); webcilWriter.ConvertToWebcil(); if (!Directory.Exists(candidatePath))