Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
d3ad227
rebased
radical Aug 27, 2021
cfb584d
Fix helix work item name
radical Aug 25, 2021
80fe082
fix test
radical Aug 25, 2021
b4d7659
get all the assemblies from the publishdir
radical Aug 25, 2021
c39313b
AOTCompiler: Expand the paths used with MONO_PATH
radical Aug 26, 2021
f9948e5
Implement support for skipping assemblies for AOT
radical Aug 26, 2021
7a82a3f
Update blazorwasm targets file with a locally patched copy
radical Aug 26, 2021
cd9ec8e
Cleanup
radical Aug 26, 2021
8944a98
fix path for copying blazorwasm targets file
radical Aug 27, 2021
56c5dc3
Fix tests on emsdk
radical Aug 27, 2021
5c707f0
Don't fixup runtime pack paths when not using workloads
radical Aug 27, 2021
2dbc899
[wasm] Fix building blazor projects with no workload installed
radical Sep 7, 2021
0cfd401
Update wasm README.md
radical Sep 7, 2021
8165407
Add missing files
radical Sep 7, 2021
b499586
WasmApp.targets: remove hack for blazor, which is not needed now
radical Sep 7, 2021
0ec1188
add comments for the new properties
radical Sep 8, 2021
567144c
blazor-sdk: cleanup assemblies list before adding to it
radical Sep 8, 2021
c906da8
Fix "Clean" for blazorwasm projects, for *Build*
radical Sep 8, 2021
1ecf92d
[wasm] Rename tmp folder 'relink' to 'for-build'
radical Sep 9, 2021
40d6713
[wasm] Fix support for AOT with trimming disabled
radical Sep 10, 2021
73efb99
WasmAppBuilder - cleanup
radical Sep 10, 2021
5457420
Bump sdk for workload testing to 6.0.100-rc.2.21459.15
radical Sep 10, 2021
a93db63
disable non-wasm builds
radical Sep 10, 2021
b5744b4
run blazor tests only with the workloads installed
radical Sep 9, 2021
5a5d8ed
Update BlazorOverride.targets to 6.0
radical Sep 9, 2021
40aef7d
[wasm] Fix Publish with VS
radical Sep 10, 2021
fda6f18
Revert "disable non-wasm builds"
radical Sep 10, 2021
8e2ba88
Fix up blazorOverride.targets
radical Sep 10, 2021
d011f44
Fix local aot builds for samples
radical Sep 10, 2021
6a37e25
Fix aot with no trimming for blazor projects
radical Sep 10, 2021
6fc4bbc
Wasm.Build.Test: find differently cased publish dir
radical Sep 10, 2021
5d53a50
Rename WasmBuildingForPublish->WasmBuildingForNestedPublish to be cle…
radical Sep 10, 2021
d2037c7
Update BlazorOverwrite.targets
radical Sep 10, 2021
ad96269
sample/iOS: Add new required IntermediateOutputPath parameter for Mon…
radical Sep 10, 2021
1e67f3e
disable non-wasm builds
radical Sep 10, 2021
7cfc9cf
Fix more wasm.build.tests to work around blazor's Publish dir issue
radical Sep 11, 2021
c1ab08f
Surface @(FileWrites) from nested publish to the main build
radical Sep 11, 2021
a8f1eae
[wasm] Don't relink after build, when `$(DeployOnBuild)=true`
radical Sep 11, 2021
c6cbe0b
Revert "disable non-wasm builds"
radical Sep 11, 2021
c1a77cf
Merge remote-tracking branch 'origin/release/6.0' into build-publish-6.0
radical Sep 13, 2021
48085f2
Update BlazorOverwrite.targets to work with rc2
radical Sep 14, 2021
3bba097
[wasm] Disable a blazorwasm publish test
radical Sep 14, 2021
617415f
Bump sdk for workload testing to 6.0.100-rc.2.21463.12
radical Sep 14, 2021
eb4ef84
Merge remote-tracking branch 'origin/release/6.0' into build-publish-6.0
radical Sep 14, 2021
ee62901
Revert "Update BlazorOverwrite.targets to work with rc2"
radical Sep 14, 2021
3da2650
disable non-wasm builds
radical Sep 10, 2021
4f52961
Address review feedback from @jonathanpeppers
radical Sep 14, 2021
981ba33
Revert "disable non-wasm builds"
radical Sep 15, 2021
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
Prev Previous commit
Next Next commit
[wasm] Fix building blazor projects with no workload installed
- And add extra checks for verifying that
  • Loading branch information
radical committed Sep 9, 2021
commit 2dbc8990f72d8d51d30cd27f142e6e77c26f8560
2 changes: 1 addition & 1 deletion eng/testing/scenarios/BuildWasmAppsJobsList.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Wasm.Build.NativeRebuild.Tests.BlazorWasmRebuildTest
Wasm.Build.NativeRebuild.Tests.BlazorWasmRebuildTests
Wasm.Build.NativeRebuild.Tests.FlagsChangeRebuildTest
Wasm.Build.NativeRebuild.Tests.NoopNativeRebuildTest
Wasm.Build.NativeRebuild.Tests.ReferenceNewAssemblyRebuildTest
Expand Down
8 changes: 6 additions & 2 deletions src/mono/wasm/BlazorOverwrite.targets
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<DisableAutoWasmPublishApp>true</DisableAutoWasmPublishApp>
<EnableDefaultWasmAssembliesToBundle>false</EnableDefaultWasmAssembliesToBundle>
<WasmNestedPublishAppDependsOn>ComputeFilesToPublish;_GatherWasmFilesToPublish;$(WasmNestedPublishAppDependsOn)</WasmNestedPublishAppDependsOn>
<_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' != 'true'">ResolveRuntimePackAssets</_ScrambleDotnetJsFileNameAfterThisTarget>
<_ScrambleDotnetJsFileNameAfterThisTarget Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'">WasmBuildApp</_ScrambleDotnetJsFileNameAfterThisTarget>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -157,7 +159,7 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>
</Target>

<Target Name="_ScrambleDotnetJsFileName" AfterTargets="WasmBuildApp">
<Target Name="_ScrambleDotnetJsFileName" AfterTargets="$(_ScrambleDotnetJsFileNameAfterThisTarget)">
<!--
We want the dotnet.js file output to have a version to better work with caching. We'll append the runtime version to the file name as soon as file has been discovered.
-->
Expand Down Expand Up @@ -211,13 +213,15 @@ Copyright (c) .NET Foundation. All rights reserved.
</ItemGroup>
</Target>

<Target Name="_BlazorWasmNativeForBuild" DependsOnTargets="_GatherWasmFilesToBuild;WasmBuildApp" Condition="'$(UsingBrowserRuntimeWorkload)' == 'true'" />

<Target Name="_GatherWasmFilesToBuild">
<ItemGroup>
<WasmAssembliesToBundle Include="@(ReferenceCopyLocalPaths);@(MainAssembly)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'" />
</ItemGroup>
</Target>

<Target Name="_ResolveBlazorWasmOutputs" DependsOnTargets="ResolveReferences;PrepareResourceNames;ComputeIntermediateSatelliteAssemblies;_GatherWasmFilesToBuild;WasmBuildApp" BeforeTargets="_RazorPrepareForRun">
<Target Name="_ResolveBlazorWasmOutputs" DependsOnTargets="ResolveReferences;PrepareResourceNames;ComputeIntermediateSatelliteAssemblies;_BlazorWasmNativeForBuild" BeforeTargets="_RazorPrepareForRun">
<!--
Calculates the outputs and the paths for Blazor WASM. This target is invoked frequently and should perform minimal work.
-->
Expand Down
13 changes: 7 additions & 6 deletions src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,13 @@
<_BeforeWasmBuildAppDependsOn />

<IsWasmProject Condition="'$(IsWasmProject)' == '' and '$(OutputType)' != 'Library'">true</IsWasmProject>
<DisableAutoWasmBuildApp Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">true</DisableAutoWasmBuildApp>
<_WasmBuildAppAfterThisTarget Condition="'$(DisableAutoWasmBuildApp)' != 'true'">Build</_WasmBuildAppAfterThisTarget>
<!-- FIXME: tmp hack for blazor -->
<DisableAutoWasmBuildApp Condition="'$(DisableAutoWasmBuildApp)' == '' and '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">true</DisableAutoWasmBuildApp>
<WasmBuildAppAfterThisTarget Condition="'$(WasmBuildAppAfterThisTarget)' == '' and '$(DisableAutoWasmBuildApp)' != 'true'">Build</WasmBuildAppAfterThisTarget>

<!-- FIXME: tmp hack for blazor -->
<DisableAutoWasmPublishApp Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">true</DisableAutoWasmPublishApp>
<_WasmTriggerPublishAppAfterThisTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true' and '$(WasmBuildingForPublish)' != 'true'">Publish</_WasmTriggerPublishAppAfterThisTarget>
<DisableAutoWasmPublishApp Condition="'$(DisableAutoWasmPublishApp)' == '' and '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">true</DisableAutoWasmPublishApp>
<WasmTriggerPublishAppAfterThisTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true' and '$(WasmBuildingForPublish)' != 'true'">Publish</WasmTriggerPublishAppAfterThisTarget>
<_WasmNestedPublishAppPreTarget Condition="'$(DisableAutoWasmPublishApp)' != 'true'">Publish</_WasmNestedPublishAppPreTarget>

<EnableDefaultWasmAssembliesToBundle Condition="'$(EnableDefaultWasmAssembliesToBundle)' == ''">true</EnableDefaultWasmAssembliesToBundle>
Expand All @@ -97,7 +98,7 @@
<!-- PUBLISH -->

<Target Name="WasmTriggerPublishApp"
AfterTargets="$(_WasmTriggerPublishAppAfterThisTarget)"
AfterTargets="$(WasmTriggerPublishAppAfterThisTarget)"
Condition="'$(IsWasmProject)' == 'true' and '$(WasmBuildingForPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'">

<!-- Use a unique property, so the already run wasm targets can also run -->
Expand Down Expand Up @@ -147,7 +148,7 @@

<!-- public target for Build -->
<Target Name="WasmBuildApp"
AfterTargets="$(_WasmBuildAppAfterThisTarget)"
AfterTargets="$(WasmBuildAppAfterThisTarget)"
DependsOnTargets="$(WasmBuildAppDependsOn)"
Condition="'$(IsWasmProject)' == 'true' and '$(WasmBuildingForPublish)' == '' and '$(WasmBuildOnlyAfterPublish)' != 'true' and '$(IsCrossTargetingBuild)' != 'true'" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System;
using System.IO;
using System.Linq;
using System.Xml;
using Xunit;
using Xunit.Abstractions;

Expand All @@ -20,13 +19,32 @@ public BlazorWasmBuildPublishTests(ITestOutputHelper output, SharedBuildPerTestC
_enablePerTestCleanup = true;
}

[ConditionalTheory(typeof(BuildTestBase), nameof(IsNotUsingWorkloads))]
[InlineData("Debug")]
[InlineData("Release")]
public void DefaultTemplate_WithoutWorkload(string config)
{
string id = $"blz_no_workload_{config}";
CreateBlazorWasmTemplateProject(id);

// Build
BuildInternal(id, config, publish: false);
string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", "wwwroot", "_framework");
AssertBlazorBootJson(config, isPublish: false, binFrameworkDir);

// Publish
BuildInternal(id, config, publish: true);
binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net6.0", "publish", "wwwroot", "_framework");
AssertBlazorBootJson(config, isPublish: true, binFrameworkDir);
}

[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
[InlineData("Debug")]
[InlineData("Release")]
public void DefaultTemplate(string config)
public void DefaultTemplate_NoAOT_WithWorkload(string config)
{
string id = $"blz_no_aot_{config}";
CreateTemplateProject(id);
CreateBlazorWasmTemplateProject(id);

BlazorBuild(id, config, NativeFilesType.FromRuntimePack);
if (config == "Release")
Expand All @@ -46,7 +64,7 @@ public void DefaultTemplate(string config)
public void DefaultTemplate_AOT_InProjectFile(string config)
{
string id = $"blz_aot_prj_file_{config}";
string projectFile = CreateTemplateProject(id);
string projectFile = CreateBlazorWasmTemplateProject(id);
AddItemsPropertiesToProject(projectFile, extraProperties: "<RunAOTCompilation>true</RunAOTCompilation>");

// No relinking, no AOT
Expand All @@ -65,7 +83,7 @@ public void DefaultTemplate_AOT_InProjectFile(string config)
public void DefaultTemplate_AOT_OnlyWithPublishCommandLine_Then_PublishNoAOT(string config)
{
string id = $"blz_aot_pub_{config}";
CreateTemplateProject(id);
CreateBlazorWasmTemplateProject(id);

// No relinking, no AOT
BlazorBuild(id, config, NativeFilesType.FromRuntimePack);
Expand Down Expand Up @@ -101,7 +119,7 @@ public void WithNativeReference_AOTInProjectFile(string config)
public void WithNativeReference_AOTOnCommandLine(string config)
{
string id = $"blz_nativeref_aot_{config}";
string projectFile = CreateProjectWithNativeReference(id);
CreateProjectWithNativeReference(id);

BlazorBuild(id, config, expectedFileType: NativeFilesType.Relinked);

Expand All @@ -115,6 +133,7 @@ public void WithNativeReference_AOTOnCommandLine(string config)
{
var res = BuildInternal(id, config, publish: false, extraArgs);
AssertDotNetNativeFiles(expectedFileType, config, forPublish: false);
AssertBlazorBundle(config, isPublish: false, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack);

return res;
}
Expand All @@ -123,6 +142,7 @@ public void WithNativeReference_AOTOnCommandLine(string config)
{
var res = BuildInternal(id, config, publish: true, extraArgs);
AssertDotNetNativeFiles(expectedFileType, config, forPublish: true);
AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: expectedFileType == NativeFilesType.FromRuntimePack);
return res;
}

Expand Down Expand Up @@ -184,7 +204,7 @@ private void AssertDotNetNativeFiles(NativeFilesType type, string config, bool f

private string CreateProjectWithNativeReference(string id)
{
CreateTemplateProject(id);
CreateBlazorWasmTemplateProject(id);

string extraItems = @$"
<PackageReference Include=""SkiaSharp"" Version=""2.80.3"" />
Expand All @@ -199,16 +219,6 @@ private string CreateProjectWithNativeReference(string id)
return projectFile;
}

private string CreateTemplateProject(string id)
{
InitBlazorWasmProjectDir(id);
new DotNetCommand(s_buildEnv, useDefaultArgs: false)
.WithWorkingDirectory(_projectDir!)
.ExecuteWithCapturedOutput("new blazorwasm")
.EnsureSuccessful();

return Path.Combine(_projectDir!, $"{id}.csproj");
}
}

internal enum NativeFilesType { FromRuntimePack, Relinked, AOT };
Expand Down
50 changes: 10 additions & 40 deletions src/tests/BuildWasmApps/Wasm.Build.Tests/BlazorWasmTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections.Generic;
using System.IO;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -17,43 +16,14 @@ public BlazorWasmTests(ITestOutputHelper output, SharedBuildPerTestClassFixture
{
}

// TODO: invariant case?

[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]
[InlineData("Debug", false)]
[InlineData("Debug", true)] // just aot
[InlineData("Release", false)] // should re-link
[InlineData("Release", true)]
public void PublishTemplateProject(string config, bool aot)
{
string id = $"blazorwasm_{config}_aot_{aot}_{Path.GetRandomFileName()}";
InitBlazorWasmProjectDir(id);

new DotNetCommand(s_buildEnv, useDefaultArgs: false)
.WithWorkingDirectory(_projectDir!)
.ExecuteWithCapturedOutput("new blazorwasm")
.EnsureSuccessful();

string publishLogPath = Path.Combine(s_buildEnv.LogRootPath, id, $"{id}.binlog");
new DotNetCommand(s_buildEnv)
.WithWorkingDirectory(_projectDir!)
.ExecuteWithCapturedOutput("publish", $"-bl:{publishLogPath}", aot ? "-p:RunAOTCompilation=true" : "", $"-p:Configuration={config}")
.EnsureSuccessful();

//TODO: validate the build somehow?
// compare dotnet.wasm?
// relinking - dotnet.wasm should be smaller
//
// playwright?
}

[ConditionalTheory(typeof(BuildTestBase), nameof(IsNotUsingWorkloads))]
[InlineData("Debug")]
[InlineData("Release")]
public void NativeRef_EmitsWarningBecauseItRequiresWorkload(string config)
{
CommandResult res = PublishForRequiresWorkloadTest(config, extraItems: "<NativeFileReference Include=\"native-lib.o\" />");
res.EnsureSuccessful();
AssertBlazorBundle(config, isPublish: true, dotnetWasmFromRuntimePack: true);

Assert.Contains("but the native references won't be linked in", res.Output);
}
Expand All @@ -71,7 +41,7 @@ public void AOT_FailsBecauseItRequiresWorkload(string config)
[ConditionalTheory(typeof(BuildTestBase), nameof(IsNotUsingWorkloads))]
[InlineData("Debug")]
[InlineData("Release")]
public void AOT_And_NativeRef_FailsBecauseItRequireWorkload(string config)
public void AOT_And_NativeRef_FailBecauseTheyRequireWorkload(string config)
{
CommandResult res = PublishForRequiresWorkloadTest(config,
extraProperties: "<RunAOTCompilation>true</RunAOTCompilation>",
Expand All @@ -84,18 +54,13 @@ public void AOT_And_NativeRef_FailsBecauseItRequireWorkload(string config)
private CommandResult PublishForRequiresWorkloadTest(string config, string extraItems="", string extraProperties="")
{
string id = $"needs_workload_{config}_{Path.GetRandomFileName()}";
InitBlazorWasmProjectDir(id);

new DotNetCommand(s_buildEnv, useDefaultArgs: false)
.WithWorkingDirectory(_projectDir!)
.ExecuteWithCapturedOutput("new blazorwasm")
.EnsureSuccessful();
CreateBlazorWasmTemplateProject(id);

if (IsNotUsingWorkloads)
{
// no packs installed, so no need to update the paths for runtime pack etc
File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.props"), "<Project />");
File.WriteAllText(Path.Combine(_projectDir!, "Directory.Build.targets"), "<Project />");
File.Copy(Path.Combine(BuildEnvironment.TestDataPath, "Blazor.Local.Directory.Build.props"), Path.Combine(_projectDir!, "Directory.Build.props"), overwrite: true);
File.Copy(Path.Combine(BuildEnvironment.TestDataPath, "Blazor.Local.Directory.Build.targets"), Path.Combine(_projectDir!, "Directory.Build.targets"), overwrite: true);
}

AddItemsPropertiesToProject(Path.Combine(_projectDir!, $"{id}.csproj"),
Expand Down Expand Up @@ -167,6 +132,11 @@ private void BuildNet50Project(string config, bool aot, bool expectError, string
{
result.EnsureSuccessful();
Assert.Contains("** UsingBrowserRuntimeWorkload: 'false'", result.Output);

string binFrameworkDir = Path.Combine(_projectDir!, "bin", config, "net5.0", "publish", "wwwroot", "_framework");
AssertBlazorBootJson(config, isPublish: true, binFrameworkDir: binFrameworkDir);
// dotnet.wasm here would be from 5.0 nuget like:
// /Users/radical/.nuget/packages/microsoft.netcore.app.runtime.browser-wasm/5.0.9/runtimes/browser-wasm/native/dotnet.wasm
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/tests/BuildWasmApps/Wasm.Build.Tests/BuildEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,8 @@ public BuildEnvironment()

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"));
}
}
Loading