Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/BenchmarkDotNet/Portability/RuntimeInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ internal static string GetRuntimeVersion()
}
}

return $".NET Core (Mono) {versionString}";
string runtimeName = IsMono ? "Mono" : "CoreCLR";
return $".NET Core ({runtimeName}) {versionString}";
}
else if (IsOldMono)
{
Expand Down
2 changes: 1 addition & 1 deletion src/BenchmarkDotNet/Templates/WasmCsProj.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<Import Project="$(WasmPropsPath)" Condition="Exists($(WasmPropsPath))" />

$CORECLR_OVERRIDES$
<PropertyGroup>
<OutputType>Exe</OutputType>
<RuntimeConfig>Release</RuntimeConfig>
Expand Down
19 changes: 17 additions & 2 deletions src/BenchmarkDotNet/Toolchains/MonoWasm/WasmGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,22 @@ protected void GenerateProjectFile(BuildPartition buildPartition, ArtifactsPaths
var xmlDoc = new XmlDocument();
xmlDoc.Load(projectFile.FullName);
var (customProperties, _) = GetSettingsThatNeedToBeCopied(xmlDoc, projectFile);
// Microsoft.NET.Sdk.WebAssembly auto-defaults UseMonoRuntime=true.
string sdkName = runtime.IsMonoRuntime ? "Microsoft.NET.Sdk.WebAssembly" : "Microsoft.NET.Sdk";
string sdkName = "Microsoft.NET.Sdk.WebAssembly";

// For CoreCLR WASM:
// - UseMonoRuntime=false: resolves CoreCLR runtime pack instead of Mono
// - WasmBuildNative=false: avoids requiring wasm-tools workload
// - WasmEnableWebcil=false: CoreCLR doesn't support webcil format
string coreclrOverrides = runtime.IsMonoRuntime
? string.Empty
: @"
<!-- CoreCLR overrides: use CoreCLR runtime instead of Mono -->
<PropertyGroup>
<UseMonoRuntime>false</UseMonoRuntime>
<WasmBuildNative>false</WasmBuildNative>
<WasmEnableWebcil>false</WasmEnableWebcil>
</PropertyGroup>
";

string content = new StringBuilder(ResourceHelper.LoadTemplate("WasmCsProj.txt"))
.Replace("$PLATFORM$", buildPartition.Platform.ToConfig())
Expand All @@ -60,6 +74,7 @@ protected void GenerateProjectFile(BuildPartition buildPartition, ArtifactsPaths
.Replace("$SDKNAME$", sdkName)
.Replace("$WASMDATADIR$", runtime.WasmDataDir)
.Replace("$TARGET$", CustomRuntimePack.IsNotBlank() ? "PublishWithCustomRuntimePack" : "Publish")
.Replace("$CORECLR_OVERRIDES$", coreclrOverrides)
.ToString();

File.WriteAllText(artifactsPaths.ProjectFilePath, content);
Expand Down