Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 0 additions & 2 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@

<!-- https://github.com/dotnet/runtime/issues/125495 - These tests are disabled on browser/CoreCLR because of crashes and test failures. -->
<ItemGroup Condition="'$(TargetOS)' == 'browser' and '$(RuntimeFlavor)' == 'CoreCLR' and '$(RunDisabledWasmTests)' != 'true'">
<!-- test failures -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Formats.Nrbf\tests\System.Formats.Nrbf.Tests.csproj" />
<!-- long running suites -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Linq\tests\System.Linq.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Memory\tests\System.Memory.Tests.csproj" />
Expand Down
34 changes: 34 additions & 0 deletions src/mono/browser/build/BrowserWasmApp.CoreCLR.targets
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,40 @@
'$(WasmBuildingForNestedPublish)' != 'true' and
'$(UsingBrowserRuntimeWorkload)' != 'true'" />

<!-- ======================== Prefer app-local assemblies over runtime-pack copies ========================

For a self-contained browser-wasm app, @(ReferenceCopyLocalPaths) can contain two copies of the
same assembly: the runtime-pack copy (under $(MicrosoftNetCoreAppRuntimePackDir)) and an app-local
copy referenced out-of-band at a different version. ComputeWasmBuildAssets dedupes the webcil bundle
candidates by relative path (first-wins, version-blind), so the runtime-pack copy can shadow the
app-local one in _framework. The canonical case is System.Runtime.Serialization.Formatters: the
shared framework ships a non-functional 8.1.0.0 stub while the app references the functional 11.0.0.0
build, so an Assembly.Load for 11.0.0.0 then fails with FileNotFoundException.

Resolve it the way a self-contained app loads assemblies (copy-local wins): drop runtime-pack copies
shadowed by a same-named app-local copy before the candidates are gathered. Apps without an app-local
copy of a framework assembly are unaffected.
-->
<Target Name="_CoreCLRPreferAppLocalAssembliesOverRuntimePack"
BeforeTargets="_ComputeWasmBuildCandidates;_GatherWasmFilesToBuild"
Condition="'$(IsBrowserWasmProject)' == 'true' and '$(MicrosoftNetCoreAppRuntimePackDir)' != ''">
<ItemGroup>
<!-- App-local (non-runtime-pack) managed assemblies copied next to the app. -->
<_CoreCLRAppLocalAssembly Include="@(ReferenceCopyLocalPaths)"
Condition="'%(Extension)' == '.dll' and !$([System.String]::Copy('%(FullPath)').StartsWith('$(MicrosoftNetCoreAppRuntimePackDir)'))" />
</ItemGroup>
<PropertyGroup>
<_CoreCLRAppLocalAssemblyNames>;@(_CoreCLRAppLocalAssembly->'%(FileName)%(Extension)');</_CoreCLRAppLocalAssemblyNames>
</PropertyGroup>
<ItemGroup>
<!-- Drop runtime-pack copies shadowed by a same-named app-local assembly. -->
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)"
Condition="'%(Extension)' == '.dll'
and $([System.String]::Copy('%(FullPath)').StartsWith('$(MicrosoftNetCoreAppRuntimePackDir)'))
and $(_CoreCLRAppLocalAssemblyNames.Contains(';%(FileName)%(Extension);'))" />
</ItemGroup>
</Target>
Comment on lines +195 to +213

<!-- ======================== Core Orchestrator ======================== -->

<PropertyGroup>
Expand Down
Loading