Skip to content

Commit 8e5533f

Browse files
authored
Use BlazorWebAssemblySDK (#24371)
* Use BlazorWebAssemblySDK * Update projects to use the BlazorSDK * Remove tasks and targets from RazorSDK * Remove workarounds from BlazorSDK * Fixup * Fixup
1 parent 7efec87 commit 8e5533f

File tree

38 files changed

+46
-1761
lines changed

38 files changed

+46
-1761
lines changed

eng/targets/CSharp.Common.props

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageReference Include="MicroBuild.Core" Version="0.3.0" PrivateAssets="All" AllowExplicitReference="true" ExcludeAssets="All" />
1313
</ItemGroup>
1414

15-
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
15+
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
1616
<!--
1717
Use the Razor SDK as a project reference. The version of the .NET Core SDK we build with often contains a version of the Razor SDK
1818
several versions older than latest. We reference the project to ensure it's built before the other projects that use it. Since this
@@ -25,11 +25,28 @@
2525
UndefineProperties="TargetFramework;TargetFrameworks" />
2626
</ItemGroup>
2727

28-
<ImportGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
28+
<ImportGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
2929
<Import Project="$(RepoRoot)eng\targets\GetRazorSDKDirectory.props" />
3030
<Import Project="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" />
3131
</ImportGroup>
3232

33+
<ItemGroup Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">
34+
<!-- See comments further up in the file when we import the Razor SDK-->
35+
<Reference Include="Microsoft.NET.Sdk.BlazorWebAssembly"
36+
PrivateAssets="All"
37+
ReferenceOutputAssembly="false"
38+
SkipGetTargetFrameworkProperties="true"
39+
UndefineProperties="TargetFramework;TargetFrameworks" />
40+
</ItemGroup>
41+
42+
<ImportGroup Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">
43+
<Import Project="$(RepoRoot)src\Components\WebAssembly\Sdk\src\build\net5.0\Microsoft.NET.Sdk.BlazorWebAssembly.props" />
44+
</ImportGroup>
45+
46+
<PropertyGroup Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">
47+
<BlazorWebAssemblySdkDirectoryRoot>$(ArtifactsBinDir)\Microsoft.NET.Sdk.BlazorWebAssembly\$(Configuration)\sdk-output\</BlazorWebAssemblySdkDirectoryRoot>
48+
</PropertyGroup>
49+
3350
<ItemGroup Condition=" '$(IsTestProject)' != 'true' AND '$(DotNetBuildFromSource)' != 'true' ">
3451
<Reference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" PrivateAssets="All" />
3552
</ItemGroup>

src/Components/Directory.Build.targets

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
2-
<PropertyGroup Condition="'$(UseBlazorWebAssembly)' == 'true'">
2+
<PropertyGroup Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'">
33
<BlazorWebAssemblyJSPath>$(RepoRoot)src\Components\Web.JS\dist\$(Configuration)\blazor.webassembly.js</BlazorWebAssemblyJSPath>
44
<BlazorWebAssemblyJSMapPath>$(BlazorWebAssemblyJSPath).map</BlazorWebAssemblyJSMapPath>
55

@@ -12,7 +12,7 @@
1212
<!-- Add a project dependency without reference output assemblies to enforce build order -->
1313
<!-- Applying workaround for https://github.com/microsoft/msbuild/issues/2661 and https://github.com/dotnet/sdk/issues/952 -->
1414
<ProjectReference
15-
Condition="'$(UseBlazorWebAssembly)' == 'true' and '$(BuildNodeJS)' != 'false' and '$(BuildingInsideVisualStudio)' != 'true'"
15+
Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' and '$(BuildNodeJS)' != 'false' and '$(BuildingInsideVisualStudio)' != 'true'"
1616
Include="$(RepoRoot)src\Components\Web.JS\Microsoft.AspNetCore.Components.Web.JS.npmproj"
1717
ReferenceOutputAssemblies="false"
1818
SkipGetTargetFrameworkProperties="true"

src/Components/WebAssembly/Sdk/integrationtests/WasmPublishIntegrationTest.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ public async Task Publish_SatelliteAssemblies_AreCopiedToBuildOutput()
321321
project.AddProjectFileContent(
322322
@"
323323
<PropertyGroup>
324+
<!-- Workaround for https://github.com/mono/linker/issues/1390 -->
325+
<PublishTrimmed>false</PublishTrimmed>
324326
<DefineConstants>$(DefineConstants);REFERENCE_classlibrarywithsatelliteassemblies</DefineConstants>
325327
</PropertyGroup>
326328
<ItemGroup>
@@ -450,6 +452,8 @@ public async Task Publish_HostedApp_WithSatelliteAssemblies()
450452
wasmProject.AddProjectFileContent(
451453
@"
452454
<PropertyGroup>
455+
<!-- Workaround for https://github.com/mono/linker/issues/1390 -->
456+
<PublishTrimmed>false</PublishTrimmed>
453457
<DefineConstants>$(DefineConstants);REFERENCE_classlibrarywithsatelliteassemblies</DefineConstants>
454458
</PropertyGroup>
455459
<ItemGroup>
@@ -637,7 +641,7 @@ public async Task Publish_HostedAppWithScopedCss_VisualStudio()
637641
// Arrange
638642
using var project = ProjectDirectory.Create("blazorhosted", additionalProjects: new[] { "blazorwasm", "razorclasslibrary", });
639643
File.WriteAllText(Path.Combine(project.SolutionPath, "blazorwasm", "App.razor.css"), "h1 { font-size: 16px; }");
640-
644+
641645
project.Configuration = "Release";
642646
var result = await MSBuildProcessManager.DotnetMSBuild(project, "Build", "/p:BuildInsideVisualStudio=true");
643647

@@ -701,6 +705,8 @@ public async Task Publish_HostedApp_VisualStudio_WithSatelliteAssemblies()
701705
var existing = File.ReadAllText(blazorwasmProjFile);
702706
var updatedContent = @"
703707
<PropertyGroup>
708+
<!-- Workaround for https://github.com/mono/linker/issues/1390 -->
709+
<PublishTrimmed>false</PublishTrimmed>
704710
<DefineConstants>$(DefineConstants);REFERENCE_classlibrarywithsatelliteassemblies</DefineConstants>
705711
</PropertyGroup>
706712
<ItemGroup>

src/Components/WebAssembly/Sdk/src/build/net5.0/Microsoft.NET.Sdk.BlazorWebAssembly.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ Copyright (c) .NET Foundation. All rights reserved.
1212
<Project ToolsVersion="14.0">
1313
<PropertyGroup>
1414
<_BlazorWebAssemblyPropsFile>$(MSBuildThisFileDirectory)..\..\targets\Microsoft.NET.Sdk.BlazorWebAssembly.Current.props</_BlazorWebAssemblyPropsFile>
15+
<_BlazorWebAssemblyTargetsFile>$(MSBuildThisFileDirectory)..\..\targets\Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets</_BlazorWebAssemblyTargetsFile>
1516
</PropertyGroup>
1617
</Project>

src/Components/WebAssembly/Sdk/src/build/net5.0/Microsoft.NET.Sdk.BlazorWebAssembly.targets

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.props

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ Copyright (c) .NET Foundation. All rights reserved.
2424
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
2525
</PropertyGroup>
2626

27-
<PropertyGroup>
28-
<!-- Determines if this Sdk is responsible for importing Microsoft.NET.Sdk.Razor. Temporary workaround until we can create a SDK. -->
29-
<_RazorSdkImportsMicrosoftNetSdkRazor Condition="'$(UsingMicrosoftNETSdkRazor)' != 'true'">true</_RazorSdkImportsMicrosoftNetSdkRazor>
30-
</PropertyGroup>
31-
32-
<Import Sdk="Microsoft.NET.Sdk.Razor" Project="Sdk.props" Condition="'$(_RazorSdkImportsMicrosoftNetSdkRazor)' == 'true'" />
27+
<Import Sdk="Microsoft.NET.Sdk.Razor" Project="Sdk.props" />
3328
<Import Sdk="Microsoft.NET.Sdk.Web.ProjectSystem" Project="Sdk.props" />
3429
<Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.props" />
3530

src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Copyright (c) .NET Foundation. All rights reserved.
1515
<EnableDefaultContentItems Condition=" '$(EnableDefaultContentItems)' == '' ">true</EnableDefaultContentItems>
1616
</PropertyGroup>
1717

18-
<Import Sdk="Microsoft.NET.Sdk.Razor" Project="Sdk.targets" Condition="'$(_RazorSdkImportsMicrosoftNetSdkRazor)' == 'true'" />
18+
<Import Sdk="Microsoft.NET.Sdk.Razor" Project="Sdk.targets" />
1919
<Import Sdk="Microsoft.NET.Sdk.Web.ProjectSystem" Project="Sdk.targets" />
2020
<Import Sdk="Microsoft.NET.Sdk.Publish" Project="Sdk.targets" />
2121

src/Components/WebAssembly/Sdk/testassets/blazorwasm-minimal/blazorwasm-minimal.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Razor">
2-
3-
<Import Project="$(RepoRoot)src\Components\WebAssembly\Sdk\src\Sdk\Sdk.props" />
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
42

53
<PropertyGroup>
64
<TargetFramework>net5.0</TargetFramework>
@@ -26,6 +24,4 @@
2624
<Reference Include="$(BinariesRoot)\Microsoft.AspNetCore.Razor.Test.ComponentShim.dll"/>
2725
</ItemGroup>
2826

29-
<Import Project="$(RepoRoot)src\Components\WebAssembly\Sdk\src\Sdk\Sdk.targets" />
30-
3127
</Project>

src/Components/WebAssembly/Sdk/testassets/blazorwasm/blazorwasm.csproj

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Razor">
2-
3-
<Import Project="$(RepoRoot)src\Components\WebAssembly\Sdk\src\Sdk\Sdk.props" />
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
42

53
<PropertyGroup>
64
<TargetFramework>net5.0</TargetFramework>
@@ -52,6 +50,4 @@
5250
<ServiceWorker Include="wwwroot\serviceworkers\my-service-worker.js" PublishedContent="wwwroot\serviceworkers\my-prod-service-worker.js" />
5351
</ItemGroup>
5452

55-
<Import Project="$(RepoRoot)src\Components\WebAssembly\Sdk\src\Sdk\Sdk.targets" />
56-
5753
</Project>

src/Components/WebAssembly/testassets/HostedInAspNet.Client/HostedInAspNet.Client.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
22

33
<PropertyGroup>
44
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5-
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
6-
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
75
</PropertyGroup>
86

97
<ItemGroup>

0 commit comments

Comments
 (0)