Fix ILLink.Substitutions.xml Warnings during Blazor build (#40051)
authorEric Erhardt <eric.erhardt@microsoft.com>
Thu, 30 Jul 2020 17:35:09 +0000 (12:35 -0500)
committerGitHub <noreply@github.com>
Thu, 30 Jul 2020 17:35:09 +0000 (12:35 -0500)
commite872afcc9184a0c74e15f23cd798cf337d91aa4b
tree9762ece0a2b96b1690113806b5690a4635ec3610
parent1e23a0629617ab18e259872f8fbb11d3f49efc2d
Fix ILLink.Substitutions.xml Warnings during Blazor build (#40051)

* Fix ILLink warning for System.Runtime.Serialization.Formatters

LocalAppContextSwitches is getting trimmed from the Browser specific assembly since it is unused. However, we still have an ILLink.Substitutions.xml file referencing it, causing the warning.

The fix is to only include the ILLink.Substitutions.xml file for the non-Browser build.

* Fix ILLink warning in System.Runtime.InteropServices.JavaScript

When building for Browser, the Runtime.InteropServices.JavaScript assembly doesn't use the System.SR type which causes the ILLinker to trim it during the dotnet/runtme build. But since System.SR is used for the AnyOS build we are generating an ILLink.Substitutions.xml file telling the linker to remove the System.SR type. This causes a warning during the Blazor app build because the Type doesn't exist in the assembly, but the XML file references it.

The fix is to not create an System.SR Type, nor embed the resources file, for the Browser build. This will need to be undone once a string is used in the Browser build.
src/libraries/System.Runtime.InteropServices.JavaScript/src/System.Runtime.InteropServices.JavaScript.csproj
src/libraries/System.Runtime.Serialization.Formatters/src/ILLink/ILLink.Substitutions.NonBrowser.xml [moved from src/libraries/System.Runtime.Serialization.Formatters/src/ILLink/ILLink.Substitutions.xml with 100% similarity]
src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj