Skip to content

Commit

Permalink
[build] update binding redirects for MSBuild 17.3
Browse files Browse the repository at this point in the history
`xabuild Xamarin.Android-Tests.sln` was failing with:

    MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
    System.IO.FileLoadException: Could not load file or assembly 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    File name: 'System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
    at Microsoft.Build.Shared.FileUtilities.LooksLikeUnixFilePath(String value, String baseDirectory)
    at Microsoft.Build.CommandLine.MSBuildApp.GatherCommandLineSwitches(List`1 commandLineArgs, CommandLineSwitches commandLineSwitches, String commandLine)
    at Microsoft.Build.CommandLine.MSBuildApp.GatherAllSwitches(String commandLine, CommandLineSwitches& switchesFromAutoResponseFile, CommandLineSwitches& switchesNotFromAutoResponseFile)
    at Microsoft.Build.CommandLine.MSBuildApp.Execute(String commandLine)

This appears to be happening on Windows build machines running VS 2022
17.3 and MSBuild 17.3.

I did an audit comparing xabuild's `App.config` file with:

    C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe.config

We needed to update specifically to:

* System.Memory 4.5.5
* System.Collections.Immutable 6.0.0
* System.Runtime.CompilerServices.Unsafe 6.0.0

Note that in some cases the NuGet package version doesn't match the
assembly version.

After these changes, I can build `xabuild` locally with MSBuild 17.3,
and then also build Xamarin.Android projects.
  • Loading branch information
jonathanpeppers committed Aug 17, 2022
1 parent a607cf8 commit 13fdb2b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions tools/xabuild/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="1.2.5.0" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.1.2" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand All @@ -51,7 +57,7 @@
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="4.0.6.0" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
5 changes: 3 additions & 2 deletions tools/xabuild/xabuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
<Import Project="..\..\Configuration.props" />
<ItemGroup>
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<Reference Include="MSBuild">
<HintPath>$(MSBuildToolsPath)\MSBuild.$(_MSBuildExtension)</HintPath>
Expand Down

0 comments on commit 13fdb2b

Please sign in to comment.