Skip to content

Commit d6c88a3

Browse files
authored
More cleaning up Blazor.Build package (#17157)
* More cleaning up Blazor.Build package * Clean up MonoRuntime targets * Convert executables in to tasks * Add tests
1 parent a42a40d commit d6c88a3

39 files changed

+2212
-798
lines changed

eng/Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
$(RepoRoot)src\Installers\**\*.*proj;
3535
$(RepoRoot)src\SignalR\clients\ts\**\node_modules\**\*.*proj;
3636
$(RepoRoot)src\Components\Web.JS\node_modules\**\*.*proj;
37+
$(RepoRoot)src\Components\Blazor\Build\testassets\**\*.*proj;
3738
$(RepoRoot)src\Components\Blazor\Templates\src\content\**\*.*proj;
3839
$(RepoRoot)src\ProjectTemplates\Web.ProjectTemplates\content\**\*.csproj;
3940
$(RepoRoot)src\ProjectTemplates\Web.ProjectTemplates\content\**\*.fsproj;

src/Components/Blazor/Build/src/Cli/Commands/ResolveRuntimeDependenciesCommand.cs

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

src/Components/Blazor/Build/src/Cli/Commands/WriteBootJsonCommand.cs

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

src/Components/Blazor/Build/src/Cli/Program.cs

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

src/Components/Blazor/Build/src/Core/BootJsonWriter.cs

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,71 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
4+
<TargetFrameworks>$(DefaultNetCoreTargetFramework);net46</TargetFrameworks>
5+
<TargetName>Microsoft.AspNetCore.Blazor.Build.Tasks</TargetName>
6+
<AssemblyName>Microsoft.AspNetCore.Blazor.Build</AssemblyName>
57
<Description>Build mechanism for ASP.NET Core Blazor applications.</Description>
6-
<OutputType>Exe</OutputType>
78
<IsShippingPackage>true</IsShippingPackage>
89
<HasReferenceAssembly>false</HasReferenceAssembly>
10+
<GenerateDependencyFile>false</GenerateDependencyFile>
911
</PropertyGroup>
1012

1113
<!-- Pack settings -->
1214
<PropertyGroup>
1315
<!-- Producing this package requires building with NodeJS enabled. -->
1416
<IsPackable Condition="'$(BuildNodeJS)' == 'false'">false</IsPackable>
15-
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);Publish</GenerateNuspecDependsOn>
1617
<NoPackageAnalysis>true</NoPackageAnalysis>
1718
<NuspecFile>Microsoft.AspNetCore.Blazor.Build.nuspec</NuspecFile>
1819
</PropertyGroup>
1920

2021
<ItemGroup>
2122
<NuspecProperty Include="configuration=$(Configuration)" />
22-
<NuspecProperty Include="publishDir=$(PublishDir)" />
23+
<NuspecProperty Include="taskskDir=$(OutputPath)tools" />
2324
<NuspecProperty Include="componentsversion=$(ComponentsPackageVersion)" />
2425
<NuspecProperty Include="razorversion=$(MicrosoftAspNetCoreRazorDesignPackageVersion)" />
2526
<NuspecProperty Include="blazormonoversion=$(MicrosoftAspNetCoreBlazorMonoPackageVersion)" />
2627
</ItemGroup>
2728

2829
<ItemGroup>
29-
<ProjectReference Condition="'$(BuildNodeJS)' != 'false' and '$(BuildingInsideVisualStudio)' != 'true'" Include="$(RepoRoot)src\Components\Web.JS\Microsoft.AspNetCore.Components.Web.JS.npmproj" ReferenceOutputAssembly="false" />
30-
<Reference Include="Microsoft.Extensions.CommandLineUtils.Sources" />
31-
<Reference Include="System.Reflection.Metadata" />
32-
</ItemGroup>
30+
<!-- Add a project dependency without reference output assemblies to enforce build order -->
31+
<!-- Applying workaround for https://github.com/microsoft/msbuild/issues/2661 and https://github.com/dotnet/sdk/issues/952 -->
32+
<ProjectReference
33+
Include="$(RepoRoot)src\Components\Web.JS\Microsoft.AspNetCore.Components.Web.JS.npmproj"
34+
ReferenceOutputAssemblies="false"
35+
SkipGetTargetFrameworkProperties="true"
36+
UndefineProperties="TargetFramework"
37+
Private="false"
38+
Condition="'$(BuildNodeJS)' != 'false' and '$(BuildingInsideVisualStudio)' != 'true'" />
3339

34-
<ItemGroup>
35-
<Compile Include="..\..\..\Shared\src\JsonSerializerOptionsProvider.cs" />
40+
<Reference Include="Microsoft.Build.Framework" ExcludeAssets="Runtime" />
41+
<Reference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="Runtime" />
42+
<Reference Include="System.Reflection.Metadata" Condition="'$(TargetFramework)' == 'net46'" />
3643
</ItemGroup>
44+
45+
<Target Name="CopyBuildTask" BeforeTargets="Build" Condition="'$(DotNetBuildFromSource)' != 'true' AND '$(IsInnerBuild)' != 'true'">
46+
<!--
47+
The task produced by this project is referenced within this solution. When building, Visual Studio will lock up the assembly.
48+
Any attempts to overwrite the binary with a newer version will fail. This is particularly grating if a developer "Rebuilds" the project
49+
after an initial build since that would always attempt to overwrite the tasks dll
50+
51+
This target attempts to make this solution more usable at the cost of a more onerous inner-loop build of the Blazor.Build tasks.
52+
We'll copy the tasks to a location other that than the build output and use that in the Blazor.Build.targets. In the most common
53+
case where these tasks aren't being worked on, everything should work great. However, if you're attemping to modify these tasks,
54+
you will need to manaully stop MSBuild.exe processes
55+
-->
56+
57+
<ItemGroup>
58+
<_NetCoreFilesToCopy Include="$(OutputPath)$(DefaultNetCoreTargetFramework)\*" TargetPath="netcoreapp\" />
59+
<_DesktopFilesToCopy Include="$(OutputPath)net46\*" TargetPath="netfx\" />
60+
<_AllFilesToCopy Include="@(_NetCoreFilesToCopy);@(_DesktopFilesToCopy)" />
61+
</ItemGroup>
62+
63+
<Error Text="No files found in $(OutputPath)$(DefaultNetCoreTargetFramework)" Condition="@(_NetCoreFilesToCopy->Count()) == 0" />
64+
<Error Text="No files found in $(OutputPath)net46" Condition="@(_DesktopFilesToCopy->Count()) == 0" />
65+
66+
<Copy SourceFiles="@(_AllFilesToCopy)" DestinationFiles="@(_AllFilesToCopy->'$(OutputPath)tools\%(TargetPath)%(FileName)%(Extension)')" SkipUnchangedFiles="true" Retries="1" ContinueOnError="true">
67+
<Output TaskParameter="CopiedFiles" ItemName="FileWrites" />
68+
</Copy>
69+
</Target>
70+
3771
</Project>

src/Components/Blazor/Build/src/Microsoft.AspNetCore.Blazor.Build.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<file src="..\..\..\THIRD-PARTY-NOTICES.txt" />
1212
<file src="build\**" target="build" />
1313
<file src="targets\**" target="targets" />
14-
<file src="$publishdir$**\*" target="tools/" />
15-
<file src="..\..\..\Web.JS\dist\$configuration$\blazor.*.js" target="tools/blazor" />
14+
<file src="$taskskDir$\*" target="tools/" />
15+
<file src="..\..\..\Web.JS\dist\$configuration$\blazor.webassembly.js" target="tools/blazor" />
1616
</files>
1717
</package>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project>
2+
<!--
3+
Importing this file is equivalent to having:
4+
<PackageDependency Include="Microsoft.AspNetCore.Blazor.Build" />
5+
... except it's much more convenient when working in this repo, because it consumes the
6+
Blazor.Build targets/exe directly without needing this project to be packed into a .nupkg.
7+
8+
This is only intended for use by other projects in this repo.
9+
-->
10+
11+
<PropertyGroup>
12+
<ComponentsRoot Condition="'$(ComponentsRoot)'==''">$(MSBuildThisFileDirectory)..\..\..\</ComponentsRoot>
13+
<BlazorJsPath>$(ComponentsRoot)Web.JS\dist\$(Configuration)\blazor.webassembly.js</BlazorJsPath>
14+
<BlazorJsMapPath>$(ComponentsRoot)Web.JS\dist\$(Configuration)\blazor.webassembly.js.map</BlazorJsMapPath>
15+
<BlazorToolsDir>$(MSBuildThisFileDirectory)bin\$(Configuration)\tools\</BlazorToolsDir>
16+
</PropertyGroup>
17+
18+
<Target Name="CheckBlazorJSFiles" BeforeTargets="Build">
19+
<Error Text="blazor.webassembly.js file could not be found at $(BlazorJsPath)" Condition="!Exists($(BlazorJsPath))" />
20+
</Target>
21+
22+
<Import Project="$(MSBuildThisFileDirectory)targets/All.props" />
23+
<Import Project="$(MSBuildThisFileDirectory)targets/All.targets" />
24+
25+
</Project>

src/Components/Blazor/Build/src/ReferenceFromSource.props

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
<Project>
22

3-
<!--
4-
Importing this file is equivalent to having:
5-
<PackageDependency Include="Microsoft.AspNetCore.Blazor.Build" />
6-
... except it's much more convenient when working in this repo, because it consumes the
7-
Blazor.Build targets/exe directly without needing this project to be packed into a .nupkg.
8-
9-
This is only intended for use by other projects in this repo.
10-
-->
11-
12-
<PropertyGroup>
13-
<BlazorBuildReferenceFromSource>true</BlazorBuildReferenceFromSource>
14-
<BlazorJsPath>$(RepoRoot)src\Components\Web.JS\dist\$(Configuration)\blazor.*.js.*</BlazorJsPath>
15-
</PropertyGroup>
16-
17-
<Import Project="$(MSBuildThisFileDirectory)targets/All.props" />
18-
<Import Project="$(MSBuildThisFileDirectory)targets/All.targets" />
3+
<Import Project="ReferenceBlazorBuildFromSource.props" />
194

205
<!--
216
Debugging support using blazor-devserver serve.

0 commit comments

Comments
 (0)