Skip to content

Commit ef6fd02

Browse files
committed
Prototype for framework JS assets package
1 parent f6dedca commit ef6fd02

File tree

10 files changed

+149
-45
lines changed

10 files changed

+149
-45
lines changed

eng/scripts/npm/update-dependency-versions.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function applyPackageVersion(packagesToPack, defaultPackageVersion) {
5252
renames.push([`${packagePath}.bak`, packagePath]);
5353

5454
process.chdir(packageDir);
55-
execSync(`npm version ${packageVersion} --no-git-tag-version`, { stdio: 'inherit' });
55+
execSync(`npm version ${packageVersion} --no-git-tag-version --allow-same-version`, { stdio: 'inherit' });
5656
process.chdir(currentDir);
5757
console.log(`Applied version ${packageVersion} to ${packageName} in ${packageDir}...`);
5858
}

eng/tools/GenerateFiles/Directory.Build.targets.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@
3939
TargetFramework="${DefaultNetCoreTargetFramework}"
4040
Condition="'@(KnownWebAssemblySdkPack->Count())' != '0' AND
4141
!(@(KnownWebAssemblySdkPack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
42+
<KnownAspNetCorePack
43+
Include="@(KnownAspNetCorePack->WithMetadataValue('TargetFramework', 'net9.0'))"
44+
TargetFramework="${DefaultNetCoreTargetFramework}"
45+
Condition="'@(KnownAspNetCorePack->Count())' != '0' AND
46+
!(@(KnownAspNetCorePack->AnyHaveMetadataValue('TargetFramework', '${DefaultNetCoreTargetFramework}')))" />
47+
<!-- Temporary hack until the package is made available via the SDK -->
48+
<KnownAspNetCorePack
49+
Include="Microsoft.AspNetCore.Assets.Pack"
50+
TargetFramework="${DefaultNetCoreTargetFramework}"
51+
Condition="'${DefaultNetCoreTargetFramework}' == 'net10.0' AND '@(KnownAspNetCorePack->Count())' == '0'" />
4252
</ItemGroup>
4353

4454
<ItemGroup>
@@ -95,6 +105,11 @@
95105
Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</WebAssemblySdkPackVersion>
96106
</KnownWebAssemblySdkPack>
97107

108+
<KnownAspNetCorePack Update="Microsoft.AspNetCore.Assets.Pack">
109+
<AspNetCorePackVersion
110+
Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</AspNetCorePackVersion>
111+
</KnownAspNetCorePack>
112+
98113
<KnownCrossgen2Pack Update="Microsoft.NETCore.App.Crossgen2" Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">
99114
<Crossgen2PackVersion
100115
Condition=" '%(TargetFramework)' == '${DefaultNetCoreTargetFramework}' ">${MicrosoftNETCoreAppRuntimeVersion}</Crossgen2PackVersion>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web" DefaultTargets="Pack">
2+
3+
<PropertyGroup>
4+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5+
<Description>ASP.NET Core static framework assets</Description>
6+
<PackageId>Microsoft.AspNetCore.Assets.Pack</PackageId>
7+
<IsPackable>true</IsPackable>
8+
<OutputType>Library</OutputType>
9+
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
10+
<IncludeBuildOutput>false</IncludeBuildOutput>
11+
<IncludeSymbols>false</IncludeSymbols>
12+
13+
<!-- The package doesn't produce any lib or ref assemblies -->
14+
<NoWarn>$(NoWarn);NU5128</NoWarn>
15+
16+
<StaticWebAssetBasePath>_framework</StaticWebAssetBasePath>
17+
<DisableStaticWebAssetsBuildPropsFileGeneration>true</DisableStaticWebAssetsBuildPropsFileGeneration>
18+
<DisableStaticWebAssetEndpointsBuildPropsFileGeneration>true</DisableStaticWebAssetEndpointsBuildPropsFileGeneration>
19+
<StaticWebAssetsDisableProjectBuildPropsFileGeneration>true</StaticWebAssetsDisableProjectBuildPropsFileGeneration>
20+
<StaticWebAssetsDisableProjectBuildMultiTargetingPropsFileGeneration>true</StaticWebAssetsDisableProjectBuildMultiTargetingPropsFileGeneration>
21+
<StaticWebAssetsDisableProjectBuildTransitivePropsFileGeneration>true</StaticWebAssetsDisableProjectBuildTransitivePropsFileGeneration>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<None Include="build\*" Pack="true" PackagePath="%(Identity)" />
26+
</ItemGroup>
27+
28+
<PropertyGroup>
29+
<_BlazorJSContentRoot Condition="'$(Configuration)' == 'Debug'">..\..\Components\Web.JS\dist\Debug</_BlazorJSContentRoot>
30+
<_BlazorJSContentRoot Condition="'$(Configuration)' == 'Release'">..\..\Components\Web.JS\dist\Release</_BlazorJSContentRoot>
31+
</PropertyGroup>
32+
33+
<ItemGroup>
34+
<_BlazorJSFilename Include="blazor.web.js" />
35+
<_BlazorJSFilename Include="blazor.server.js" />
36+
<_BlazorJSFilename Include="blazor.webassembly.js" />
37+
38+
<_BlazorJSFile Include="@(_BlazorJSFilename->'$(_BlazorJSContentRoot)\%(Identity)')" />
39+
</ItemGroup>
40+
41+
<Target Name="_CheckBlazorJSPath" AfterTargets="ResolveProjectReferences">
42+
43+
<ItemGroup>
44+
<_MissingBlazorJSFile Include="@(_BlazorJSFile)" Condition="!EXISTS('%(_BlazorJSFile.FullPath)')" />
45+
</ItemGroup>
46+
47+
<Warning
48+
Condition="'@(_MissingBlazorJSFile)' != ''"
49+
Text="'%(_MissingBlazorJSFile.Identity)' does not exist. Falling back to checked-in copy." />
50+
51+
<ItemGroup>
52+
<_BlazorJSFile Remove="@(_MissingBlazorJSFile)" />
53+
<_BlazorJSFile Include="@(_MissingBlazorJSFile->'..\..\Components\Web.JS\dist\Release\%(Filename)%(Extension)')" />
54+
</ItemGroup>
55+
56+
</Target>
57+
58+
<Target Name="_GenerateFrameworkPackItems" BeforeTargets="GenerateStaticWebAssetsPackFiles">
59+
<ItemGroup>
60+
<_AssetCandidates Include="@(_BlazorJSFile)" />
61+
<_AssetCandidates>
62+
<RelativePath>%(RecursiveDir)%(FileName)%(Extension)</RelativePath>
63+
</_AssetCandidates>
64+
</ItemGroup>
65+
66+
<DefineStaticWebAssets
67+
Condition="'@(_AssetCandidates->Count())' != '0'"
68+
CandidateAssets="@(_AssetCandidates)"
69+
ContentRoot="_framework"
70+
SourceId="$(PackageId)"
71+
SourceType="Discovered"
72+
FingerprintCandidates="true"
73+
BasePath="$(StaticWebAssetBasePath)"
74+
>
75+
<Output TaskParameter="Assets" ItemName="_FrameworkAssets" />
76+
</DefineStaticWebAssets>
77+
78+
<DefineStaticWebAssetEndpoints
79+
Condition="'@(_FrameworkAssets)' != ''"
80+
CandidateAssets="@(_FrameworkAssets)"
81+
ExistingEndpoints="@()"
82+
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)">
83+
<Output TaskParameter="Endpoints" ItemName="_FrameworkAssetEndpoints" />
84+
</DefineStaticWebAssetEndpoints>
85+
86+
<ComputeEndpointsForReferenceStaticWebAssets
87+
Assets="@(_FrameworkAssets)"
88+
CandidateEndpoints="@(_FrameworkAssetEndpoints)">
89+
<Output TaskParameter="Endpoints" ItemName="_PackFrameworkAssetEndpoints" />
90+
</ComputeEndpointsForReferenceStaticWebAssets>
91+
92+
<GenerateStaticWebAssetsPropsFile
93+
StaticWebAssets="@(_FrameworkAssets)"
94+
PackagePathPrefix="staticwebassets"
95+
TargetPropsFilePath="$(IntermediateOutputPath)StaticWebAssets.targets" />
96+
97+
<GenerateStaticWebAssetEndpointsPropsFile
98+
StaticWebAssets="@(_FrameworkAssets)"
99+
StaticWebAssetEndpoints="@(_PackFrameworkAssetEndpoints)"
100+
TargetPropsFilePath="$(IntermediateOutputPath)StaticWebAssets.endpoints.targets" />
101+
102+
<ItemGroup>
103+
<StaticWebAssetPackageFile Include="$(IntermediateOutputPath)StaticWebAssets.targets">
104+
<PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.targets</PackagePath>
105+
</StaticWebAssetPackageFile>
106+
<StaticWebAssetPackageFile Include="$(IntermediateOutputPath)StaticWebAssets.endpoints.targets">
107+
<PackagePath>build\Microsoft.AspNetCore.StaticWebAssets.endpoints.targets</PackagePath>
108+
</StaticWebAssetPackageFile>
109+
</ItemGroup>
110+
111+
</Target>
112+
113+
<Target Name="CreateManifestResourceNames" />
114+
<Target Name="CoreCompile" />
115+
116+
</Project>

src/Assets/Pack/build.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@ECHO OFF
2+
SET RepoRoot=%~dp0..\..\..
3+
%RepoRoot%\eng\build.cmd -projects %~dp0**\*.*proj %*
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<Project>
2+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<Project>
2+
<Import Project="$(MSBuildThisFileDirectory)Microsoft.AspNetCore.StaticWebAssets.targets"/>
3+
<Import Project="$(MSBuildThisFileDirectory)Microsoft.AspNetCore.StaticWebAssets.endpoints.targets"/>
4+
</Project>

src/Components/Endpoints/src/Microsoft.AspNetCore.Components.Endpoints.csproj

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,28 +60,6 @@
6060
<Reference Include="Microsoft.Extensions.FileProviders.Embedded" />
6161
</ItemGroup>
6262

63-
<PropertyGroup>
64-
<BlazorWebJSFilename>blazor.web.js</BlazorWebJSFilename>
65-
<!-- Microsoft.AspNetCore.Components.Web.JS.npmproj always capitalizes the directory name. -->
66-
<BlazorWebJSFile Condition=" '$(Configuration)' == 'Debug' ">..\..\Web.JS\dist\Debug\$(BlazorWebJSFilename)</BlazorWebJSFile>
67-
<BlazorWebJSFile Condition=" '$(Configuration)' != 'Debug' ">..\..\Web.JS\dist\Release\$(BlazorWebJSFilename)</BlazorWebJSFile>
68-
</PropertyGroup>
69-
70-
<!-- blazor.web.js should exist after eng/Npm.Workspace.nodeproj builds. Fall back if not. -->
71-
<Target Name="_CheckBlazorWebJSPath" AfterTargets="ResolveProjectReferences" Condition=" !EXISTS('$(BlazorWebJSFile)') ">
72-
<Warning Text="'$(BlazorWebJSFile)' does not exist. Falling back to checked-in copy." />
73-
<PropertyGroup>
74-
<BlazorWebJSFile>..\..\Web.JS\dist\Release\$(BlazorWebJSFilename)</BlazorWebJSFile>
75-
</PropertyGroup>
76-
</Target>
77-
78-
<Target Name="_AddEmbeddedBlazorWebJS" AfterTargets="_CheckBlazorWebJSPath">
79-
<ItemGroup>
80-
<EmbeddedResource Include="$(BlazorWebJSFile)" LogicalName="_framework/$(BlazorWebJSFilename)" />
81-
<EmbeddedResource Include="$(BlazorWebJSFile).map" LogicalName="_framework/$(BlazorWebJSFilename).map" Condition="Exists('$(BlazorWebJSFile).map')" />
82-
</ItemGroup>
83-
</Target>
84-
8563
<ItemGroup>
8664
<InternalsVisibleTo Include="Microsoft.AspNetCore.Components.Endpoints.Microbenchmarks" />
8765
<InternalsVisibleTo Include="Microsoft.AspNetCore.Components.Endpoints.Tests" />

src/Components/Server/src/Microsoft.AspNetCore.Components.Server.csproj

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -98,28 +98,6 @@
9898
<Compile Include="$(RepoRoot)src\Shared\Components\ProtectedPrerenderComponentApplicationStore.cs" />
9999
</ItemGroup>
100100

101-
<PropertyGroup>
102-
<BlazorServerJSFilename>blazor.server.js</BlazorServerJSFilename>
103-
<!-- Microsoft.AspNetCore.Components.Web.JS.npmproj always capitalizes the directory name. -->
104-
<BlazorServerJSFile Condition=" '$(Configuration)' == 'Debug' ">..\..\Web.JS\dist\Debug\$(BlazorServerJSFilename)</BlazorServerJSFile>
105-
<BlazorServerJSFile Condition=" '$(Configuration)' != 'Debug' ">..\..\Web.JS\dist\Release\$(BlazorServerJSFilename)</BlazorServerJSFile>
106-
</PropertyGroup>
107-
108-
<!-- blazor.server.js should exist after eng/Npm.Workspace.nodeproj builds. Fall back if not. -->
109-
<Target Name="_CheckBlazorServerJSPath" AfterTargets="ResolveProjectReferences" Condition=" !EXISTS('$(BlazorServerJSFile)') ">
110-
<Warning Text="'$(BlazorServerJSFile)' does not exist. Falling back to checked-in copy." />
111-
<PropertyGroup>
112-
<BlazorServerJSFile>..\..\Web.JS\dist\Release\$(BlazorServerJSFilename)</BlazorServerJSFile>
113-
</PropertyGroup>
114-
</Target>
115-
116-
<Target Name="_AddEmbeddedBlazor" AfterTargets="_CheckBlazorServerJSPath">
117-
<ItemGroup>
118-
<EmbeddedResource Include="$(BlazorServerJSFile)" LogicalName="_framework/$(BlazorServerJSFilename)" />
119-
<EmbeddedResource Include="$(BlazorServerJSFile).map" LogicalName="_framework/$(BlazorServerJSFilename).map" Condition="Exists('$(BlazorServerJSFile).map')" />
120-
</ItemGroup>
121-
</Target>
122-
123101
<ItemGroup>
124102
<InternalsVisibleTo Include="Microsoft.AspNetCore.Blazor.DevServer" />
125103
<InternalsVisibleTo Include="Microsoft.AspNetCore.Components.Server.Tests" />

src/ProjectTemplates/scripts/Run-BlazorWasm-Locally.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ param(
2424
[Parameter(Mandatory = $false)]
2525
[string] $ClientId,
2626
[switch] $Pwa,
27+
[Parameter(Mandatory = $false)]
28+
[ValidateSet("Debug", "Release")]
29+
[string] $Configuration = "Release",
2730
[Parameter(ValueFromRemainingArguments = $true)]
2831
[string[]] $Args
2932
)
@@ -77,4 +80,5 @@ Test-Template `
7780
-TemplateArguments $templateArguments `
7881
-MainProjectRelativePath $mainProjectRelativePath `
7982
-TargetFramework $Framework `
83+
-Configuration $Configuration `
8084
-Verbose:$VerbosePreference;

src/ProjectTemplates/scripts/Run-BlazorWeb-Locally.ps1

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
[switch] $NoHttps,
2828
[Parameter(Mandatory = $false)]
2929
[switch] $UseProgramMain,
30+
[Parameter(Mandatory = $false)]
31+
[ValidateSet("Debug", "Release")]
32+
[string] $Configuration = "Release",
3033
[Parameter(ValueFromRemainingArguments = $true)]
3134
[string[]] $Args
3235
)
@@ -82,4 +85,5 @@
8285
-TemplateArguments $templateArguments `
8386
-MainProjectRelativePath $mainProjectRelativePath `
8487
-TargetFramework $Framework `
88+
-Configuration $Configuration `
8589
-Verbose:$VerbosePreference;

0 commit comments

Comments
 (0)