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

[browser] Fix treating dotnet.native.wasm as native asset during publish #89079

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.NET.Sdk.WebAssembly;

namespace Microsoft.NET.Sdk.WebAssembly;

Expand Down Expand Up @@ -265,6 +263,7 @@ private List<ITaskItem> ProcessNativeAssets(

ApplyPublishProperties(newDotNetWasm);
nativeStaticWebAssets.Add(newDotNetWasm);

if (resolvedNativeAssetToPublish.TryGetValue("dotnet.native.wasm", out var resolved))
{
filesToRemove.Add(resolved);
Expand Down Expand Up @@ -592,7 +591,14 @@ private void GroupResolvedFilesToPublish(
continue;
}

var fileName = candidate.GetMetadata("FileName");
var extension = candidate.GetMetadata("Extension");
if (string.Equals(candidate.GetMetadata("AssetType"), "native", StringComparison.Ordinal) && (fileName == "dotnet" || fileName == "dotnet.native") && extension == ".wasm")
{
ResolveAsNativeAsset(Log, resolvedNativeAssetToPublish, candidate, extension);
continue;
}

if (string.Equals(extension, ".dll", StringComparison.Ordinal) || string.Equals(extension, Utils.WebcilInWasmExtension, StringComparison.Ordinal))
{
var culture = candidate.GetMetadata("Culture");
Expand Down Expand Up @@ -643,6 +649,12 @@ private void GroupResolvedFilesToPublish(
// Capture all the native unfiltered assets since we need to process them to determine what static web assets need to get
// upgraded
if (string.Equals(candidate.GetMetadata("AssetType"), "native", StringComparison.Ordinal))
{
ResolveAsNativeAsset(Log, resolvedNativeAssetToPublish, candidate, extension);
continue;
}

static void ResolveAsNativeAsset(TaskLoggingHelper log, Dictionary<string, ITaskItem> resolvedNativeAssetToPublish, ITaskItem candidate, string extension)
{
var candidateName = $"{candidate.GetMetadata("FileName")}{extension}";
if (!resolvedNativeAssetToPublish.ContainsKey(candidateName))
Expand All @@ -651,9 +663,8 @@ private void GroupResolvedFilesToPublish(
}
else
{
Log.LogMessage(MessageImportance.Low, "Duplicate candidate '{0}' found in ResolvedFilesToPublish", candidate.ItemSpec);
log.LogMessage(MessageImportance.Low, "Duplicate candidate '{0}' found in ResolvedFilesToPublish", candidate.ItemSpec);
}
continue;
}
#pragma warning restore CA1864
}
Expand Down