Skip to content

Commit 76d01f7

Browse files
committed
Use BlazorWebAssemblySDK
* Update projects to use the BlazorSDK * Remove tasks and targets from RazorSDK * Remove workarounds from BlazorSDK
1 parent 747957b commit 76d01f7

33 files changed

+38
-1746
lines changed

eng/targets/CSharp.Common.props

Lines changed: 16 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
@@ -26,11 +26,25 @@
2626
UndefineProperties="TargetFramework;TargetFrameworks" />
2727
</ItemGroup>
2828

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

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

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "5.0.100-preview.7.20330.3"
3+
"version": "5.0.100-rc.1.20377.3"
44
},
55
"tools": {
6-
"dotnet": "5.0.100-preview.7.20330.3",
6+
"dotnet": "5.0.100-rc.1.20377.3",
77
"runtimes": {
88
"dotnet/x64": [
99
"2.1.18",

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
@@ -44,7 +44,6 @@ public override Task InitializeAsync()
4444
public async Task BlazorWasmStandaloneTemplate_Works()
4545
{
4646
var project = await ProjectFactory.GetOrCreateProject("blazorstandalone", Output);
47-
project.RuntimeIdentifier = "browser-wasm";
4847

4948
var createResult = await project.RunDotNetNewAsync("blazorwasm");
5049
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
@@ -136,7 +135,6 @@ private static async Task AssertCompressionFormat(AspNetProcess aspNetProcess, s
136135
public async Task BlazorWasmStandalonePwaTemplate_Works()
137136
{
138137
var project = await ProjectFactory.GetOrCreateProject("blazorstandalonepwa", Output);
139-
project.RuntimeIdentifier = "browser-wasm";
140138

141139
var createResult = await project.RunDotNetNewAsync("blazorwasm", args: new[] { "--pwa" });
142140
Assert.True(0 == createResult.ExitCode, ErrorMessages.GetFailedProcessMessage("create/restore", project, createResult));
@@ -337,7 +335,6 @@ private async Task BlazorWasmHostedTemplate_IndividualAuth_Works(bool useLocalDb
337335
public async Task BlazorWasmStandaloneTemplate_IndividualAuth_Works()
338336
{
339337
var project = await ProjectFactory.GetOrCreateProject("blazorstandaloneindividual", Output);
340-
project.RuntimeIdentifier = "browser-wasm";
341338

342339
var createResult = await project.RunDotNetNewAsync("blazorwasm", args: new[] {
343340
"-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
@@ -38,4 +38,5 @@
3838
<RazorSdkDirectoryRoot>${ArtifactsBinDir}Microsoft.NET.Sdk.Razor\${Configuration}\sdk-output\</RazorSdkDirectoryRoot>
3939
</PropertyGroup>
4040
<Import Project="${RepoRoot}src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''" />
41+
<Import Project="${RepoRoot}src\Components\WebAssembly\Sdk\src\build\net5.0\Microsoft.NET.Sdk.BlazorWebAssembly.props" Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'" />
4142
</Project>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +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-
Assert.BuildError(result, "CS1503", location: Path.Combine("Views", "Home", "Index.cshtml") + "(1,27)");
99+
Assert.BuildError(result, "CS1503", location: Path.Combine(Project.DirectoryPath, "Views", "Home", "Index.cshtml") + "(1,27)");
100100

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

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ public async Task IntrospectJsonContentFiles()
216216
var result = await DotnetMSBuild("_IntrospectContentItems");
217217

218218
Assert.BuildPassed(result);
219-
var launchSettingsPath = Path.Combine("Properties", "launchSettings.json");
220-
Assert.BuildOutputContainsLine(result, $"Content: {launchSettingsPath} CopyToOutputDirectory=PreserveNewest CopyToPublishDirectory=Never ExcludeFromSingleFile=true");
221219
Assert.BuildOutputContainsLine(result, "Content: appsettings.json CopyToOutputDirectory=PreserveNewest CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true");
222220
Assert.BuildOutputContainsLine(result, "Content: appsettings.Development.json CopyToOutputDirectory=PreserveNewest CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true");
223221
}
@@ -230,8 +228,6 @@ public async Task IntrospectJsonContentFiles_WithExcludeConfigFilesFromBuildOutp
230228
var result = await DotnetMSBuild("_IntrospectContentItems", "/p:ExcludeConfigFilesFromBuildOutput=true");
231229

232230
Assert.BuildPassed(result);
233-
var launchSettingsPath = Path.Combine("Properties", "launchSettings.json");
234-
Assert.BuildOutputContainsLine(result, $"Content: {launchSettingsPath} CopyToOutputDirectory= CopyToPublishDirectory=Never ExcludeFromSingleFile=true");
235231
Assert.BuildOutputContainsLine(result, "Content: appsettings.json CopyToOutputDirectory= CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true");
236232
Assert.BuildOutputContainsLine(result, "Content: appsettings.Development.json CopyToOutputDirectory= CopyToPublishDirectory=PreserveNewest ExcludeFromSingleFile=true");
237233
}

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
@@ -37,11 +37,6 @@
3737
</ProjectReference>
3838
</ItemGroup>
3939

40-
<ItemGroup>
41-
<Compile Include="..\src\BootJsonData.cs" LinkBase="Wasm" />
42-
<Compile Include="..\src\AssetsManifestFile.cs" LinkBase="Wasm" />
43-
</ItemGroup>
44-
4540
<Target Name="GenerateTestData" BeforeTargets="GetAssemblyAttributes">
4641
<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">
4742
<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.

0 commit comments

Comments
 (0)