-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[browser] Wasm SDK packed as a nuget package #84082
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2788669
Wasm SDK as nuget package.
maraf aac1aaa
Include project in the mono-packages.proj
maraf ff71159
Drop debug nuget source.
maraf 0bb15b3
Rename package to Microsoft.NET.Sdk.WebAssembly.Pack, disable package…
maraf 609386f
Drop debug nuget source.
maraf d5bd817
Include .cs and .config files
maraf d079e6a
Import using overridable _WebAssemblyPropsFile and _WebAssemblyTarget…
maraf 735368d
Rewrite bundling as pkgproj.
maraf 5e94346
Drop BuildOutputTargetFolder.
maraf 93b48b6
Rename WebAssemblySdk.Pack to WebAssemblySdk.Browser
maraf 31f492e
Revert "Rename WebAssemblySdk.Pack to WebAssemblySdk.Browser"
maraf b25e9ec
Move the RID condition to pack props.
maraf 2e268b6
Update UsingMicrosoftNETSdkBlazorWebAssembly conditions
maraf c4bf098
Fix publishing dotnet.js
maraf 5dd1c93
Fix including tasks dlls
maraf c2812d2
Fix default value for RID
maraf 39a9ddd
Proper way to pack tasks dll
maraf 4117c5c
Formatting
maraf 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
2 changes: 1 addition & 1 deletion
2
src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Sdk/Sdk/Sdk.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
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
14 changes: 14 additions & 0 deletions
14
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/Microsoft.NET.Sdk.WebAssembly.Pack.pkgproj
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,14 @@ | ||
<Project DefaultTargets="Build"> | ||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.props))" /> | ||
|
||
<PropertyGroup> | ||
<PackageDescription>SDK for building and publishing WebAssembly applications.</PackageDescription> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="$(RepoTasksDir)Microsoft.NET.Sdk.WebAssembly.Pack.Tasks\Microsoft.NET.Sdk.WebAssembly.Pack.Tasks.csproj" /> | ||
<PackageFile Include="build\*.props;build\*.targets;build\*.web.config" TargetPath="build" /> | ||
</ItemGroup> | ||
|
||
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets))" /> | ||
</Project> |
43 changes: 43 additions & 0 deletions
43
...uget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.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,43 @@ | ||
<!-- | ||
*********************************************************************************************** | ||
Microsoft.NET.Sdk.WebAssembly.props | ||
|
||
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have | ||
created a backup copy. Incorrect changes to this file will make it | ||
impossible to load or build your projects from the command-line or the IDE. | ||
|
||
Copyright (c) .NET Foundation. All rights reserved. | ||
*********************************************************************************************** | ||
--> | ||
<Project ToolsVersion="14.0" TreatAsLocalProperty="RuntimeIdentifier"> | ||
<PropertyGroup> | ||
<!-- Avoid having the rid show up in output paths --> | ||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath> | ||
|
||
<OutputType>exe</OutputType> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject> | ||
|
||
<!-- Turn off symbol publishing by default --> | ||
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory> | ||
|
||
<!-- Trimmer defaults --> | ||
<PublishTrimmed Condition="'$(PublishTrimmed)' == ''">true</PublishTrimmed> | ||
<TrimMode Condition="'$(TrimMode)' == ''">partial</TrimMode> | ||
<TrimmerRemoveSymbols Condition="'$(TrimmerRemoveSymbols)' == ''">false</TrimmerRemoveSymbols> | ||
|
||
<!-- Static web assets defaults --> | ||
<StaticWebAssetBasePath Condition="'$(StaticWebAssetBasePath)' == ''">/</StaticWebAssetBasePath> | ||
<StaticWebAssetProjectMode Condition="'$(StaticWebAssetProjectMode)' == ''">Root</StaticWebAssetProjectMode> | ||
<StaticWebAssetsAdditionalBuildPropertiesToRemove>$(StaticWebAssetsAdditionalBuildPropertiesToRemove);RuntimeIdentifier;SelfContained</StaticWebAssetsAdditionalBuildPropertiesToRemove> | ||
<StaticWebAssetsGetPublishAssetsTargets>ComputeFilesToPublish;GetCurrentProjectPublishStaticWebAssetItems</StaticWebAssetsGetPublishAssetsTargets> | ||
<StaticWebAssetsAdditionalPublishProperties>$(StaticWebAssetsAdditionalPublishProperties);BuildProjectReferences=false;ResolveAssemblyReferencesFindRelatedSatellites=true</StaticWebAssetsAdditionalPublishProperties> | ||
<StaticWebAssetsAdditionalPublishPropertiesToRemove>$(StaticWebAssetsAdditionalPublishPropertiesToRemove);NoBuild;RuntimeIdentifier</StaticWebAssetsAdditionalPublishPropertiesToRemove> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectCapability Include="WebAssembly" /> | ||
</ItemGroup> | ||
</Project> |
493 changes: 493 additions & 0 deletions
493
...et/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets
Large diffs are not rendered by default.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
...o/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Pack.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,20 @@ | ||
<!-- | ||
*********************************************************************************************** | ||
Microsoft.NET.Sdk.WebAssembly.props | ||
|
||
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have | ||
created a backup copy. Incorrect changes to this file will make it | ||
impossible to load or build your projects from the command-line or the IDE. | ||
|
||
Copyright (c) .NET Foundation. All rights reserved. | ||
*********************************************************************************************** | ||
--> | ||
<Project ToolsVersion="14.0"> | ||
<PropertyGroup> | ||
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">browser-wasm</RuntimeIdentifier> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(RuntimeIdentifier)' == 'browser-wasm'"> | ||
<_WebAssemblyPropsFile>$(MSBuildThisFileDirectory)\Microsoft.NET.Sdk.WebAssembly.Browser.props</_WebAssemblyPropsFile> | ||
<_WebAssemblyTargetsFile>$(MSBuildThisFileDirectory)\Microsoft.NET.Sdk.WebAssembly.Browser.targets</_WebAssemblyTargetsFile> | ||
</PropertyGroup> | ||
</Project> |
12 changes: 12 additions & 0 deletions
12
...nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Pack.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,12 @@ | ||
<!-- | ||
*********************************************************************************************** | ||
Microsoft.NET.Sdk.WebAssembly.targets | ||
|
||
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have | ||
created a backup copy. Incorrect changes to this file will make it | ||
impossible to load or build your projects from the command-line or the IDE. | ||
|
||
Copyright (c) .NET Foundation. All rights reserved. | ||
*********************************************************************************************** | ||
--> | ||
<Project ToolsVersion="14.0"></Project> |
44 changes: 44 additions & 0 deletions
44
src/mono/nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Wasm.web.config
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,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
<system.webServer> | ||
<staticContent> | ||
<remove fileExtension=".blat" /> | ||
<remove fileExtension=".dat" /> | ||
<remove fileExtension=".dll" /> | ||
<remove fileExtension=".webcil" /> | ||
<remove fileExtension=".json" /> | ||
<remove fileExtension=".wasm" /> | ||
<remove fileExtension=".woff" /> | ||
<remove fileExtension=".woff2" /> | ||
<mimeMap fileExtension=".blat" mimeType="application/octet-stream" /> | ||
<mimeMap fileExtension=".dll" mimeType="application/octet-stream" /> | ||
<mimeMap fileExtension=".webcil" mimeType="application/octet-stream" /> | ||
<mimeMap fileExtension=".dat" mimeType="application/octet-stream" /> | ||
<mimeMap fileExtension=".json" mimeType="application/json" /> | ||
<mimeMap fileExtension=".wasm" mimeType="application/wasm" /> | ||
<mimeMap fileExtension=".woff" mimeType="application/font-woff" /> | ||
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" /> | ||
</staticContent> | ||
<httpCompression> | ||
<dynamicTypes> | ||
<add mimeType="application/octet-stream" enabled="true" /> | ||
<add mimeType="application/wasm" enabled="true" /> | ||
</dynamicTypes> | ||
</httpCompression> | ||
<rewrite> | ||
<rules> | ||
<rule name="Serve subdir"> | ||
<match url=".*" /> | ||
<action type="Rewrite" url="wwwroot\{R:0}" /> | ||
</rule> | ||
<rule name="SPA fallback routing" stopProcessing="true"> | ||
<match url=".*" /> | ||
<conditions logicalGrouping="MatchAll"> | ||
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> | ||
</conditions> | ||
<action type="Rewrite" url="wwwroot\" /> | ||
</rule> | ||
</rules> | ||
</rewrite> | ||
</system.webServer> | ||
</configuration> |
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
86 changes: 86 additions & 0 deletions
86
src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/AssetsComputingHelper.cs
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,86 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using Microsoft.Build.Framework; | ||
using Microsoft.Build.Utilities; | ||
|
||
namespace Microsoft.NET.Sdk.WebAssembly; | ||
|
||
public class AssetsComputingHelper | ||
{ | ||
public static bool ShouldFilterCandidate( | ||
ITaskItem candidate, | ||
bool timezoneSupport, | ||
bool invariantGlobalization, | ||
bool copySymbols, | ||
string customIcuCandidateFilename, | ||
out string reason) | ||
{ | ||
var extension = candidate.GetMetadata("Extension"); | ||
var fileName = candidate.GetMetadata("FileName"); | ||
var assetType = candidate.GetMetadata("AssetType"); | ||
var fromMonoPackage = string.Equals( | ||
candidate.GetMetadata("NuGetPackageId"), | ||
"Microsoft.NETCore.App.Runtime.Mono.browser-wasm", | ||
StringComparison.Ordinal); | ||
|
||
reason = extension switch | ||
{ | ||
".a" when fromMonoPackage => "extension is .a is not supported.", | ||
".c" when fromMonoPackage => "extension is .c is not supported.", | ||
".h" when fromMonoPackage => "extension is .h is not supported.", | ||
// It is safe to filter out all XML files since we are not interested in any XML file from the list | ||
// of ResolvedFilesToPublish to become a static web asset. Things like this include XML doc files and | ||
// so on. | ||
".xml" => "it is a documentation file", | ||
".rsp" when fromMonoPackage => "extension is .rsp is not supported.", | ||
".props" when fromMonoPackage => "extension is .props is not supported.", | ||
".blat" when !timezoneSupport => "timezone support is not enabled.", | ||
".dat" when invariantGlobalization && fileName.StartsWith("icudt") => "invariant globalization is enabled", | ||
".dat" when !string.IsNullOrEmpty(customIcuCandidateFilename) && fileName != customIcuCandidateFilename => "custom icu file will be used instead of icu from the runtime pack", | ||
".json" when fromMonoPackage && (fileName == "emcc-props" || fileName == "package") => $"{fileName}{extension} is not used by Blazor", | ||
".ts" when fromMonoPackage && fileName == "dotnet.d" => "dotnet type definition is not used by Blazor", | ||
".ts" when fromMonoPackage && fileName == "dotnet-legacy.d" => "dotnet type definition is not used by Blazor", | ||
".js" when assetType == "native" && fileName != "dotnet" => $"{fileName}{extension} is not used by Blazor", | ||
".pdb" when !copySymbols => "copying symbols is disabled", | ||
".symbols" when fromMonoPackage => "extension .symbols is not required.", | ||
_ => null | ||
}; | ||
|
||
return reason != null; | ||
} | ||
|
||
public static string GetCandidateRelativePath(ITaskItem candidate) | ||
{ | ||
var destinationSubPath = candidate.GetMetadata("DestinationSubPath"); | ||
if (!string.IsNullOrEmpty(destinationSubPath)) | ||
return $"_framework/{destinationSubPath}"; | ||
|
||
var relativePath = candidate.GetMetadata("FileName") + candidate.GetMetadata("Extension"); | ||
return $"_framework/{relativePath}"; | ||
} | ||
|
||
public static ITaskItem GetCustomIcuAsset(ITaskItem candidate) | ||
{ | ||
var customIcuCandidate = new TaskItem(candidate); | ||
var relativePath = GetCandidateRelativePath(customIcuCandidate); | ||
customIcuCandidate.SetMetadata("RelativePath", relativePath); | ||
customIcuCandidate.SetMetadata("AssetTraitName", "BlazorWebAssemblyResource"); | ||
customIcuCandidate.SetMetadata("AssetTraitValue", "native"); | ||
customIcuCandidate.SetMetadata("AssetType", "native"); | ||
return customIcuCandidate; | ||
} | ||
|
||
public static bool TryGetAssetFilename(ITaskItem candidate, out string filename) | ||
{ | ||
bool candidateIsValid = candidate != null && !string.IsNullOrEmpty(candidate.ItemSpec); | ||
filename = candidateIsValid ? | ||
$"{candidate.GetMetadata("FileName")}" : | ||
""; | ||
return candidateIsValid; | ||
} | ||
} |
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.
What's the reason for this?
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.
It's taken from blazor. I would like to be as similar as possible