Copy I18N assemblies when running without the linker (#20878)
* Copy I18N assemblies when running without the linker Fixes https://github.com/dotnet/aspnetcore/issues/20517
This commit is contained in:
parent
840d806326
commit
50a2527ca9
|
|
@ -1,7 +1,7 @@
|
||||||
<Project>
|
<Project>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<MonoLinkerI18NAssemblies>none</MonoLinkerI18NAssemblies> <!-- See Mono linker docs - allows comma-separated values from: none,all,cjk,mideast,other,rare,west -->
|
<BlazorWebAssemblyI18NAssemblies>none</BlazorWebAssemblyI18NAssemblies> <!-- See Mono linker docs - allows comma-separated values from: none,all,cjk,mideast,other,rare,west -->
|
||||||
<AdditionalMonoLinkerOptions>--disable-opt unreachablebodies --verbose --strip-security true --exclude-feature com -v false -c link -u link -b true</AdditionalMonoLinkerOptions>
|
<AdditionalMonoLinkerOptions>--disable-opt unreachablebodies --verbose --strip-security true --exclude-feature com -v false -c link -u link -b true</AdditionalMonoLinkerOptions>
|
||||||
|
|
||||||
<_BlazorJsPath Condition="'$(_BlazorJsPath)' == ''">$(MSBuildThisFileDirectory)..\tools\blazor\blazor.webassembly.js</_BlazorJsPath>
|
<_BlazorJsPath Condition="'$(_BlazorJsPath)' == ''">$(MSBuildThisFileDirectory)..\tools\blazor\blazor.webassembly.js</_BlazorJsPath>
|
||||||
|
|
|
||||||
|
|
@ -265,7 +265,7 @@
|
||||||
Condition="'$(BuildingInsideVisualStudio)' != 'true' OR '$(DeployOnBuild)' != 'true'">
|
Condition="'$(BuildingInsideVisualStudio)' != 'true' OR '$(DeployOnBuild)' != 'true'">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<_BlazorLinkerAdditionalOptions>-l $(MonoLinkerI18NAssemblies) $(AdditionalMonoLinkerOptions)</_BlazorLinkerAdditionalOptions>
|
<_BlazorLinkerAdditionalOptions>-l $(BlazorWebAssemblyI18NAssemblies) $(AdditionalMonoLinkerOptions)</_BlazorLinkerAdditionalOptions>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -333,6 +333,14 @@
|
||||||
<Output TaskParameter="Dependencies" ItemName="_BlazorResolvedAssemblyUnlinked" />
|
<Output TaskParameter="Dependencies" ItemName="_BlazorResolvedAssemblyUnlinked" />
|
||||||
</ResolveBlazorRuntimeDependencies>
|
</ResolveBlazorRuntimeDependencies>
|
||||||
|
|
||||||
|
<ItemGroup Condition="'$(BlazorWebAssemblyI18NAssemblies)' != 'none'">
|
||||||
|
<!--
|
||||||
|
Unless the user has asked for no-assemblies, copy all I18N assemblies to the build output.
|
||||||
|
We do not want to decipher the linker's format for passing in I18N options in our build targets
|
||||||
|
-->
|
||||||
|
<_BlazorResolvedAssemblyUnlinked Include="$(ComponentsWebAssemblyBaseClassLibraryPath)I18N*.dll" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Workaround for https://github.com/dotnet/aspnetcore/issues/19926. Using the files from their initial locations
|
Workaround for https://github.com/dotnet/aspnetcore/issues/19926. Using the files from their initial locations
|
||||||
as-is causes RazorSDK to remove files from a hosted app's publish directory. This is because files being removed
|
as-is causes RazorSDK to remove files from a hosted app's publish directory. This is because files being removed
|
||||||
|
|
|
||||||
|
|
@ -276,6 +276,55 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Build
|
||||||
Assert.Contains("ja/standalone.resources.dll", satelliteResources["ja"].Keys);
|
Assert.Contains("ja/standalone.resources.dll", satelliteResources["ja"].Keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Build_WithI8NOption_CopiesI8NAssembliesWithoutLinkerEnabled()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var project = ProjectDirectory.Create("standalone", additionalProjects: new[] { "razorclasslibrary" });
|
||||||
|
project.Configuration = "Debug";
|
||||||
|
project.AddProjectFileContent(
|
||||||
|
@"
|
||||||
|
<PropertyGroup>
|
||||||
|
<BlazorWebAssemblyI18NAssemblies>other</BlazorWebAssemblyI18NAssemblies>
|
||||||
|
</PropertyGroup>");
|
||||||
|
|
||||||
|
var result = await MSBuildProcessManager.DotnetMSBuild(project);
|
||||||
|
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
|
||||||
|
var buildOutputDirectory = project.BuildOutputDirectory;
|
||||||
|
|
||||||
|
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "I18N.dll");
|
||||||
|
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "I18N.Other.dll");
|
||||||
|
// When running without linker, we copy all I18N assemblies. Look for one additional
|
||||||
|
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "I18N.West.dll");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task Build_WithI8NOption_CopiesI8NAssembliesWithLinkerEnabled()
|
||||||
|
{
|
||||||
|
// Arrange
|
||||||
|
using var project = ProjectDirectory.Create("standalone", additionalProjects: new[] { "razorclasslibrary" });
|
||||||
|
project.Configuration = "Debug";
|
||||||
|
project.AddProjectFileContent(
|
||||||
|
@"
|
||||||
|
<PropertyGroup>
|
||||||
|
<BlazorWebAssemblyEnableLinking>true</BlazorWebAssemblyEnableLinking>
|
||||||
|
<BlazorWebAssemblyI18NAssemblies>other</BlazorWebAssemblyI18NAssemblies>
|
||||||
|
</PropertyGroup>");
|
||||||
|
|
||||||
|
var result = await MSBuildProcessManager.DotnetMSBuild(project);
|
||||||
|
|
||||||
|
Assert.BuildPassed(result);
|
||||||
|
|
||||||
|
var buildOutputDirectory = project.BuildOutputDirectory;
|
||||||
|
|
||||||
|
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "I18N.dll");
|
||||||
|
Assert.FileExists(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "I18N.Other.dll");
|
||||||
|
Assert.FileDoesNotExist(result, buildOutputDirectory, "wwwroot", "_framework", "_bin", "I18N.West.dll");
|
||||||
|
}
|
||||||
|
|
||||||
private static GenerateBlazorBootJson.BootJsonData ReadBootJsonData(MSBuildResult result, string path)
|
private static GenerateBlazorBootJson.BootJsonData ReadBootJsonData(MSBuildResult result, string path)
|
||||||
{
|
{
|
||||||
return JsonSerializer.Deserialize<GenerateBlazorBootJson.BootJsonData>(
|
return JsonSerializer.Deserialize<GenerateBlazorBootJson.BootJsonData>(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue