Skip to content

Commit bc84bd3

Browse files
authored
Fix (#85400)
1 parent 0b30b3b commit bc84bd3

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

src/mono/wasm/Wasm.Build.Tests/Blazor/BuildPublishTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ public void BugRegression_60479_WithRazorClassLib()
198198
.ExecuteWithCapturedOutput("new razorclasslib")
199199
.EnsureSuccessful();
200200

201-
AddItemsPropertiesToProject(wasmProjectFile, extraItems:@"
201+
AddItemsPropertiesToProject(wasmProjectFile, extraItems: UseWebcil ? @"
202+
<ProjectReference Include=""..\RazorClassLibrary\RazorClassLibrary.csproj"" />
203+
<BlazorWebAssemblyLazyLoad Include=""RazorClassLibrary.webcil"" />
204+
" : @"
202205
<ProjectReference Include=""..\RazorClassLibrary\RazorClassLibrary.csproj"" />
203206
<BlazorWebAssemblyLazyLoad Include=""RazorClassLibrary.dll"" />
204207
");
@@ -223,7 +226,7 @@ public void BugRegression_60479_WithRazorClassLib()
223226
throw new XunitException($"Could not find resources.lazyAssembly object in {bootJson}");
224227
}
225228

226-
Assert.Contains("RazorClassLibrary.dll", lazyVal.EnumerateObject().Select(jp => jp.Name));
229+
Assert.Contains("RazorClassLibrary.webcil", lazyVal.EnumerateObject().Select(jp => jp.Name));
227230
}
228231

229232
[ConditionalTheory(typeof(BuildTestBase), nameof(IsUsingWorkloads))]

src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ComputeWasmPublishAssets.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ private List<ITaskItem> ComputeUpdatedAssemblies(
373373
assetsToUpdate.Add(satelliteAssembly.ItemSpec, satelliteAssembly);
374374
var culture = satelliteAssembly.GetMetadata("AssetTraitValue");
375375
var fileName = Path.GetFileName(satelliteAssembly.GetMetadata("RelativePath"));
376+
if (IsWebCilEnabled)
377+
fileName = Path.ChangeExtension(fileName, ".dll");
378+
376379
if (satelliteAssemblies.TryGetValue((culture, fileName), out var existing))
377380
{
378381
filesToRemove.Add(existing);

src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/ConvertDllsToWebCil.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ public override bool Execute()
6262
var webcilWriter = Microsoft.WebAssembly.Build.Tasks.WebcilConverter.FromPortableExecutable(inputPath: filePath, outputPath: tmpWebcil, logger: Log);
6363
webcilWriter.ConvertToWebcil();
6464

65-
var finalWebcil = Path.Combine(OutputPath, Path.GetFileNameWithoutExtension(filePath) + ".webcil");
65+
string candicatePath = Path.Combine(OutputPath, candidate.GetMetadata("Culture"));
66+
if (!Directory.Exists(candicatePath))
67+
Directory.CreateDirectory(candicatePath);
68+
69+
var finalWebcil = Path.Combine(candicatePath, Path.GetFileNameWithoutExtension(filePath) + ".webcil");
6670
if (Utils.CopyIfDifferent(tmpWebcil, finalWebcil, useHash: true))
6771
Log.LogMessage(MessageImportance.Low, $"Generated {finalWebcil} .");
6872
else
@@ -72,10 +76,16 @@ public override bool Execute()
7276

7377
var webcilItem = new TaskItem(finalWebcil, candidate.CloneCustomMetadata());
7478
webcilItem.SetMetadata("RelativePath", Path.ChangeExtension(candidate.GetMetadata("RelativePath"), ".webcil"));
75-
webcilItem.SetMetadata("AssetTraitName", "WasmResource");
76-
webcilItem.SetMetadata("AssetTraitValue", "runtime");
7779
webcilItem.SetMetadata("OriginalItemSpec", finalWebcil);
7880

81+
if (webcilItem.GetMetadata("AssetTraitName") == "Culture")
82+
{
83+
string relatedAsset = webcilItem.GetMetadata("RelatedAsset");
84+
relatedAsset = Path.ChangeExtension(relatedAsset, ".webcil");
85+
webcilItem.SetMetadata("RelatedAsset", relatedAsset);
86+
Log.LogMessage(MessageImportance.Low, $"Changing related asset of {webcilItem} to {relatedAsset}.");
87+
}
88+
7989
webCilCandidates.Add(webcilItem);
8090
}
8191
else

src/tasks/Microsoft.NET.Sdk.WebAssembly.Pack.Tasks/GenerateWasmBootJson.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void WriteBootJson(Stream output, string entryAssemblyName)
174174
}
175175
else if (string.Equals("symbol", assetTraitValue, StringComparison.OrdinalIgnoreCase))
176176
{
177-
if (TryGetLazyLoadedAssembly($"{fileName}.dll", out _))
177+
if (TryGetLazyLoadedAssembly($"{fileName}.dll", out _) || TryGetLazyLoadedAssembly($"{fileName}.webcil", out _))
178178
{
179179
Log.LogMessage(MessageImportance.Low, "Candidate '{0}' is defined as a lazy loaded symbols file.", resource.ItemSpec);
180180
resourceData.lazyAssembly ??= new ResourceHashesByNameDictionary();

0 commit comments

Comments
 (0)