Skip to content
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

Wasm SDK packed as a nuget package #31519

Merged
merged 31 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e7d2e81
Remove most of Wasm SDK bits
maraf Mar 29, 2023
cdcb032
Fix KnownWebAssemblySdkPacks in FrameworkReferenceResolution
maraf Mar 30, 2023
fd70e90
Import using overridable _WebAssemblyPropsFile and _WebAssemblyTarget…
maraf Mar 30, 2023
068259c
Move wasm tasks related tests to runtime. Leave BootJsonData related …
maraf Mar 31, 2023
fc77b96
Don't override existing RuntimeIdentifier in SDK.props. Pass UsingMic…
maraf Apr 3, 2023
f968538
Move BootJsonData for tests to tests project.
maraf Apr 3, 2023
0af6292
Rename KnownWebAssemblySdkPack to KnownWebAssemblySdkBrowserPack
maraf Apr 6, 2023
75b3431
Revert "Rename KnownWebAssemblySdkPack to KnownWebAssemblySdkBrowserP…
maraf Apr 6, 2023
5c0ee81
Drop check for RuntimeIdenfier.
maraf Apr 6, 2023
55638db
Localization
maraf Apr 6, 2023
a0fb290
Merge remote-tracking branch 'upstream/main' into WasmSdkPackaged
maraf Apr 10, 2023
7feef8d
UpdateXlf
maraf Apr 10, 2023
d29701c
Update SDK
maraf Apr 11, 2023
e46392e
Feedback
maraf Apr 11, 2023
767d13a
Remove local nuget source.
maraf Apr 11, 2023
a74062c
Merge remote-tracking branch 'upstream/main' into WasmSdkPackaged
maraf Apr 17, 2023
2545fea
Fix after merge with main
maraf Apr 17, 2023
56781d7
Update installer version
maraf Apr 18, 2023
775f314
Merge remote-tracking branch 'upstream/main' into WasmSdkPackaged
maraf Apr 19, 2023
79daf53
Dont fail when WasmPack is not found (= building older .NET project)
maraf Apr 19, 2023
e765c80
Fix property expression. UsingBlazorSdk is still probably needed.
maraf Apr 19, 2023
fcc5d48
[ToRevert] Temporarily hook Compression
maraf Apr 19, 2023
6f4c068
Merge remote-tracking branch 'upstream/main' into WasmSdkPackaged
maraf Apr 21, 2023
abef876
Update SDK
maraf Apr 21, 2023
b72464a
Revert "[ToRevert] Temporarily hook Compression"
maraf Apr 21, 2023
f4d0393
Force browser-wasm on BlazorWebAssemblySdk.
maraf Apr 21, 2023
17589c3
Force AppendRuntimeIdentifierToOutputPath on BlazorWebAssemblySdk.
maraf Apr 21, 2023
9a052a2
Force CopyOutputSymbolsToPublishDirectory on BlazorWebAssemblySdk.
maraf Apr 21, 2023
64f0e09
Update comment
maraf Apr 21, 2023
e56576a
bump the sdk
lewing Apr 21, 2023
916e183
Update dependencies from https://github.com/dotnet/sourcelink build 2…
dotnet-maestro[bot] Apr 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -275,30 +275,30 @@
<Uri>https://github.com/dotnet/deployment-tools</Uri>
<Sha>9e870996b8bf0b91a791edd1039bfd23bdd01af8</Sha>
</Dependency>
<Dependency Name="Microsoft.Build.Tasks.Git" Version="8.0.0-beta.23210.3">
<Dependency Name="Microsoft.Build.Tasks.Git" Version="8.0.0-beta.23221.2">
<Uri>https://github.com/dotnet/sourcelink</Uri>
<Sha>759f344923a0859f3fae83431d0ba1cc62108118</Sha>
<Sha>34e1337814ee1c8f3cd7ac0a8402c0b03cdb95ad</Sha>
<SourceBuild RepoName="sourcelink" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.SourceLink.Common" Version="8.0.0-beta.23210.3">
<Dependency Name="Microsoft.SourceLink.Common" Version="8.0.0-beta.23221.2">
<Uri>https://github.com/dotnet/sourcelink</Uri>
<Sha>759f344923a0859f3fae83431d0ba1cc62108118</Sha>
<Sha>34e1337814ee1c8f3cd7ac0a8402c0b03cdb95ad</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceLink.AzureRepos.Git" Version="8.0.0-beta.23210.3">
<Dependency Name="Microsoft.SourceLink.AzureRepos.Git" Version="8.0.0-beta.23221.2">
<Uri>https://github.com/dotnet/sourcelink</Uri>
<Sha>759f344923a0859f3fae83431d0ba1cc62108118</Sha>
<Sha>34e1337814ee1c8f3cd7ac0a8402c0b03cdb95ad</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceLink.GitHub" Version="8.0.0-beta.23210.3">
<Dependency Name="Microsoft.SourceLink.GitHub" Version="8.0.0-beta.23221.2">
<Uri>https://github.com/dotnet/sourcelink</Uri>
<Sha>759f344923a0859f3fae83431d0ba1cc62108118</Sha>
<Sha>34e1337814ee1c8f3cd7ac0a8402c0b03cdb95ad</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceLink.GitLab" Version="8.0.0-beta.23210.3">
<Dependency Name="Microsoft.SourceLink.GitLab" Version="8.0.0-beta.23221.2">
<Uri>https://github.com/dotnet/sourcelink</Uri>
<Sha>759f344923a0859f3fae83431d0ba1cc62108118</Sha>
<Sha>34e1337814ee1c8f3cd7ac0a8402c0b03cdb95ad</Sha>
</Dependency>
<Dependency Name="Microsoft.SourceLink.BitBucket.Git" Version="8.0.0-beta.23210.3">
<Dependency Name="Microsoft.SourceLink.Bitbucket.Git" Version="8.0.0-beta.23221.2">
<Uri>https://github.com/dotnet/sourcelink</Uri>
<Sha>759f344923a0859f3fae83431d0ba1cc62108118</Sha>
<Sha>34e1337814ee1c8f3cd7ac0a8402c0b03cdb95ad</Sha>
</Dependency>
<!-- Explicit dependency because Microsoft.Deployment.DotNet.Releases has different versioning
than the SB intermediate -->
Expand Down
12 changes: 6 additions & 6 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@
</PropertyGroup>
<PropertyGroup>
<!-- Dependencies from https://github.com/dotnet/sourcelink -->
<MicrosoftBuildTasksGitVersion>8.0.0-beta.23210.3</MicrosoftBuildTasksGitVersion>
<MicrosoftSourceLinkCommonVersion>8.0.0-beta.23210.3</MicrosoftSourceLinkCommonVersion>
<MicrosoftSourceLinkAzureReposGitVersion>8.0.0-beta.23210.3</MicrosoftSourceLinkAzureReposGitVersion>
<MicrosoftSourceLinkGitHubVersion>8.0.0-beta.23210.3</MicrosoftSourceLinkGitHubVersion>
<MicrosoftSourceLinkGitLabVersion>8.0.0-beta.23210.3</MicrosoftSourceLinkGitLabVersion>
<MicrosoftSourceLinkBitBucketGitVersion>8.0.0-beta.23210.3</MicrosoftSourceLinkBitBucketGitVersion>
<MicrosoftBuildTasksGitVersion>8.0.0-beta.23221.2</MicrosoftBuildTasksGitVersion>
<MicrosoftSourceLinkCommonVersion>8.0.0-beta.23221.2</MicrosoftSourceLinkCommonVersion>
<MicrosoftSourceLinkAzureReposGitVersion>8.0.0-beta.23221.2</MicrosoftSourceLinkAzureReposGitVersion>
<MicrosoftSourceLinkGitHubVersion>8.0.0-beta.23221.2</MicrosoftSourceLinkGitHubVersion>
<MicrosoftSourceLinkGitLabVersion>8.0.0-beta.23221.2</MicrosoftSourceLinkGitLabVersion>
<MicrosoftSourceLinkBitbucketGitVersion>8.0.0-beta.23221.2</MicrosoftSourceLinkBitbucketGitVersion>
</PropertyGroup>
<!-- Get .NET Framework reference assemblies from NuGet packages -->
<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"tools": {
"dotnet": "8.0.100-preview.4.23174.9",
"dotnet": "8.0.100-preview.4.23221.6",
"runtimes": {
"dotnet": [
"$(VSRedistCommonNetCoreSharedFrameworkx6480PackageVersion)"
Expand All @@ -14,4 +14,4 @@
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23219.2",
"Microsoft.DotNet.Helix.Sdk": "8.0.0-beta.23219.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
<Project ToolsVersion="14.0">
<Project ToolsVersion="14.0" TreatAsLocalProperty="RuntimeIdentifier">
<PropertyGroup>
<OutputType>exe</OutputType>

<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<CopyOutputSymbolsToPublishDirectory>false</CopyOutputSymbolsToPublishDirectory>

<!-- Trimmer defaults -->
<PublishTrimmed Condition="'$(PublishTrimmed)' == ''">true</PublishTrimmed>
<TrimMode Condition="'$(TrimMode)' == ''">partial</TrimMode>
Expand Down
35 changes: 35 additions & 0 deletions src/StaticWebAssetsSdk/Tasks/FileHasher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// 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.Numerics;
using System.Security.Cryptography;
using System.Text;

namespace Microsoft.AspNetCore.StaticWebAssets.Tasks;

public static class FileHasher
{
public static string GetFileHash(string filePath)
{
using var hash = SHA256.Create();
var bytes = Encoding.UTF8.GetBytes(filePath);
var hashBytes = hash.ComputeHash(bytes);
return ToBase36(hashBytes);
}

private static string ToBase36(byte[] hash)
{
const string chars = "0123456789abcdefghijklmnopqrstuvwxyz";

var result = new char[10];
var dividend = BigInteger.Abs(new BigInteger(hash.AsSpan().Slice(0, 9).ToArray()));
for (var i = 0; i < 10; i++)
{
dividend = BigInteger.DivRem(dividend, 36, out var remainder);
result[i] = chars[(int)remainder];
}

return new string(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@
<Compile Include="..\..\RazorSdk\Tasks\DotnetToolTask.cs">
<Link>Shared\DotnetToolTask.cs</Link>
</Compile>
<Compile Include="..\..\WasmSdk\Tasks\FileHasher.cs">
<Link>Shared\FileHasher.cs</Link>
</Compile>
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/StaticWebAssetsSdk/Tasks/ResolveCompressedAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.NET.Sdk.WebAssembly;

namespace Microsoft.AspNetCore.StaticWebAssets.Tasks;

Expand Down
75 changes: 44 additions & 31 deletions src/Tasks/Microsoft.NET.Build.Tasks/ProcessFrameworkReferences.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public class ProcessFrameworkReferences : TaskBase

public ITaskItem[] KnownILLinkPacks { get; set; } = Array.Empty<ITaskItem>();

public ITaskItem[] KnownWebAssemblySdkPacks { get; set; } = Array.Empty<ITaskItem>();

public bool UsingMicrosoftNETSdkWebAssembly { get; set; }

[Required]
public string NETCoreSdkRuntimeIdentifier { get; set; }

Expand Down Expand Up @@ -368,7 +372,7 @@ var runtimeRequiredByDeployment
return;
}
}

if (AotEnabled)
{
if (!AddToolPack(ToolPackType.ILCompiler, _normalizedTargetFrameworkVersion, packagesToDownload, implicitPackageReferences))
Expand All @@ -387,6 +391,12 @@ var runtimeRequiredByDeployment
}
}

if (UsingMicrosoftNETSdkWebAssembly)
{
// WebAssemblySdk is used for .NET >= 6, it's ok if no pack is added.
AddToolPack(ToolPackType.WebAssemblySdk, _normalizedTargetFrameworkVersion, packagesToDownload, implicitPackageReferences);
}

if (packagesToDownload.Any())
{
PackagesToDownload = packagesToDownload.Distinct(new PackageToDownloadComparer<ITaskItem>()).ToArray();
Expand Down Expand Up @@ -594,7 +604,8 @@ private enum ToolPackType
{
Crossgen2,
ILCompiler,
ILLink
ILLink,
WebAssemblySdk
}

private bool AddToolPack(
Expand All @@ -603,10 +614,12 @@ private bool AddToolPack(
List<ITaskItem> packagesToDownload,
List<ITaskItem> implicitPackageReferences)
{
var knownPacks = toolPackType switch {
var knownPacks = toolPackType switch
{
ToolPackType.Crossgen2 => KnownCrossgen2Packs,
ToolPackType.ILCompiler => KnownILCompilerPacks,
ToolPackType.ILLink => KnownILLinkPacks,
ToolPackType.WebAssemblySdk => KnownWebAssemblySdkPacks,
_ => throw new ArgumentException($"Unknown package type {toolPackType}", nameof(toolPackType))
};

Expand All @@ -629,7 +642,6 @@ private bool AddToolPack(
packVersion = RuntimeFrameworkVersion;
}


// Crossgen and ILCompiler have RID-specific bits.
if (toolPackType is ToolPackType.Crossgen2 or ToolPackType.ILCompiler)
{
Expand Down Expand Up @@ -658,43 +670,44 @@ private bool AddToolPack(
runtimePackItem.SetMetadata(MetadataKeys.NuGetPackageId, runtimePackName);
runtimePackItem.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);

switch (toolPackType) {
case ToolPackType.Crossgen2:
Crossgen2Packs = new[] { runtimePackItem };
break;
case ToolPackType.ILCompiler:
HostILCompilerPacks = new[] { runtimePackItem };
switch (toolPackType)
{
case ToolPackType.Crossgen2:
Crossgen2Packs = new[] { runtimePackItem };
break;
case ToolPackType.ILCompiler:
HostILCompilerPacks = new[] { runtimePackItem };

// ILCompiler supports cross target compilation. If there is a cross-target request, we need to download that package as well
// We expect RuntimeIdentifier to be defined during publish but can allow during build
if (RuntimeIdentifier != null)
{
var targetRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, RuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph2);
if (targetRuntimeIdentifier == null)
// ILCompiler supports cross target compilation. If there is a cross-target request, we need to download that package as well
// We expect RuntimeIdentifier to be defined during publish but can allow during build
if (RuntimeIdentifier != null)
{
return false;
}
if (!hostRuntimeIdentifier.Equals(targetRuntimeIdentifier))
{
var targetIlcPackName = packNamePattern.Replace("**RID**", targetRuntimeIdentifier);
var targetIlcPack = new TaskItem(targetIlcPackName);
targetIlcPack.SetMetadata(MetadataKeys.NuGetPackageId, targetIlcPackName);
targetIlcPack.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);
TargetILCompilerPacks = new[] { targetIlcPack };
var targetRuntimeIdentifier = NuGetUtils.GetBestMatchingRid(runtimeGraph, RuntimeIdentifier, packSupportedRuntimeIdentifiers, out bool wasInGraph2);
if (targetRuntimeIdentifier == null)
{
return false;
}
if (!hostRuntimeIdentifier.Equals(targetRuntimeIdentifier))
{
var targetIlcPackName = packNamePattern.Replace("**RID**", targetRuntimeIdentifier);
var targetIlcPack = new TaskItem(targetIlcPackName);
targetIlcPack.SetMetadata(MetadataKeys.NuGetPackageId, targetIlcPackName);
targetIlcPack.SetMetadata(MetadataKeys.NuGetPackageVersion, packVersion);
TargetILCompilerPacks = new[] { targetIlcPack };
}
}
}
break;
break;
}
}

// ILCompiler and ILLink have RID-agnostic build packages that contain MSBuild targets.
if (toolPackType is ToolPackType.ILCompiler or ToolPackType.ILLink)
// Packs with RID-agnostic build packages that contain MSBuild targets.
if (toolPackType is not ToolPackType.Crossgen2)
{
var buildPackageName = knownPack.ItemSpec;
var buildPackage = new TaskItem(buildPackageName);
buildPackage.SetMetadata(MetadataKeys.Version, packVersion);
implicitPackageReferences.Add(buildPackage);
}
}

return true;
}
Expand Down Expand Up @@ -929,7 +942,7 @@ public KnownFrameworkReference(ITaskItem item)
public string RuntimePackRuntimeIdentifiers => _item.GetMetadata(MetadataKeys.RuntimePackRuntimeIdentifiers);

public bool IsWindowsOnly => _item.HasMetadataValue("IsWindowsOnly", "true");

public bool RuntimePackAlwaysCopyLocal =>
_item.HasMetadataValue(MetadataKeys.RuntimePackAlwaysCopyLocal, "true");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ Copyright (c) .NET Foundation. All rights reserved.
KnownCrossgen2Packs="@(KnownCrossgen2Pack)"
KnownILCompilerPacks="@(KnownILCompilerPack)"
KnownILLinkPacks="@(KnownILLinkPack)"
KnownWebAssemblySdkPacks="@(KnownWebAssemblySdkPack)"
UsingMicrosoftNETSdkWebAssembly="$(UsingMicrosoftNETSdkWebAssembly)"
NETCoreSdkRuntimeIdentifier="$(NETCoreSdkRuntimeIdentifier)"
NetCoreRoot="$(NetCoreRoot)"
NETCoreSdkVersion="$(NETCoreSdkVersion)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
</ItemGroup>

<ItemGroup>
<Compile Include="..\Microsoft.NET.Sdk.BlazorWebAssembly.Tests\BootJsonData.cs" Link="BootJsonData.cs" />
<Compile Include="..\Microsoft.NET.Sdk.BlazorWebAssembly.Tests\WasmPublishIntegrationTestBase.cs" Link="WasmPublishIntegrationTestBase.cs" />
<Compile Include="..\Microsoft.NET.Sdk.BlazorWebAssembly.Tests\ServiceWorkerAssert.cs" Link="ServiceWorkerAssert.cs" />
</ItemGroup>
Expand All @@ -51,7 +52,6 @@

<ItemGroup>
<ProjectReference Include="..\..\..\src\BlazorWasmSdk\Tasks\Microsoft.NET.Sdk.BlazorWebAssembly.Tasks.csproj" SkipGetTargetFrameworkProperties="true" />
<ProjectReference Include="..\..\..\src\WasmSdk\Tasks\Microsoft.NET.Sdk.WebAssembly.Tasks.csproj" SkipGetTargetFrameworkProperties="true" />
<ProjectReference Include="..\..\RazorSdk\Tasks\Microsoft.NET.Sdk.Razor.Tasks.csproj" />
<ProjectReference Include="..\Microsoft.NET.TestFramework\Microsoft.NET.TestFramework.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Runtime.Serialization;
using ResourceHashesByNameDictionary = System.Collections.Generic.Dictionary<string, string>;

// For test purposes only. Actual build time implementation lives in runtime repository with WasmSDK

namespace Microsoft.NET.Sdk.WebAssembly
{
#pragma warning disable IDE1006 // Naming Styles
Expand Down
Loading