diff --git a/eng/Subsets.props b/eng/Subsets.props
index 0674e93cf4ded7..8b1a2dafc496cd 100644
--- a/eng/Subsets.props
+++ b/eng/Subsets.props
@@ -761,13 +761,9 @@
diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Crossgen2/Sdk.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Crossgen2/Sdk.props
deleted file mode 100644
index a5cdb6c55a638d..00000000000000
--- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Crossgen2/Sdk.props
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- <_Crossgen2PackExeSuffix Condition="$([MSBuild]::IsOSPlatform('Windows'))">.exe
- $([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', '..', 'tools', 'crossgen2$(_Crossgen2PackExeSuffix)'))
-
-
diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Crossgen2.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Crossgen2.props
index 9edd9f702fa280..7babe847a2cf92 100644
--- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Crossgen2.props
+++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Crossgen2.props
@@ -24,10 +24,6 @@
OutputItemType="_RawCrossgenPublishFiles"
ReferenceOutputAssembly="false"
Private="false" />
-
-
-
CoreCLR
+
+ true
+
<_CoreCLRInvalidEH Condition="'$(WasmEnableExceptionHandling)' != '' and '$(WasmEnableExceptionHandling)' != 'true'">true
<_CoreCLRInvalidSIMD Condition="'$(WasmEnableSIMD)' != '' and '$(WasmEnableSIMD)' != 'true'">true
@@ -640,6 +644,15 @@
+
+
+
+
+
<_WasmPInvokeTablePath>$(_WasmIntermediateOutputPath)callhelpers-pinvoke.cpp
@@ -694,21 +707,20 @@
<_WasmManagedAssemblies Include="$(_CoreLibPath)" />
-
+
<_Crossgen2ExeSuffix Condition="'$(OS)' == 'Windows_NT'">.exe
$([MSBuild]::NormalizePath('$(Crossgen2InBuildDir)', 'crossgen2$(_Crossgen2ExeSuffix)'))
$(Crossgen2ToolPath)
+ @(Crossgen2Tool)
+ Text="Could not resolve crossgen2. Update the .NET SDK and restore the project, or set %24(Crossgen2Path) to a crossgen2 executable." />
+ Text="Set %24(Crossgen2Path) to a crossgen2 executable, not the DLL '$(Crossgen2Path)'." />
+ Text="crossgen2 executable not found: '$(Crossgen2Path)'. Build or restore crossgen2, or correct %24(Crossgen2Path)." />
<_Crossgen2GeneratorRsp>$(_WasmIntermediateOutputPath)callhelpers-generator.rsp
diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in
index 48286c531fca63..7b600623e798d8 100644
--- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in
+++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.json.in
@@ -11,8 +11,7 @@
"Microsoft.NET.Sdk.WebAssembly.Pack.${NetVersion}",
"Microsoft.NETCore.App.Runtime.Mono.${NetVersion}.browser-wasm",
"Microsoft.NETCore.App.Runtime.${NetVersion}.browser-wasm",
- "Microsoft.NETCore.App.Runtime.AOT.Cross.${NetVersion}.browser-wasm",
- "Microsoft.NETCore.App.Crossgen2.${NetVersion}"
+ "Microsoft.NETCore.App.Runtime.AOT.Cross.${NetVersion}.browser-wasm"
],
"extends": [ "microsoft-net-runtime-mono-tooling", "microsoft-net-sdk-emscripten" ],
"platforms": [ "win-x64", "win-arm64", "linux-x64", "linux-arm64", "linux-musl-x64", "linux-musl-arm64", "osx-x64", "osx-arm64" ]
@@ -453,20 +452,6 @@
"osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-arm64.Cross.wasi-wasm"
}
},
- "Microsoft.NETCore.App.Crossgen2.${NetVersion}": {
- "kind": "Sdk",
- "version": "${PackageVersion}",
- "alias-to": {
- "win-x64": "Microsoft.NETCore.App.Crossgen2.win-x64",
- "win-arm64": "Microsoft.NETCore.App.Crossgen2.win-arm64",
- "linux-x64": "Microsoft.NETCore.App.Crossgen2.linux-x64",
- "linux-arm64": "Microsoft.NETCore.App.Crossgen2.linux-arm64",
- "linux-musl-x64": "Microsoft.NETCore.App.Crossgen2.linux-musl-x64",
- "linux-musl-arm64": "Microsoft.NETCore.App.Crossgen2.linux-musl-arm64",
- "osx-x64": "Microsoft.NETCore.App.Crossgen2.osx-x64",
- "osx-arm64": "Microsoft.NETCore.App.Crossgen2.osx-arm64"
- }
- },
"Microsoft.NETCore.App.Runtime.Mono.${NetVersion}.browser-wasm" : {
"kind": "framework",
"version": "${PackageVersion}",
diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in
index 7420fab69354c2..e1b3a6351ae054 100644
--- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in
+++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Current.Manifest/WorkloadManifest.targets.in
@@ -212,18 +212,11 @@
-
+
-
diff --git a/src/mono/wasi/build/WasiApp.CoreCLR.targets b/src/mono/wasi/build/WasiApp.CoreCLR.targets
index 78fcf6424eb0a2..e5ac90b0191c98 100644
--- a/src/mono/wasi/build/WasiApp.CoreCLR.targets
+++ b/src/mono/wasi/build/WasiApp.CoreCLR.targets
@@ -26,6 +26,7 @@
CoreCLR
false
+ true
false
@@ -86,6 +87,16 @@
+
+
+
+
+
-
+
<_Crossgen2ExeSuffix Condition="'$(OS)' == 'Windows_NT'">.exe
$([MSBuild]::NormalizePath('$(Crossgen2InBuildDir)', 'crossgen2$(_Crossgen2ExeSuffix)'))
$(Crossgen2ToolPath)
+ @(Crossgen2Tool)
+ Text="Could not resolve crossgen2. Update the .NET SDK and restore the project, or set %24(Crossgen2Path) to a crossgen2 executable." />
+ Text="Set %24(Crossgen2Path) to a crossgen2 executable, not the DLL '$(Crossgen2Path)'." />
+ Text="crossgen2 executable not found: '$(Crossgen2Path)'. Build or restore crossgen2, or correct %24(Crossgen2Path)." />
<_Crossgen2GeneratorRsp>$(_WasiRelinkObjDir)callhelpers-generator.rsp
diff --git a/src/mono/wasm/Wasm.Build.Tests/CoreCLRWasmNativeDefaultsTests.cs b/src/mono/wasm/Wasm.Build.Tests/CoreCLRWasmNativeDefaultsTests.cs
index 883cfbbab3d7d8..b99fee0e087c78 100644
--- a/src/mono/wasm/Wasm.Build.Tests/CoreCLRWasmNativeDefaultsTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/CoreCLRWasmNativeDefaultsTests.cs
@@ -151,6 +151,72 @@ public void PublishReadyToRunDirectoryMatchesSdkOutputCasing()
Assert.Equal(Path.Combine(GetObjDir(config), "R2R") + Path.DirectorySeparatorChar, match.Groups[1].Value);
}
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void NativeRelinkResolvesCrossgen2WithoutReadyToRun(bool publish)
+ {
+ ProjectInfo info = CopyTestAsset(
+ Configuration.Debug,
+ aot: false,
+ TestAsset.WasmBasicTestApp,
+ "coreclr_sdk_crossgen2",
+ extraProperties: """
+ false
+ true
+ """,
+ insertAtEnd: $$"""
+
+
+
+
+
+
+
+
+
+
+
+ """);
+
+ // Run the generator, then stop before native compilation.
+ string output = publish
+ ? PublishProject(info, Configuration.Debug, new PublishOptions(ExpectSuccess: false)).buildOutput
+ : BuildProject(info, Configuration.Debug, new BuildOptions(ExpectSuccess: false)).buildOutput;
+
+ Assert.Contains("Stopping after validating SDK crossgen2", output);
+ }
+
+ [Theory]
+ [InlineData(false)]
+ [InlineData(true)]
+ public void NativeRelinkWithoutCrossgen2PackReportsMissingGenerator(bool publish)
+ {
+ ProjectInfo info = CopyTestAsset(
+ Configuration.Debug,
+ aot: false,
+ TestAsset.WasmBasicTestApp,
+ "coreclr_missing_crossgen2",
+ extraProperties: """
+ false
+ false
+ true
+ """);
+
+ string output = publish
+ ? PublishProject(info, Configuration.Debug, new PublishOptions(ExpectSuccess: false)).buildOutput
+ : BuildProject(info, Configuration.Debug, new BuildOptions(ExpectSuccess: false)).buildOutput;
+
+ Assert.Contains("Could not resolve crossgen2. Update the .NET SDK and restore the project, or set $(Crossgen2Path) to a crossgen2 executable.", output);
+ Assert.DoesNotContain("NETSDK1094", output);
+ }
+
private string? BuildAndGetWasmBuildNativeLine(string projectPrefix, string extraProperties, bool expectSuccess)
=> BuildAndGetOutput(projectPrefix, extraProperties, extraItems: "", expectSuccess).line;
diff --git a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs
index f9842bed1047b4..6603a8338ddf86 100644
--- a/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/Templates/WasmTemplateTestsBase.cs
@@ -175,12 +175,15 @@ private static void AddCoreClrProjectProperties(ref string extraProperties, ref
""";
insertAtEnd +=
$$"""
-
{{runtimePackVersion}}
+
+ {{runtimePackVersion}}
+
""";