Skip to content

Commit 31d0956

Browse files
committed
Use BlazorWebAssemblySDK
* Update projects to use the BlazorSDK * Remove tasks and targets from RazorSDK * Remove workarounds from BlazorSDK
1 parent c924af3 commit 31d0956

File tree

33 files changed

+40
-1759
lines changed

33 files changed

+40
-1759
lines changed

eng/targets/CSharp.Common.props

Lines changed: 15 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,24 @@
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="$(RepoRoot)src\Components\WebAssembly\Sdk\src\Microsoft.NET.Sdk.BlazorWebAssembly.csproj"
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+
3346
<ItemGroup Condition=" '$(IsTestProject)' != 'true' AND '$(DotNetBuildFromSource)' != 'true' ">
3447
<Reference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" PrivateAssets="All" />
3548
</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: 6 additions & 0 deletions
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>
@@ -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/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>

src/Components/WebAssembly/testassets/StandaloneApp/StandaloneApp.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +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>
7-
<FixupWebAssemblyHttpHandlerReference>true</FixupWebAssemblyHttpHandlerReference>
85
</PropertyGroup>
96

107
<ItemGroup>

src/Components/WebAssembly/testassets/Wasm.Authentication.Client/Wasm.Authentication.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>

src/Components/benchmarkapps/Wasm.Performance/TestApp/Wasm.Performance.TestApp.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
<IsTestAssetProject>true</IsTestAssetProject>
86
</PropertyGroup>
97

src/Components/test/testassets/BasicTestApp/BasicTestApp.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-
<UseBlazorWebAssembly>true</UseBlazorWebAssembly>
6-
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
75

86
<!-- Must be defined before ReferenceFromSource.props is imported -->
97
<AdditionalRunArguments>--pathbase /subdir</AdditionalRunArguments>

src/ProjectTemplates/BlazorTemplates.Tests/BlazorWasmTemplateTest.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public async Task BlazorWasmStandaloneTemplate_Works()
4747
Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");
4848

4949
var project = await ProjectFactory.GetOrCreateProject("blazorstandalone", Output);
50-
project.RuntimeIdentifier = "browser-wasm";
5150

5251
var createResult = await project.RunDotNetNewAsync("blazorwasm");
5352
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
@@ -145,7 +144,6 @@ public async Task BlazorWasmStandalonePwaTemplate_Works()
145144
Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");
146145

147146
var project = await ProjectFactory.GetOrCreateProject("blazorstandalonepwa", Output);
148-
project.RuntimeIdentifier = "browser-wasm";
149147

150148
var createResult = await project.RunDotNetNewAsync("blazorwasm", args: new[] { "--pwa" });
151149
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
@@ -355,7 +353,6 @@ public async Task BlazorWasmStandaloneTemplate_IndividualAuth_Works()
355353
Environment.SetEnvironmentVariable("EnableDefaultScopedCssItems", "true");
356354

357355
var project = await ProjectFactory.GetOrCreateProject("blazorstandaloneindividual", Output);
358-
project.RuntimeIdentifier = "browser-wasm";
359356

360357
var createResult = await project.RunDotNetNewAsync("blazorwasm", args: new[] {
361358
"-au",

src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Client.csproj.in

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
<!--#if PWA -->
86
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
97
<!--#endif -->

src/ProjectTemplates/test/Infrastructure/TemplateTests.props.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@
3737
<RazorSdkDirectoryRoot>${ArtifactsBinDir}Microsoft.NET.Sdk.Razor\${Configuration}\sdk-output\</RazorSdkDirectoryRoot>
3838
</PropertyGroup>
3939
<Import Project="${RepoRoot}src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''" />
40+
<Import Project="${RepoRoot}src\Components\WebAssembly\Sdk\src\build\net5.0\Microsoft.NET.Sdk.BlazorWebAssembly.props" Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'" />
4041
</Project>

src/Razor/Microsoft.AspNetCore.Razor.Tools/src/rzc.csproj

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33
<PropertyGroup>
44
<Description>Razor is a markup syntax for adding server-side logic to web pages. This assembly contains infrastructure supporting Razor MSBuild integration.</Description>
5-
6-
<!--
7-
This is intentionally targeting netcoreapp3.0. This allows using the Microsoft.NET.Sdk.Razor package without having to solve diamond dependency problems in AspNetCore.
8-
We use a runtimeconfig.json.template to allow roll forwards.
9-
In addition, the SDK stamps an exact version of the shared fx to use in all runtimeconfig.json that are contained in the SDK.
10-
See the discussion here: https://github.com/dotnet/aspnetcore-internal/issues/3201#issuecomment-539631557
11-
-->
12-
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
136
<OutputType>Exe</OutputType>
147
<AssemblyName>rzc</AssemblyName>
158

src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/BuildIntegrationTest.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,7 @@ public async Task Build_ErrorInGeneratedCode_ReportsMSBuildError()
9696
Assert.BuildFailed(result);
9797

9898
// Verifying that the error correctly gets mapped to the original source
99-
var filePath = Path.Combine(Project.DirectoryPath, "Views", "Home", "Index.cshtml");
100-
var location = filePath + "(1,27)";
101-
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
102-
{
103-
// Absolute paths on OSX don't work well.
104-
location = null;
105-
}
106-
Assert.BuildError(result, "CS1503", location);
99+
Assert.BuildError(result, "CS1503", location: Path.Combine(Project.DirectoryPath, "Views", "Home", "Index.cshtml") + "(1,27)");
107100

108101
// Compilation failed without creating the views assembly
109102
Assert.FileExists(result, IntermediateOutputPath, "SimpleMvc.dll");

src/Razor/Microsoft.NET.Sdk.Razor/integrationtests/Microsoft.NET.Sdk.Razor.IntegrationTests.csproj

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@
3333
<Reference Include="Microsoft.NET.Sdk.Razor" ReferenceOutputAssembly="false" SkipGetTargetFrameworkProperties="true" />
3434
</ItemGroup>
3535

36-
<ItemGroup>
37-
<Compile Include="..\src\BootJsonData.cs" LinkBase="Wasm" />
38-
<Compile Include="..\src\AssetsManifestFile.cs" LinkBase="Wasm" />
39-
</ItemGroup>
40-
4136
<Target Name="GenerateTestData" BeforeTargets="GetAssemblyAttributes">
4237
<Exec Condition="'$(OS)' == 'Windows_NT'" Command="&quot;$(NuGetPackageRoot)vswhere\$(VSWhereVersion)\tools\vswhere.exe&quot; -latest -prerelease -property installationPath -requires Microsoft.Component.MSBuild" ConsoleToMsBuild="true" StandardErrorImportance="high">
4338
<Output TaskParameter="ConsoleOutput" PropertyName="_VSInstallDir" />

src/Razor/Microsoft.NET.Sdk.Razor/src/AssetsManifestFile.cs

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

src/Razor/Microsoft.NET.Sdk.Razor/src/BlazorReadSatelliteAssemblyFile.cs

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

src/Razor/Microsoft.NET.Sdk.Razor/src/BlazorWriteSatelliteAssemblyFile.cs

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

0 commit comments

Comments
 (0)