-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add package for consuming Blazor framework assets #58721
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
896fc94
Prototype for framework JS assets package
MackinnonBuck 4cd421e
Fix local development scenarios
MackinnonBuck ae3d1df
A few more fixes
MackinnonBuck cab68e4
Use `<Reference />`
MackinnonBuck cfeb607
Fix project template tests
MackinnonBuck 35012fa
Include .map files
MackinnonBuck b3b8d48
Update "rollup.config.mjs"
MackinnonBuck b5c6cc8
Fix release build
MackinnonBuck aaf8318
Update tests
MackinnonBuck 82eca0f
Fix more tests
MackinnonBuck c206188
Fix E2E tests
MackinnonBuck ef84a49
Change how new package is reference in repo
MackinnonBuck caf6aba
Remove checked-in built JS assets
MackinnonBuck 4c92e35
Rename package
MackinnonBuck 6a93240
More PR feedback
MackinnonBuck fa5f52d
Try generating static assets in package targets
MackinnonBuck 7b6fc53
Fix Blazor WebAssembly standalone
MackinnonBuck 3ac33cf
Try to fix release build (again)
MackinnonBuck 24bb8d5
Fix Components.slnf
MackinnonBuck 4a9b2e3
Don't include blazor.webassembly.js in server project
MackinnonBuck 9715c03
Copy assets to intermediate output dir
6344b48
Use .map files during local development
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/Assets/Microsoft.AspNetCore.App.Internal.Assets.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="Pack"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
<Description>ASP.NET Core static framework assets</Description> | ||
<PackageId>Microsoft.AspNetCore.App.Internal.Assets</PackageId> | ||
<IsPackable>true</IsPackable> | ||
<OutputType>Library</OutputType> | ||
<ExcludeFromSourceOnlyBuild>true</ExcludeFromSourceOnlyBuild> | ||
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory> | ||
<IncludeBuildOutput>false</IncludeBuildOutput> | ||
<IncludeSymbols>false</IncludeSymbols> | ||
<ImplicitUsings>disable</ImplicitUsings> | ||
|
||
<!-- The package doesn't produce any lib or ref assemblies --> | ||
<NoWarn>$(NoWarn);NU5128</NoWarn> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<_BlazorJSContentRoot Condition="'$(Configuration)' == 'Debug'">$(RepoRoot)src\Components\Web.JS\dist\Debug</_BlazorJSContentRoot> | ||
<_BlazorJSContentRoot Condition="'$(Configuration)' == 'Release'">$(RepoRoot)src\Components\Web.JS\dist\Release</_BlazorJSContentRoot> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.web.js" /> | ||
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.server.js" /> | ||
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.webassembly.js" /> | ||
|
||
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.web.js.map" /> | ||
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.server.js.map" /> | ||
<_BlazorJSFile Include="$(_BlazorJSContentRoot)\blazor.webassembly.js.map" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="build\*" Pack="true" PackagePath="%(Identity)" /> | ||
<None Include="buildMultiTargeting\*" Pack="true" PackagePath="%(Identity)" /> | ||
<None Include="buildTransitive\*" Pack="true" PackagePath="%(Identity)" /> | ||
<None Include="@(_BlazorJSFile)" Pack="true" PackagePath="_framework\%(FileName)%(Extension)" /> | ||
</ItemGroup> | ||
|
||
<Target Name="_CheckBlazorJSPath" AfterTargets="ResolveProjectReferences"> | ||
<ItemGroup> | ||
<_MissingBlazorJSFile Include="@(_BlazorJSFile)" Condition="!EXISTS('%(_BlazorJSFile.FullPath)')" /> | ||
</ItemGroup> | ||
|
||
<Error | ||
Condition="'@(_MissingBlazorJSFile)' != ''" | ||
Text="'%(_MissingBlazorJSFile.Identity)' does not exist. Run 'npm run build' in the repo root to generate the file." /> | ||
</Target> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@ECHO OFF | ||
SET RepoRoot=%~dp0..\.. | ||
%RepoRoot%\eng\build.cmd -projects %~dp0**\*.*proj %* |
2 changes: 2 additions & 0 deletions
2
src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.props
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<Project> | ||
</Project> |
85 changes: 85 additions & 0 deletions
85
src/Assets/build/Microsoft.AspNetCore.App.Internal.Assets.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<ResolveStaticWebAssetsInputsDependsOn> | ||
$(ResolveStaticWebAssetsInputsDependsOn); | ||
_AddBlazorFrameworkStaticWebAssets; | ||
</ResolveStaticWebAssetsInputsDependsOn> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<BlazorFrameworkStaticWebAssetRoot Condition="'$(BlazorFrameworkStaticWebAssetRoot)' == ''">$(MSBuildThisFileDirectory)..\_framework</BlazorFrameworkStaticWebAssetRoot> | ||
</PropertyGroup> | ||
|
||
<Target Name="_AddBlazorFrameworkStaticWebAssets" Condition="'$(OutputType)' == 'Exe'"> | ||
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'"> | ||
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.web.js" /> | ||
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.server.js" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' AND '$(UseBlazorFrameworkDebugAssets)' == 'true'"> | ||
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.web.js.map" /> | ||
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.server.js.map" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<_IncludeAssetsInBlazorWebAssemblyProject Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' AND '$(StaticWebAssetProjectMode)' != 'Default'">true</_IncludeAssetsInBlazorWebAssemblyProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="'$(_IncludeAssetsInBlazorWebAssemblyProject)' == 'true'"> | ||
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.webassembly.js" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Condition="'$(_IncludeAssetsInBlazorWebAssemblyProject)' == 'true' AND '$(UseBlazorFrameworkDebugAssets)' == 'true'"> | ||
<_FrameworkStaticWebAssetCandidate Include="$(BlazorFrameworkStaticWebAssetRoot)\blazor.webassembly.js.map" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<_FrameworkAssetsPath>$(IntermediateOutputPath)frameworkassets</_FrameworkAssetsPath> | ||
</PropertyGroup> | ||
|
||
<MakeDir | ||
Directories="$(_FrameworkAssetsPath)" | ||
Condition="!Exists('$(_FrameworkAssetsPath)')" /> | ||
|
||
<Copy | ||
SourceFiles="@(_FrameworkStaticWebAssetCandidate)" | ||
DestinationFolder="$(_FrameworkAssetsPath)" | ||
SkipUnchangedFiles="true"> | ||
<Output TaskParameter="CopiedFiles" ItemName="_CopiedFrameworkStaticWebAssetCandidate" /> | ||
</Copy> | ||
|
||
<ItemGroup> | ||
<_CopiedFrameworkStaticWebAssetCandidate> | ||
<RelativePath>_framework\%(FileName)%(Extension)</RelativePath> | ||
<ContentRoot>$(_FrameworkAssetsPath)</ContentRoot> | ||
</_CopiedFrameworkStaticWebAssetCandidate> | ||
</ItemGroup> | ||
|
||
<DefineStaticWebAssets | ||
Condition="'@(_CopiedFrameworkStaticWebAssetCandidate->Count())' != '0'" | ||
CandidateAssets="@(_CopiedFrameworkStaticWebAssetCandidate)" | ||
SourceId="$(PackageId)" | ||
SourceType="Discovered" | ||
AssetKind="All" | ||
AssetMode="All" | ||
AssetRole="Primary" | ||
FingerprintCandidates="true" | ||
BasePath="$(StaticWebAssetBasePath)"> | ||
<Output TaskParameter="Assets" ItemName="_FrameworkStaticWebAsset" /> | ||
</DefineStaticWebAssets> | ||
|
||
<DefineStaticWebAssetEndpoints | ||
Condition="'@(_FrameworkStaticWebAsset)' != ''" | ||
CandidateAssets="@(_FrameworkStaticWebAsset)" | ||
ExistingEndpoints="" | ||
ContentTypeMappings="@(StaticWebAssetContentTypeMapping)"> | ||
<Output TaskParameter="Endpoints" ItemName="_FrameworkStaticAssetEndpoint" /> | ||
</DefineStaticWebAssetEndpoints> | ||
|
||
<ItemGroup> | ||
<StaticWebAsset Include="@(_FrameworkStaticWebAsset)" /> | ||
<StaticWebAssetEndpoint Include="@(_FrameworkStaticAssetEndpoint)" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
</Project> |
3 changes: 3 additions & 0 deletions
3
src/Assets/buildMultiTargeting/Microsoft.AspNetCore.App.Internal.Assets.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Project> | ||
<Import Project="$(MSBuildThisFileDirectory)..\buildTransitive\Microsoft.AspNetCore.App.Internal.Assets.targets"/> | ||
</Project> |
3 changes: 3 additions & 0 deletions
3
src/Assets/buildTransitive/Microsoft.AspNetCore.App.Internal.Assets.targets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Project> | ||
<Import Project="$(MSBuildThisFileDirectory)..\build\Microsoft.AspNetCore.App.Internal.Assets.targets"/> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,3 @@ | ||
<Project> | ||
<PropertyGroup Condition="'$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true'"> | ||
<BlazorWebAssemblyJSPath | ||
Condition=" '$(Configuration)' == 'Debug' ">$(RepoRoot)src\Components\Web.JS\dist\Debug\blazor.webassembly.js</BlazorWebAssemblyJSPath> | ||
<BlazorWebAssemblyJSPath | ||
Condition=" '$(Configuration)' != 'Debug' ">$(RepoRoot)src\Components\Web.JS\dist\Release\blazor.webassembly.js</BlazorWebAssemblyJSPath> | ||
<BlazorWebAssemblyJSMapPath>$(BlazorWebAssemblyJSPath).map</BlazorWebAssemblyJSMapPath> | ||
|
||
<_BlazorDevServerPath>$(ArtifactsDir)bin/Microsoft.AspNetCore.Components.WebAssembly.DevServer/$(Configuration)/$(DefaultNetCoreTargetFramework)/blazor-devserver.dll</_BlazorDevServerPath> | ||
<RunCommand>dotnet</RunCommand> | ||
<_RunExtraArguments Condition="'$(WasmEnableThreads)' == 'true'">--apply-cop-headers</_RunExtraArguments> | ||
<RunArguments>exec "$(_BlazorDevServerPath)" --applicationpath "$(TargetPath)" $(_RunExtraArguments) $(AdditionalRunArguments)</RunArguments> | ||
</PropertyGroup> | ||
|
||
<Target Name="_CheckBlazorWebAssemblyJSPath" AfterTargets="ResolveProjectReferences" | ||
Condition=" '$(UsingMicrosoftNETSdkBlazorWebAssembly)' == 'true' AND !EXISTS('$(BlazorWebAssemblyJSPath)') "> | ||
<Error Text="'$(BlazorWebAssemblyJSPath)' does not exist. Enable NodeJS to build this project." /> | ||
</Target> | ||
|
||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
<Project> | ||
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory)..\, Directory.Build.targets))\Directory.Build.targets" /> | ||
<!-- Workaround target import for project references to Microsoft.Extensions.FileProviders.Embedded --> | ||
<Import | ||
Project="$(RepoRoot)src\FileProviders\Embedded\src\build\netstandard2.0\Microsoft.Extensions.FileProviders.Embedded.targets" /> | ||
</Project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having troubles getting this to build inside the VMR. Don't we need something similar to
aspnetcore/src/Components/WebView/WebView/src/Microsoft.AspNetCore.Components.WebView.csproj
Lines 66 to 72 in 8d0f798
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK my issue with building this inside the VMR is unrelated to this change. But I wonder if a fallback should still get added as the other project has it.