diff --git a/src/mono/wasm/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs b/src/mono/wasm/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs
index 8123c9cfc1c9ed..015a45dd4fa2c2 100644
--- a/src/mono/wasm/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/BlazorWasmBuildPublishTests.cs
@@ -26,7 +26,7 @@ public BlazorWasmBuildPublishTests(ITestOutputHelper output, SharedBuildPerTestC
[InlineData("Release")]
public void DefaultTemplate_WithoutWorkload(string config)
{
- string id = $"blz_no_workload_{config}";
+ string id = $"blz_no_workload_{config}_{Path.GetRandomFileName()}";
CreateBlazorWasmTemplateProject(id);
// Build
@@ -43,7 +43,7 @@ public void DefaultTemplate_WithoutWorkload(string config)
[InlineData("Release")]
public void DefaultTemplate_NoAOT_WithWorkload(string config)
{
- string id = $"blz_no_aot_{config}";
+ string id = $"blz_no_aot_{config}_{Path.GetRandomFileName()}";
CreateBlazorWasmTemplateProject(id);
BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.FromRuntimePack));
@@ -63,7 +63,7 @@ public void DefaultTemplate_NoAOT_WithWorkload(string config)
[InlineData("Release")]
public void DefaultTemplate_AOT_InProjectFile(string config)
{
- string id = $"blz_aot_prj_file_{config}";
+ string id = $"blz_aot_prj_file_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateBlazorWasmTemplateProject(id);
AddItemsPropertiesToProject(projectFile, extraProperties: "true");
@@ -82,10 +82,10 @@ public void DefaultTemplate_AOT_InProjectFile(string config)
[InlineData("Debug", false)]
[InlineData("Release", true)]
[InlineData("Release", false)]
- [ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
+ //[ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRelink)
{
- string id = $"blz_deploy_on_build_{config}_{nativeRelink}";
+ string id = $"blz_deploy_on_build_{config}_{nativeRelink}_{Path.GetRandomFileName()}";
string projectFile = CreateProjectWithNativeReference(id);
AddItemsPropertiesToProject(projectFile, extraProperties: nativeRelink ? string.Empty : "true");
@@ -94,7 +94,7 @@ public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRel
var expectedFileType = nativeRelink ? NativeFilesType.Relinked : NativeFilesType.AOT;
- AssertDotNetNativeFiles(expectedFileType, config, forPublish: true);
+ AssertDotNetNativeFiles(expectedFileType, config, forPublish: true, targetFramework: DefaultTargetFrameworkForBlazor);
AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: false);
if (expectedFileType == NativeFilesType.AOT)
@@ -147,7 +147,7 @@ public void NativeBuild_WithDeployOnBuild_UsedByVS(string config, bool nativeRel
[ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
public void WithNativeReference_AOTInProjectFile(string config)
{
- string id = $"blz_nativeref_aot_{config}";
+ string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateProjectWithNativeReference(id);
AddItemsPropertiesToProject(projectFile, extraProperties: "true");
@@ -165,7 +165,7 @@ public void WithNativeReference_AOTInProjectFile(string config)
[ActiveIssue("https://github.com/dotnet/runtime/issues/70985", TestPlatforms.Linux)]
public void WithNativeReference_AOTOnCommandLine(string config)
{
- string id = $"blz_nativeref_aot_{config}";
+ string id = $"blz_nativeref_aot_{config}_{Path.GetRandomFileName()}";
CreateProjectWithNativeReference(id);
BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.Relinked));
@@ -182,7 +182,7 @@ public void WithNativeReference_AOTOnCommandLine(string config)
public void WithDllImportInMainAssembly(string config)
{
// Based on https://github.com/dotnet/runtime/issues/59255
- string id = $"blz_dllimp_{config}";
+ string id = $"blz_dllimp_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateProjectWithNativeReference(id);
string nativeSource = @"
#include
@@ -233,7 +233,7 @@ void CheckNativeFileLinked(bool forPublish)
[Fact]
public void BugRegression_60479_WithRazorClassLib()
{
- string id = "blz_razor_lib_top";
+ string id = $"blz_razor_lib_top_{Path.GetRandomFileName()}";
InitBlazorWasmProjectDir(id);
string wasmProjectDir = Path.Combine(_projectDir!, "wasm");
@@ -241,6 +241,7 @@ public void BugRegression_60479_WithRazorClassLib()
Directory.CreateDirectory(wasmProjectDir);
new DotNetCommand(s_buildEnv, _testOutput, useDefaultArgs: false)
.WithWorkingDirectory(wasmProjectDir)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("new blazorwasm")
.EnsureSuccessful();
@@ -249,6 +250,7 @@ public void BugRegression_60479_WithRazorClassLib()
Directory.CreateDirectory(razorProjectDir);
new DotNetCommand(s_buildEnv, _testOutput, useDefaultArgs: false)
.WithWorkingDirectory(razorProjectDir)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("new razorclasslib")
.EnsureSuccessful();
diff --git a/src/mono/wasm/Wasm.Build.Tests/BlazorWasmTests.cs b/src/mono/wasm/Wasm.Build.Tests/BlazorWasmTests.cs
index cfb725bd59f22a..91cf6c23156fe0 100644
--- a/src/mono/wasm/Wasm.Build.Tests/BlazorWasmTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/BlazorWasmTests.cs
@@ -61,6 +61,7 @@ private CommandResult PublishForRequiresWorkloadTest(string config, string extra
string publishLogPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}.binlog");
return new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("publish",
$"-bl:{publishLogPath}",
$"-p:Configuration={config}");
@@ -109,6 +110,7 @@ private void BuildNet50Project(string config, bool aot, bool expectError, string
string publishLogPath = Path.Combine(logPath, $"{id}.binlog");
CommandResult result = new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("publish",
$"-bl:{publishLogPath}",
(aot ? "-p:RunAOTCompilation=true" : ""),
diff --git a/src/mono/wasm/Wasm.Build.Tests/BuildEnvironment.cs b/src/mono/wasm/Wasm.Build.Tests/BuildEnvironment.cs
index f921b870375730..de8c14b30495b7 100644
--- a/src/mono/wasm/Wasm.Build.Tests/BuildEnvironment.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/BuildEnvironment.cs
@@ -27,7 +27,7 @@ public class BuildEnvironment
public static readonly string RelativeTestAssetsPath = @"..\testassets\";
public static readonly string TestAssetsPath = Path.Combine(AppContext.BaseDirectory, "testassets");
public static readonly string TestDataPath = Path.Combine(AppContext.BaseDirectory, "data");
- public static readonly string TmpPath = Path.Combine(Path.GetTempPath(), "wasmbuildtests");
+ public static readonly string TmpPath = Path.Combine(AppContext.BaseDirectory, "wbt");
private static readonly Dictionary s_runtimePackVersions = new();
@@ -107,7 +107,6 @@ public BuildEnvironment()
EnvVars["DOTNET_INSTALL_DIR"] = sdkForWorkloadPath;
EnvVars["DOTNET_MULTILEVEL_LOOKUP"] = "0";
EnvVars["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "1";
- EnvVars["MSBuildSDKsPath"] = string.Empty;
EnvVars["PATH"] = $"{sdkForWorkloadPath}{Path.PathSeparator}{Environment.GetEnvironmentVariable("PATH")}";
EnvVars["EM_WORKAROUND_PYTHON_BUG_34780"] = "1";
@@ -160,8 +159,5 @@ public string GetRuntimeNativeDir(string tfm = BuildTestBase.DefaultTargetFramew
protected static string s_directoryBuildPropsForLocal = File.ReadAllText(Path.Combine(TestDataPath, "Local.Directory.Build.props"));
protected static string s_directoryBuildTargetsForLocal = File.ReadAllText(Path.Combine(TestDataPath, "Local.Directory.Build.targets"));
-
- protected static string s_directoryBuildPropsForBlazorLocal = File.ReadAllText(Path.Combine(TestDataPath, "Blazor.Local.Directory.Build.props"));
- protected static string s_directoryBuildTargetsForBlazorLocal = File.ReadAllText(Path.Combine(TestDataPath, "Blazor.Local.Directory.Build.targets"));
}
}
diff --git a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
index f4a73bdbb0fe5b..7847c95cfc374f 100644
--- a/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/BuildTestBase.cs
@@ -28,7 +28,7 @@ namespace Wasm.Build.Tests
public abstract class BuildTestBase : IClassFixture, IDisposable
{
public const string DefaultTargetFramework = "net7.0";
- public static readonly string NuGetConfigFileNameForDefaultFramework = $"nuget7.config";
+ public const string DefaultTargetFrameworkForBlazor = "net7.0";
protected static readonly bool s_skipProjectCleanup;
protected static readonly string s_xharnessRunnerCommand;
protected string? _projectDir;
@@ -36,6 +36,7 @@ public abstract class BuildTestBase : IClassFixture s_buildEnv.IsWorkload;
public static bool IsNotUsingWorkloads => !s_buildEnv.IsWorkload;
+ public static string GetNuGetConfigPathFor(string targetFramework) =>
+ Path.Combine(BuildEnvironment.TestDataPath, "nuget8.config"); // for now - we are still using net7, but with
+ // targetFramework == "net7.0" ? "nuget7.config" : "nuget8.config");
static BuildTestBase()
{
@@ -63,13 +67,6 @@ static BuildTestBase()
else
s_xharnessRunnerCommand = EnvironmentVariables.XHarnessCliPath;
- string? nugetPackagesPath = Environment.GetEnvironmentVariable("NUGET_PACKAGES");
- if (!string.IsNullOrEmpty(nugetPackagesPath))
- {
- if (!Directory.Exists(nugetPackagesPath))
- Directory.CreateDirectory(nugetPackagesPath);
- }
-
Console.WriteLine ("");
Console.WriteLine ($"==============================================================================================");
Console.WriteLine ($"=============== Running with {(s_buildEnv.IsWorkload ? "Workloads" : "No workloads")} ===============");
@@ -284,13 +281,18 @@ protected static string RunWithXHarness(string testCommand, string testLogPath,
protected void InitPaths(string id)
{
if (_projectDir == null)
- _projectDir = Path.Combine(AppContext.BaseDirectory, id);
+ _projectDir = Path.Combine(BuildEnvironment.TmpPath, id);
_logPath = Path.Combine(s_buildEnv.LogRootPath, id);
+ _nugetPackagesDir = Path.Combine(BuildEnvironment.TmpPath, "nuget", id);
+ if (Directory.Exists(_nugetPackagesDir))
+ Directory.Delete(_nugetPackagesDir, recursive: true);
+
+ Directory.CreateDirectory(_nugetPackagesDir!);
Directory.CreateDirectory(_logPath);
}
- protected static void InitProjectDir(string dir, bool addNuGetSourceForLocalPackages = false)
+ protected void InitProjectDir(string dir, bool addNuGetSourceForLocalPackages = false, string targetFramework = DefaultTargetFramework)
{
Directory.CreateDirectory(dir);
File.WriteAllText(Path.Combine(dir, "Directory.Build.props"), s_buildEnv.DirectoryBuildPropsContents);
@@ -301,15 +303,13 @@ protected static void InitProjectDir(string dir, bool addNuGetSourceForLocalPack
{
File.WriteAllText(targetNuGetConfigPath,
GetNuGetConfigWithLocalPackagesPath(
- Path.Combine(BuildEnvironment.TestDataPath, NuGetConfigFileNameForDefaultFramework),
+ GetNuGetConfigPathFor(targetFramework),
s_buildEnv.BuiltNuGetsPath));
}
else
{
- File.Copy(Path.Combine(BuildEnvironment.TestDataPath, NuGetConfigFileNameForDefaultFramework),
- targetNuGetConfigPath);
+ File.Copy(GetNuGetConfigPathFor(targetFramework), targetNuGetConfigPath);
}
- Directory.CreateDirectory(Path.Combine(dir, ".nuget"));
}
protected const string SimpleProjectTemplate =
@@ -405,6 +405,7 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp
foreach (var kvp in options.ExtraBuildEnvironmentVariables!)
envVars[kvp.Key] = kvp.Value;
}
+ envVars["NUGET_PACKAGES"] = _nugetPackagesDir;
result = AssertBuild(sb.ToString(), id, expectSuccess: options.ExpectSuccess, envVars: envVars);
// check that we are using the correct runtime pack!
@@ -414,7 +415,14 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp
AssertRuntimePackPath(result.buildOutput, options.TargetFramework ?? DefaultTargetFramework);
string bundleDir = Path.Combine(GetBinDir(config: buildArgs.Config, targetFramework: options.TargetFramework ?? DefaultTargetFramework), "AppBundle");
- AssertBasicAppBundle(bundleDir, buildArgs.ProjectName, buildArgs.Config, options.MainJS ?? "test-main.js", options.HasV8Script, options.HasIcudt, options.DotnetWasmFromRuntimePack ?? !buildArgs.AOT, options.TargetFramework ?? DefaultTargetFramework);
+ AssertBasicAppBundle(bundleDir,
+ buildArgs.ProjectName,
+ buildArgs.Config,
+ options.MainJS ?? "test-main.js",
+ options.HasV8Script,
+ options.TargetFramework ?? DefaultTargetFramework,
+ options.HasIcudt,
+ options.DotnetWasmFromRuntimePack ?? !buildArgs.AOT);
}
if (options.UseCache)
@@ -430,17 +438,16 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp
}
}
- public void InitBlazorWasmProjectDir(string id)
+ public void InitBlazorWasmProjectDir(string id, string targetFramework = DefaultTargetFrameworkForBlazor)
{
InitPaths(id);
if (Directory.Exists(_projectDir))
Directory.Delete(_projectDir, recursive: true);
Directory.CreateDirectory(_projectDir);
- Directory.CreateDirectory(Path.Combine(_projectDir, ".nuget"));
File.WriteAllText(Path.Combine(_projectDir, "nuget.config"),
GetNuGetConfigWithLocalPackagesPath(
- Path.Combine(BuildEnvironment.TestDataPath, NuGetConfigFileNameForDefaultFramework),
+ GetNuGetConfigPathFor(targetFramework),
s_buildEnv.BuiltNuGetsPath));
File.Copy(Path.Combine(BuildEnvironment.TestDataPath, "Blazor.Directory.Build.props"), Path.Combine(_projectDir, "Directory.Build.props"));
@@ -459,7 +466,7 @@ private static string GetNuGetConfigWithLocalPackagesPath(string templatePath, s
public string CreateWasmTemplateProject(string id, string template = "wasmbrowser", string extraArgs = "")
{
InitPaths(id);
- InitProjectDir(id, addNuGetSourceForLocalPackages: true);
+ InitProjectDir(_projectDir, addNuGetSourceForLocalPackages: true);
File.WriteAllText(Path.Combine(_projectDir, "Directory.Build.props"), "");
File.WriteAllText(Path.Combine(_projectDir, "Directory.Build.targets"),
@@ -487,6 +494,7 @@ public string CreateBlazorWasmTemplateProject(string id)
InitBlazorWasmProjectDir(id);
new DotNetCommand(s_buildEnv, _testOutput, useDefaultArgs: false)
.WithWorkingDirectory(_projectDir!)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("new blazorwasm")
.EnsureSuccessful();
@@ -496,8 +504,12 @@ public string CreateBlazorWasmTemplateProject(string id)
protected (CommandResult, string) BlazorBuild(BlazorBuildOptions options, params string[] extraArgs)
{
var res = BuildInternal(options.Id, options.Config, publish: false, setWasmDevel: false, extraArgs);
+ _testOutput.WriteLine($"BlazorBuild, options.tfm: {options.TargetFramework}");
AssertDotNetNativeFiles(options.ExpectedFileType, options.Config, forPublish: false, targetFramework: options.TargetFramework);
- AssertBlazorBundle(options.Config, isPublish: false, dotnetWasmFromRuntimePack: options.ExpectedFileType == NativeFilesType.FromRuntimePack);
+ AssertBlazorBundle(options.Config,
+ isPublish: false,
+ dotnetWasmFromRuntimePack: options.ExpectedFileType == NativeFilesType.FromRuntimePack,
+ targetFramework: options.TargetFramework);
return res;
}
@@ -506,7 +518,10 @@ public string CreateBlazorWasmTemplateProject(string id)
{
var res = BuildInternal(options.Id, options.Config, publish: true, setWasmDevel: false, extraArgs);
AssertDotNetNativeFiles(options.ExpectedFileType, options.Config, forPublish: true, targetFramework: options.TargetFramework);
- AssertBlazorBundle(options.Config, isPublish: true, dotnetWasmFromRuntimePack: options.ExpectedFileType == NativeFilesType.FromRuntimePack);
+ AssertBlazorBundle(options.Config,
+ isPublish: true,
+ dotnetWasmFromRuntimePack: options.ExpectedFileType == NativeFilesType.FromRuntimePack,
+ targetFramework: options.TargetFramework);
if (options.ExpectedFileType == NativeFilesType.AOT)
{
@@ -538,17 +553,18 @@ public string CreateBlazorWasmTemplateProject(string id)
CommandResult res = new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput(combinedArgs)
.EnsureSuccessful();
return (res, logPath);
}
- protected void AssertDotNetNativeFiles(NativeFilesType type, string config, bool forPublish, string targetFramework = DefaultTargetFramework)
+ protected void AssertDotNetNativeFiles(NativeFilesType type, string config, bool forPublish, string targetFramework)
{
string label = forPublish ? "publish" : "build";
string objBuildDir = Path.Combine(_projectDir!, "obj", config, targetFramework, "wasm", forPublish ? "for-publish" : "for-build");
- string binFrameworkDir = FindBlazorBinFrameworkDir(config, forPublish);
+ string binFrameworkDir = FindBlazorBinFrameworkDir(config, forPublish, framework: targetFramework);
string srcDir = type switch
{
@@ -589,7 +605,14 @@ static void AssertRuntimePackPath(string buildOutput, string targetFramework)
throw new XunitException($"Runtime pack path doesn't match.{Environment.NewLine}Expected: '{expectedRuntimePackDir}'{Environment.NewLine}Actual: '{actualPath}'");
}
- protected static void AssertBasicAppBundle(string bundleDir, string projectName, string config, string mainJS, bool hasV8Script, bool hasIcudt=true, bool dotnetWasmFromRuntimePack=true, string targetFramework=DefaultTargetFramework)
+ protected static void AssertBasicAppBundle(string bundleDir,
+ string projectName,
+ string config,
+ string mainJS,
+ bool hasV8Script,
+ string targetFramework,
+ bool hasIcudt = true,
+ bool dotnetWasmFromRuntimePack = true)
{
AssertFilesExist(bundleDir, new []
{
@@ -637,7 +660,7 @@ protected static void AssertDotNetWasmJs(string bundleDir, bool fromRuntimePack,
same: fromRuntimePack);
}
- protected static void AssertDotNetJsSymbols(string bundleDir, bool fromRuntimePack, string targetFramework=DefaultTargetFramework)
+ protected static void AssertDotNetJsSymbols(string bundleDir, bool fromRuntimePack, string targetFramework)
=> AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.js.symbols"),
Path.Combine(bundleDir, "dotnet.js.symbols"),
same: fromRuntimePack);
@@ -689,11 +712,11 @@ protected static void AssertFile(string file0, string file1, string? label=null,
return result;
}
- protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasmFromRuntimePack, string? binFrameworkDir=null, string targetFramework=DefaultTargetFramework)
+ protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasmFromRuntimePack, string targetFramework = DefaultTargetFrameworkForBlazor, string? binFrameworkDir=null)
{
- binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish);
+ binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish, targetFramework);
- AssertBlazorBootJson(config, isPublish, binFrameworkDir: binFrameworkDir);
+ AssertBlazorBootJson(config, isPublish, targetFramework, binFrameworkDir: binFrameworkDir);
AssertFile(Path.Combine(s_buildEnv.GetRuntimeNativeDir(targetFramework), "dotnet.wasm"),
Path.Combine(binFrameworkDir, "dotnet.wasm"),
"Expected dotnet.wasm to be same as the runtime pack",
@@ -708,9 +731,9 @@ protected void AssertBlazorBundle(string config, bool isPublish, bool dotnetWasm
same: dotnetWasmFromRuntimePack);
}
- protected void AssertBlazorBootJson(string config, bool isPublish, string? binFrameworkDir=null)
+ protected void AssertBlazorBootJson(string config, bool isPublish, string targetFramework = DefaultTargetFrameworkForBlazor, string? binFrameworkDir=null)
{
- binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish);
+ binFrameworkDir ??= FindBlazorBinFrameworkDir(config, isPublish, targetFramework);
string bootJsonPath = Path.Combine(binFrameworkDir, "blazor.boot.json");
Assert.True(File.Exists(bootJsonPath), $"Expected to find {bootJsonPath}");
@@ -727,7 +750,7 @@ protected void AssertBlazorBootJson(string config, bool isPublish, string? binFr
$"{msgPrefix} Could not find dotnet.*js in {bootJson}");
}
- protected string FindBlazorBinFrameworkDir(string config, bool forPublish, string framework = DefaultTargetFramework)
+ protected string FindBlazorBinFrameworkDir(string config, bool forPublish, string framework = DefaultTargetFrameworkForBlazor)
{
string basePath = Path.Combine(_projectDir!, "bin", config, framework);
if (forPublish)
@@ -817,6 +840,9 @@ public static (int exitCode, string buildOutput) RunProcess(string path,
processStartInfo.EnvironmentVariables[envVar.Key] = envVar.Value;
_testOutput.WriteLine($"\t{envVar.Key} = {envVar.Value}");
}
+
+ // runtime repo sets this, which interferes with the tests
+ processStartInfo.RemoveEnvironmentVariables("MSBuildSDKsPath");
}
Process process = new ();
@@ -1004,6 +1030,6 @@ public record BlazorBuildOptions
string Id,
string Config,
NativeFilesType ExpectedFileType,
- string TargetFramework = BuildTestBase.DefaultTargetFramework
+ string TargetFramework = BuildTestBase.DefaultTargetFrameworkForBlazor
);
}
diff --git a/src/mono/wasm/Wasm.Build.Tests/CleanTests.cs b/src/mono/wasm/Wasm.Build.Tests/CleanTests.cs
index bbd0f0106e89bd..b113c8443631d5 100644
--- a/src/mono/wasm/Wasm.Build.Tests/CleanTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/CleanTests.cs
@@ -36,12 +36,13 @@ public void Blazor_BuildThenClean_NativeRelinking(string config)
AddItemsPropertiesToProject(projectFile, extraProperties: extraProperties);
BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.Relinked));
- string relinkDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFramework, "wasm", "for-build");
+ string relinkDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFrameworkForBlazor, "wasm", "for-build");
Assert.True(Directory.Exists(relinkDir), $"Could not find expected relink dir: {relinkDir}");
string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-clean.binlog");
new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("build", "-t:Clean", $"-p:Configuration={config}", $"-bl:{logPath}")
.EnsureSuccessful();
@@ -75,7 +76,7 @@ private void Blazor_BuildNativeNonNative_ThenCleanTest(string config, bool first
BuildInternal(id, config, publish: false,
extraArgs: relink ? "-p:WasmBuildNative=true" : string.Empty);
- string relinkDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFramework, "wasm", "for-build");
+ string relinkDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFrameworkForBlazor, "wasm", "for-build");
if (relink)
Assert.True(Directory.Exists(relinkDir), $"Could not find expected relink dir: {relinkDir}");
@@ -89,6 +90,7 @@ private void Blazor_BuildNativeNonNative_ThenCleanTest(string config, bool first
string logPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-clean.binlog");
new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _projectDir!)
.ExecuteWithCapturedOutput("build", "-t:Clean", $"-p:Configuration={config}", $"-bl:{logPath}")
.EnsureSuccessful();
diff --git a/src/mono/wasm/Wasm.Build.Tests/HelperExtensions.cs b/src/mono/wasm/Wasm.Build.Tests/HelperExtensions.cs
index c20aa25a5c43af..7f36db407e2dd0 100644
--- a/src/mono/wasm/Wasm.Build.Tests/HelperExtensions.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/HelperExtensions.cs
@@ -5,9 +5,8 @@
using System.Collections.Generic;
using System.Linq;
using System.IO;
+using System.Diagnostics;
using System.Text;
-using System.Collections;
-using Xunit.Abstractions;
#nullable enable
@@ -121,5 +120,18 @@ public static void UpdateTo(this IDictionary string.Compare(k, name, StringComparison.OrdinalIgnoreCase) == 0);
+ if (key is not null)
+ env.Remove("MSBuildSDKsPath");
+ }
+
+ return psi;
+ }
}
}
diff --git a/src/mono/wasm/Wasm.Build.Tests/NativeBuildTests.cs b/src/mono/wasm/Wasm.Build.Tests/NativeBuildTests.cs
index 17d140f9a562f7..3b9d62d69f1b28 100644
--- a/src/mono/wasm/Wasm.Build.Tests/NativeBuildTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/NativeBuildTests.cs
@@ -106,7 +106,7 @@ public void IntermediateBitcodeToObjectFilesAreNotLLVMIR(BuildArgs buildArgs, st
[InlineData("Release")]
public void BlazorWasm_CanRunMonoAOTCross_WithNoTrimming(string config)
{
- string id = $"blazorwasm_{config}_aot";
+ string id = $"blazorwasm_{config}_aot_{Path.GetRandomFileName()}";
CreateBlazorWasmTemplateProject(id);
// We don't want to emcc compile, and link ~180 assemblies!
@@ -123,6 +123,7 @@ public void BlazorWasm_CanRunMonoAOTCross_WithNoTrimming(string config)
string publishLogPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}.binlog");
CommandResult res = new DotNetCommand(s_buildEnv, _testOutput)
.WithWorkingDirectory(_projectDir!)
+ .WithEnvironmentVariable("NUGET_PACKAGES", _nugetPackagesDir)
.ExecuteWithCapturedOutput("publish",
$"-bl:{publishLogPath}",
"-p:RunAOTCompilation=true",
diff --git a/src/mono/wasm/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs b/src/mono/wasm/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs
index 1cc525391ad77b..e5f17d261811a8 100644
--- a/src/mono/wasm/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/NativeRebuildTests/NoopNativeRebuildTest.cs
@@ -40,11 +40,11 @@ public void NoOpRebuildForNativeBuilds(BuildArgs buildArgs, bool nativeRelink, b
[InlineData("Release")]
public void BlazorNoopRebuild(string config)
{
- string id = $"blz_rebuild_{config}";
+ string id = $"blz_rebuild_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateBlazorWasmTemplateProject(id);
AddItemsPropertiesToProject(projectFile, extraProperties: "true");
- string objDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFramework, "wasm");
+ string objDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFrameworkForBlazor, "wasm");
BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.Relinked));
File.Move(Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-build.binlog"),
@@ -67,11 +67,11 @@ public void BlazorNoopRebuild(string config)
[InlineData("Release")]
public void BlazorOnlyLinkRebuild(string config)
{
- string id = $"blz_relink_{config}";
+ string id = $"blz_relink_{config}_{Path.GetRandomFileName()}";
string projectFile = CreateBlazorWasmTemplateProject(id);
AddItemsPropertiesToProject(projectFile, extraProperties: "true");
- string objDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFramework, "wasm");
+ string objDir = Path.Combine(_projectDir!, "obj", config, DefaultTargetFrameworkForBlazor, "wasm");
BlazorBuild(new BlazorBuildOptions(id, config, NativeFilesType.Relinked), "-p:EmccLinkOptimizationFlag=-O2");
File.Move(Path.Combine(s_buildEnv.LogRootPath, id, $"{id}-build.binlog"),
diff --git a/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs b/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs
index 0d7d58b8c24d2e..4c42a30373f09b 100644
--- a/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using Xunit;
using Xunit.Abstractions;
@@ -461,9 +462,21 @@ public static void Main()
""";
+ string tasksDir = Path.Combine(s_buildEnv.WorkloadPacksDir,
+ "Microsoft.NET.Runtime.WebAssembly.Sdk",
+ s_buildEnv.GetRuntimePackVersion(DefaultTargetFramework),
+ "tasks");
+ if (!Directory.Exists(tasksDir))
+ throw new DirectoryNotFoundException($"Could not find tasks directory {tasksDir}");
+
+ string? taskPath = Directory.EnumerateFiles(tasksDir, "WasmAppBuilder.dll", SearchOption.AllDirectories)
+ .FirstOrDefault();
+ if (string.IsNullOrEmpty(taskPath))
+ throw new FileNotFoundException($"Could not find WasmAppBuilder.dll in {tasksDir}");
+
projectCode = projectCode
.Replace("###WasmPInvokeModule###", AddAssembly("System.Private.CoreLib") + AddAssembly("System.Runtime") + AddAssembly(libraryBuildArgs.ProjectName))
- .Replace("###WasmAppBuilder###", Path.Combine(s_buildEnv.WorkloadPacksDir, "Microsoft.NET.Runtime.WebAssembly.Sdk", s_buildEnv.GetRuntimePackVersion(), "tasks", DefaultTargetFramework, "WasmAppBuilder.dll"));
+ .Replace("###WasmAppBuilder###", taskPath);
buildArgs = buildArgs with { ProjectName = $"icall_enum_{buildArgs.Config}_{id}", ProjectFileContents = projectCode };
diff --git a/src/mono/wasm/Wasm.Build.Tests/RunCommand.cs b/src/mono/wasm/Wasm.Build.Tests/RunCommand.cs
index 33759316d1e34f..d7baa51e2c1139 100644
--- a/src/mono/wasm/Wasm.Build.Tests/RunCommand.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/RunCommand.cs
@@ -10,6 +10,7 @@ public class RunCommand : DotNetCommand
{
public RunCommand(BuildEnvironment buildEnv, ITestOutputHelper _testOutput, string label="") : base(buildEnv, _testOutput, false, label)
{
+ WithEnvironmentVariables(buildEnv.EnvVars);
WithEnvironmentVariable("DOTNET_ROOT", buildEnv.DotNet);
WithEnvironmentVariable("DOTNET_INSTALL_DIR", Path.GetDirectoryName(buildEnv.DotNet)!);
WithEnvironmentVariable("DOTNET_MULTILEVEL_LOOKUP", "0");
diff --git a/src/mono/wasm/Wasm.Build.Tests/ToolCommand.cs b/src/mono/wasm/Wasm.Build.Tests/ToolCommand.cs
index 8526f0d63b551c..2fae80aa4bdd37 100644
--- a/src/mono/wasm/Wasm.Build.Tests/ToolCommand.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/ToolCommand.cs
@@ -79,7 +79,7 @@ public async virtual Task ExecuteAsync(params string[] args)
{
var resolvedCommand = _command;
string fullArgs = GetFullArgs(args);
- _testOutput.WriteLine($"[{_label}] Executing - {resolvedCommand} {fullArgs} - {WorkingDirectoryInfo()}");
+ _testOutput.WriteLine($"[{_label}] Executing - {resolvedCommand} {fullArgs} {WorkingDirectoryInfo()}");
return await ExecuteAsyncInternal(resolvedCommand, fullArgs);
}
@@ -161,6 +161,8 @@ private Process CreateProcess(string executable, string args)
psi.Environment["DOTNET_MULTILEVEL_LOOKUP"] = "0";
psi.Environment["DOTNET_SKIP_FIRST_TIME_EXPERIENCE"] = "1";
+ // runtime repo sets this, which interferes with the tests
+ psi.RemoveEnvironmentVariables("MSBuildSDKsPath");
AddEnvironmentVariablesTo(psi);
AddWorkingDirectoryTo(psi);
var process = new Process
@@ -201,6 +203,7 @@ private void AddEnvironmentVariablesTo(ProcessStartInfo psi)
{
foreach (var item in Environment)
{
+ _testOutput.WriteLine($"\t[{item.Key}] = {item.Value}");
psi.Environment[item.Key] = item.Value;
}
}
diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs b/src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs
index 01ea2a6d9d168e..12efeb59b44d82 100644
--- a/src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs
+++ b/src/mono/wasm/Wasm.Build.Tests/WasmTemplateTests.cs
@@ -102,7 +102,7 @@ public void BrowserBuildThenPublish(string config)
TargetFramework: BuildTestBase.DefaultTargetFramework
));
- AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: true);
+ AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: true, targetFramework: DefaultTargetFramework);
if (!_buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product))
throw new XunitException($"Test bug: could not get the build product in the cache");
@@ -123,7 +123,7 @@ public void BrowserBuildThenPublish(string config)
TargetFramework: BuildTestBase.DefaultTargetFramework,
UseCache: false));
- AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !expectRelinking);
+ AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !expectRelinking, targetFramework: DefaultTargetFramework);
}
[Theory]
@@ -151,7 +151,7 @@ public void ConsoleBuildThenPublish(string config)
TargetFramework: BuildTestBase.DefaultTargetFramework
));
- AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: true);
+ AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: true, targetFramework: DefaultTargetFramework);
(int exitCode, string output) = RunProcess(s_buildEnv.DotNet, _testOutput, args: $"run --no-build -c {config}", workingDir: _projectDir);
Assert.Equal(0, exitCode);
@@ -176,7 +176,7 @@ public void ConsoleBuildThenPublish(string config)
TargetFramework: BuildTestBase.DefaultTargetFramework,
UseCache: false));
- AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !expectRelinking);
+ AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !expectRelinking, targetFramework: DefaultTargetFramework);
}
[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
@@ -218,7 +218,7 @@ private void ConsoleBuildAndRun(string config, bool relinking, string extraNewAr
TargetFramework: BuildTestBase.DefaultTargetFramework
));
- AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !relinking);
+ AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !relinking, targetFramework: DefaultTargetFramework);
(int exitCode, string output) = RunProcess(s_buildEnv.DotNet, _testOutput, args: $"run --no-build -c {config} x y z", workingDir: _projectDir);
Assert.Equal(42, exitCode);
@@ -407,7 +407,7 @@ public void ConsolePublishAndRun(string config, bool aot, bool relinking)
if (!aot)
{
// These are disabled for AOT explicitly
- AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !expectRelinking);
+ AssertDotNetJsSymbols(Path.Combine(GetBinDir(config), "AppBundle"), fromRuntimePack: !expectRelinking, targetFramework: DefaultTargetFramework);
}
else
{
diff --git a/src/mono/wasm/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.props b/src/mono/wasm/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.props
deleted file mode 100644
index 058246e4086204..00000000000000
--- a/src/mono/wasm/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.props
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/src/mono/wasm/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.targets b/src/mono/wasm/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.targets
deleted file mode 100644
index 6f9b3ab9ef9994..00000000000000
--- a/src/mono/wasm/Wasm.Build.Tests/data/Blazor.Local.Directory.Build.targets
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/src/mono/wasm/Wasm.Build.Tests/data/nuget7.config b/src/mono/wasm/Wasm.Build.Tests/data/nuget7.config
index 409ee96f0277b2..a5aa037070bbc9 100644
--- a/src/mono/wasm/Wasm.Build.Tests/data/nuget7.config
+++ b/src/mono/wasm/Wasm.Build.Tests/data/nuget7.config
@@ -3,11 +3,11 @@
-
+
diff --git a/src/mono/wasm/Wasm.Build.Tests/data/nuget8.config b/src/mono/wasm/Wasm.Build.Tests/data/nuget8.config
new file mode 100644
index 00000000000000..dfdc8009c6a5d5
--- /dev/null
+++ b/src/mono/wasm/Wasm.Build.Tests/data/nuget8.config
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs b/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs
index 94e255df990ed2..e0f420941785c7 100644
--- a/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs
+++ b/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs
@@ -41,14 +41,6 @@ public class InstallWorkloadFromArtifacts : Task
private const string s_nugetInsertionTag = "";
private string AllManifestsStampPath => Path.Combine(SdkWithNoWorkloadInstalledPath, ".all-manifests.stamp");
- private static readonly string[] s_manifestIds = new[]
- {
- "microsoft.net.workload.mono.toolchain",
- "microsoft.net.workload.emscripten.net6",
- "microsoft.net.workload.emscripten.net7",
- "microsoft.net.workload.mono.toolchain.net6",
- "microsoft.net.workload.mono.toolchain.net7"
- };
public override bool Execute()
{
@@ -154,8 +146,6 @@ private bool InstallAllManifests()
return true;
}
- ExecuteHackForInstallerMismatch();
-
string nugetConfigContents = GetNuGetConfig();
HashSet manifestsInstalled = new();
foreach (ITaskItem workload in WorkloadIds)
@@ -185,43 +175,6 @@ private bool InstallAllManifests()
File.WriteAllText(AllManifestsStampPath, string.Empty);
return true;
-
- void ExecuteHackForInstallerMismatch()
- {
- // HACK - because sdk doesn't yet have the version-less manifest names in the known
- // workloads list
- string? txtPath = Directory.EnumerateFiles(Path.Combine(SdkWithNoWorkloadInstalledPath, "sdk"), "IncludedWorkloadManifests.txt",
- new EnumerationOptions { RecurseSubdirectories = true, MaxRecursionDepth = 2})
- .FirstOrDefault();
- if (txtPath is null)
- throw new LogAsErrorException($"Could not find IncludedWorkloadManifests.txt in {SdkWithNoWorkloadInstalledPath}");
-
- string stampPath = Path.Combine(Path.GetDirectoryName(txtPath)!, ".stamp");
- if (File.Exists(stampPath))
- return;
-
- List lines = File.ReadAllLines(txtPath).ToList();
- int originalCount = lines.Count;
-
- // we want to insert the manifests in a fixed order
- // so first remove all of them
- foreach (string manifestId in s_manifestIds)
- lines.Remove(manifestId);
- // .. and then insert
- lines.AddRange(s_manifestIds);
-
- // currently using emscripten.net7 instead of this,
- // so remove it from the list
- lines.Remove("microsoft.net.workload.emscripten");
-
- if (lines.Count != originalCount)
- {
- // Update the file only if we are making any changes
- File.WriteAllText(txtPath, string.Join(Environment.NewLine, lines));
- }
-
- File.WriteAllText(stampPath, "");
- }
}
private bool InstallPacks(InstallWorkloadRequest req, string nugetConfigContents)