diff --git a/eng/testing/workloads-testing.targets b/eng/testing/workloads-testing.targets index 910ce227dd6887..5c4e021e7a8849 100644 --- a/eng/testing/workloads-testing.targets +++ b/eng/testing/workloads-testing.targets @@ -211,6 +211,7 @@ LocalNuGetsPath="$(LibrariesShippingPackagesDir)" TemplateNuGetConfigPath="$(RepoRoot)NuGet.config" SdkWithNoWorkloadInstalledPath="$(_SdkWithNoWorkloadPath)" + IntermediateOutputPath="$(ArtifactsObjDir)wasm" /> 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 13a8719e62240c..f5b49c75cc3025 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 @@ -23,7 +23,7 @@ Copyright (c) .NET Foundation. All rights reserved. <_RunWorkingDirectory>$(OutputPath) <_RunWorkingDirectory Condition="'$(_RunWorkingDirectory)' != '' and !$([System.IO.Path]::IsPathRooted($(_RunWorkingDirectory)))">$([System.IO.Path]::Combine($(MSBuildProjectDirectory), $(_RunWorkingDirectory))) <_RuntimeConfigJsonPath>$([MSBuild]::NormalizePath($(_RunWorkingDirectory), '$(AssemblyName).runtimeconfig.json')) - + exec "$([MSBuild]::NormalizePath($(WasmAppHostDir), 'WasmAppHost.dll'))" --use-staticwebassets --runtime-config "$(_RuntimeConfigJsonPath)" $(WasmHostArguments) $(_RunWorkingDirectory) @@ -395,7 +395,7 @@ Copyright (c) .NET Foundation. All rights reserved. BeforeTargets="PrepareForPublish" /> - + + + <_WasmResolvedFilesToPublish Include="@(ResolvedFileToPublish)" /> + diff --git a/src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs b/src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs index 9378c052e076ec..e7be07f71c89e1 100644 --- a/src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs @@ -155,11 +155,11 @@ public void DefaultTemplate_WithResources_Publish(string config) if (config == "Release") { // relinking in publish for Release config - BlazorPublish(new BlazorBuildOptions(id, config, NativeFilesType.Relinked, ExpectRelinkDirWhenPublishing: true)); + BlazorPublish(new BlazorBuildOptions(id, config, NativeFilesType.Relinked, ExpectRelinkDirWhenPublishing: true, IsPublish: true)); } else { - BlazorPublish(new BlazorBuildOptions(id, config, NativeFilesType.FromRuntimePack, ExpectRelinkDirWhenPublishing: true)); + BlazorPublish(new BlazorBuildOptions(id, config, NativeFilesType.FromRuntimePack, ExpectRelinkDirWhenPublishing: true, IsPublish: true)); } AssertResourcesDlls(FindBlazorBinFrameworkDir(config, true)); diff --git a/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs b/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs index b1b6a031be38e9..50dac9c67a1e7a 100644 --- a/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs +++ b/src/mono/wasm/Wasm.Build.Tests/ProjectProviderBase.cs @@ -33,7 +33,7 @@ public abstract class ProjectProviderBase(ITestOutputHelper _testOutput, string? }; public string? ProjectDir { get; set; } = _projectDir; - protected ITestOutputHelper _testOutput = _testOutput; + protected ITestOutputHelper _testOutput = new TestOutputWrapper(_testOutput); protected BuildEnvironment _buildEnv = BuildTestBase.s_buildEnv; public string BundleDirName { get; set; } = "wwwroot"; diff --git a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs index 9ff2155c68e600..0480473d249a68 100644 --- a/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs +++ b/src/mono/wasm/Wasm.Build.Tests/WasmSdkBasedProjectProvider.cs @@ -4,6 +4,7 @@ using System; using System.IO; using System.Collections.Generic; +using Xunit; using Xunit.Abstractions; using Xunit.Sdk; using System.Linq; @@ -76,6 +77,18 @@ public void AssertBundle(AssertWasmSdkBundleOptions assertOptions) { IReadOnlyDictionary actualDotnetFiles = AssertBasicBundle(assertOptions); + if (assertOptions.IsPublish) + { + string publishPath = Path.GetFullPath(Path.Combine(assertOptions.BinFrameworkDir, "..", "..")); + Assert.Equal("publish", Path.GetFileName(publishPath)); + + var dlls = Directory.EnumerateFiles(publishPath, "*.dll"); + Assert.False(dlls.Any(), $"Did not expect to find any .dll in {publishPath} but found {string.Join(",", dlls)}"); + + var wasmAssemblies = Directory.EnumerateFiles(publishPath, "*.wasm"); + Assert.False(wasmAssemblies.Any(), $"Did not expect to find any .wasm files in {publishPath} but found {string.Join(",", wasmAssemblies)}"); + } + if (!BuildTestBase.IsUsingWorkloads) return; diff --git a/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs b/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs index c43b416dc67c78..0ed03bd4db6dc6 100644 --- a/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs +++ b/src/tasks/WorkloadBuildTasks/InstallWorkloadFromArtifacts.cs @@ -42,6 +42,7 @@ public partial class InstallWorkloadFromArtifacts : Task [Required, NotNull] public string SdkWithNoWorkloadInstalledPath { get; set; } = string.Empty; + public string? IntermediateOutputPath { get; set; } public bool OnlyUpdateManifests{ get; set; } private const string s_nugetInsertionTag = ""; @@ -59,7 +60,7 @@ public partial class InstallWorkloadFromArtifacts : Task public override bool Execute() { - _tempDir = Path.Combine(Path.GetTempPath(), $"workload-{Path.GetRandomFileName()}"); + _tempDir = Path.Combine(IntermediateOutputPath ?? Path.GetTempPath(), $"workload-{Path.GetRandomFileName()}"); if (Directory.Exists(_tempDir)) Directory.Delete(_tempDir, recursive: true); Directory.CreateDirectory(_tempDir);