Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try xamarin/xamarin-android-tools#196 #7501

Merged
merged 13 commits into from
Nov 18, 2022
Merged

Conversation

jonpryor
Copy link
Member

Context: dotnet/android-tools#196

Does It Build™?

@jonpryor
Copy link
Member Author

jonpryor commented Nov 1, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6904461&view=logs&j=cac0e8d3-0ef5-5d2b-b57e-e8fde7204df3&t=d8447b4e-561a-55bf-52c2-03d87ae8f26c

The **run Smoke MSBuild Tests - Windows Build Tree** step is failing:

```
NUnit.Engine.NUnitEngineException : An exception occurred in the driver while loading tests.
  ----> System.IO.FileLoadException : Could not load file or assembly 'nunit.framework, Version=3.13.2.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
--NUnitEngineException
An exception occurred in the driver while loading tests.
…
```

No idea why this would be failing; it doesn't make sense to me.

My only *guess* is that we have two different nunit.framework
package versions being pulled in -- which is TRUE -- and that is
screwing things up -- which I'm not sure I can understand.

Regardless, update the NUnit-related package versions that
`Xamarin.Android.Tools.Aidl-Tests.csproj` uses so that it is
consistent with the other package versions in the repo.
*Windows* smoke tests crash ~instantly:

https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6930346&view=ms.vss-test-web.build-test-results-tab&runId=60074246&resultId=100047&paneView=debug

```
System.TypeInitializationException : The type initializer for 'Xamarin.ProjectTools.XamarinAndroidCommonProject' threw an exception.
----> System.TypeInitializationException : The type initializer for 'SixLabors.ImageSharp.Configuration' threw an exception.
----> System.IO.FileLoadException : Could not load file or assembly 'System.Memory, Version=4.0.1.1, 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)
   at Xamarin.ProjectTools.XamarinAndroidCommonProject..ctor(String debugConfigurationName, String releaseConfigurationName)
   at Xamarin.ProjectTools.XamarinAndroidApplicationProject..ctor(String debugConfigurationName, String releaseConfigurationName, String packageName) in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Android\XamarinAndroidApplicationProject.cs:line 41
   at Xamarin.Android.Build.Tests.PackagingTest.CheckSignApk(Boolean useApkSigner, Boolean perAbiApk) in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\PackagingTest.cs:line 381
--TypeInitializationException
   at SixLabors.ImageSharp.Image.Load(Stream stream, IImageFormat& format)
   at Xamarin.ProjectTools.XamarinAndroidCommonProject..cctor() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Android\XamarinAndroidCommonProject.cs:line 40
--FileLoadException
   at SixLabors.ImageSharp.Configuration..ctor(IConfigurationModule[] configurationModules)
   at SixLabors.ImageSharp.Configuration.CreateDefaultInstance()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at SixLabors.ImageSharp.Configuration..cctor()
```

Not sure what exactly broke it, but we need to try to fix it.

Complicating the "fix" side of things, I can't build `xabuild.exe`
on Windows right now, so I'm flying blind here.

Update System.Collections.Immutable to 7.0.0 (latest; why not?).

Update SixLabors.ImageSharp to 2.1.3.

I hope this is the actual fix, because `SixLabors.ImageSharp.dll`
v2.1.3 no longer *references* `System.Memory.dll`, so failure to
find the assembly should be fine!  (Right?  Right?!)
Comment on lines 41 to 42
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="6.0.0.0" />
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="7.0.0.0" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating this file is tricky, I usually look at entries in:

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

VS 2022 17.4 says:

<dependentAssembly>
  <assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
  <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated this because I updated the System.Collections.Immutable NuGet package version, which i suppose I shouldn't do.

@@ -25,8 +25,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe don't update SixLabors.ImageSharp, as they depend on an older System.Memory?

https://www.nuget.org/packages/SixLabors.ImageSharp/2.1.3#dependencies-body-tab

I also heard that package is dropping out of the .NET foundation -- so I'm not sure if the license is going to change on newer versions.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was the 3rd commit in this PR which updated SixLabors.ImageSharp. We had similar errors about System.Memory before updating this package; this package was updated to attempt to fix those errors. See 24d5280.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the ImageSharp error...

It seems like the only way to fix is to add an assembly binding redirect to nunit3-console.exe.config. Which feels really weird...

Maybe it would be better to remove ImageSharp and use something else? Do we just use it in a test?

See also: 24d5280

There does not appear to be an easy way to get SixLabors.ImageSharp
working with updated NuGet dependencies, and I wonder… why do we need it?

We use SixLabors.ImageSharp to resize an image for different sizes,
but do we *need* the images to be different sizes?  Or would anything
break if they were all the *same* size?

Try it!  Use the same icon data for all image sizes.
@jonpryor
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Pull request contains merge conflicts.

Commit 90c51a0 "worked" in that we no
longer got insta-crashes because of resolving System.Memory, a'la
24d5280.

It failed in that it introduces a unit test failure in
`CheckLintErrorsAndWarnings()`:

    Output should not contain any XA0102 warnings

Which contains:

    warning XA0102: The image icon.png varies significantly in its density-independent (dip) size across the various density versions: drawable-hdpi/icon.png: 32x32 dp (48x48 px), drawable-mdpi/icon.png: 48x48 dp (48x48 px), drawable-xhdpi/icon.png: 24x24 dp (48x48 px), drawable-xxhdpi/icon.png: 16x16 dp (48x48 px), drawable-xxxhdpi/icon.png: 12x12 dp (48x48 px) [IconDipSize]

Doh!

Ignoring *that* for now, the Windows smoke tests continue to fail,
now because of System.Runtime.CompilerServices.Unsafe!

    System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    ----> System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
       at System.MemoryExtensions.AsSpan(String text)
       at Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, UsedUninitializedProperties usedUnInitializedProperties, IFileSystem fileSystem)
       at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
       at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
       at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
       at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
       at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
       at Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
       at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
       at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
       at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
       at Microsoft.Build.Evaluation.ToolsetReader.<ReadAllToolsets>g__ReadConfigToolset|12_0(<>c__DisplayClass12_0& )
       at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
       at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
       at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly, Boolean useAsynchronousLogging)
       at Microsoft.Build.Evaluation.ProjectCollection.get_GlobalProjectCollection()
       at Xamarin.ProjectTools.DotNetXamarinProject.Construct() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Common\DotNetXamarinProject.cs:line 101
       at Xamarin.ProjectTools.XamarinAndroidCommonProject.Construct() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Android\XamarinAndroidCommonProject.cs:line 53
       at Xamarin.ProjectTools.DotNetXamarinProject.SaveProject() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Common\DotNetXamarinProject.cs:line 141
       at Xamarin.ProjectTools.XamarinProject.Save(Boolean saveProject) in C:\a\_work\

Address a comment by @jonathanpeppers that the contents of the
App.config files should match MSBuild.exe.config from VS, and
revert the System.Collections.Immutable version bump back to 6.0.0.
Additionally, ensure all `App.config` files are consistent with
each other, which means updating versinos in
`src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/App.config`.

Maybe *now* Windows' smoke tests can run?  Maybe?
Commit 1d38470 worked, in that we
no longer get insta-crashes on Windows!
The `System.Runtime.CompilerServices.Unsafe` crash was fixed!

We now turn our attention to the XA0102 warnings, which are *also*
responsible for errors in `BuildReleaseArm64()`, because the `.apk`
size now differs, because the icons are now larger; `.apk` size
increased by 31,744 bytes!

…which is why SixLabors.ImageSharp was used…

Avoid SixLabors.ImageSharp and instead have
`Xamarin.ProjectTools` use the same icons as the
`dotnet new android` template, in
`src\Microsoft.Android.Templates\android\Resources\**\appicon.png`.
In order to ensure sane `%(LogicalName)` values, `%(RecrusiveDir)`
is used as part of the logical name, resulting in resource names
on macOS such as:

  * `mipmap-hdpi/appicon.png`
  * `mipmap-mdpi/appicon.png`
  * `mipmap-xhdpi/appicon.png`
  * `mipmap-xxhdpi/appicon.png`
  * `mipmap-xxxhdpi/appicon.png`

I'm not sure what Windows will do offhand, so have
Xamarin.ProjectTools.dll *also* look for a resource name with
`/` replaced by `\` (`Path.DirectorySeparatorChar`) so that this
logic *should* work on Windows as well.

Hopefully this will resolve the XA0102 warnings and the
`BuildReleaseArm64()` errors.
jonpryor and others added 4 commits November 17, 2022 15:01
7db57b1 looks better, but we now
have a *different* set of XA0102 warnings!

	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]
	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]
	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]
	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]

Apparently the `appicon.png` files we're using are "wrong".

I regenerated these files with <https://romannurik.github.io/AndroidAssetStudio/>
-- in particular, I think the "Shape (Legacy)" setting should be "Circle"? --
and am updating the files.
Commits 2d6afda &
69fa552 result in smaller
`.png` resources, which causes the `.apk` size to shrink, e.g.

	Summary:

	…
	 28,672 Package size difference -0.30% (of 9,549,982)
	stdErr: Error: apkdiff: PackageSize decrease 28,672 is 23,552 bytes more than the threshold 5,120. apk1 size: 9,549,982 bytes, apk2 size: 9,521,310 bytes.
	Error: apkdiff: Size regression occured, 1 check(s) failed.

Update the .apkdesc files so that the tests pass.
@jonpryor jonpryor marked this pull request as ready for review November 18, 2022 02:09
@jonpryor jonpryor requested a review from dellis1972 as a code owner November 18, 2022 02:09
@jonpryor
Copy link
Member Author

jonpryor commented Nov 18, 2022

Commit message:

Bump to xamarin/xamarin-android-tools/main@fa3711b (#7501)

(It's just NuGet package bumps!  How hard could it be? 🙃)

Changes: https://github.com/xamarin/xamarin-android-tools/compare/59cac909fa8921cf09084a92918a5b7bca726d62...fa3711b7ddac7cea6850a9c1c67beda1996aafc0

  * amarin/xamarin-android-tools@fa3711b: [build] Update NuGet package versions (amarin/xamarin-android-tools#196)

What *are* the NuGet package version bumps in
xamarin/xamarin-android-tools@fa3711b?

> NuGet Package Version Bumps:
> 
>   * Microsoft.Build                     : `16.10.0`   -> `17.3.2`
>   * Microsoft.Build.Framework           : `16.10.0`   -> `17.3.2`
>   * Microsoft.Build.Tasks.Core          : `16.10.0`   -> `17.3.2`
>   * Microsoft.Build.Utilities.Core      : `16.10.0`   -> `17.3.2`
>   * Microsoft.NET.Test.Sdk              : `16.5.0`    -> `17.5.0-preview-20221003-04`
>   * nunit                               : `3.12.0`    -> `3.13.2`
>   * NUnit3TestAdapter                   : `3.16.1`    -> `4.0.0`

The `nunit` and `NUnit3TestAdapter` versions differed from what
`Xamarin.Android.Tools.Aidl-Tests.csproj` was using, which resulted
in some tests failing with:

	NUnit.Engine.NUnitEngineException : An exception occurred in the driver while loading tests.
	  ----> System.IO.FileLoadException : Could not load file or assembly 'nunit.framework, Version=3.13.2.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' or one of its dependencies.
	    The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
	--NUnitEngineException
	An exception occurred in the driver while loading tests.

Fix by harmonizing `nunit` and `NUnit3TestAdapter` package versions.

Then came a fair bit of time trying to get the
`SixColors.ImageSharp` NuGet package working with the updated
packages, in particular the new `Microsoft.Build*` packages:

	System.TypeInitializationException : The type initializer for 'Xamarin.ProjectTools.XamarinAndroidCommonProject' threw an exception.
	----> System.TypeInitializationException : The type initializer for 'SixLabors.ImageSharp.Configuration' threw an exception.
	----> System.IO.FileLoadException : Could not load file or assembly 'System.Memory, Version=4.0.1.1, 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)
	   at Xamarin.ProjectTools.XamarinAndroidCommonProject..ctor(String debugConfigurationName, String releaseConfigurationName)
	   at Xamarin.ProjectTools.XamarinAndroidApplicationProject..ctor(String debugConfigurationName, String releaseConfigurationName, String packageName) in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Android\XamarinAndroidApplicationProject.cs:line 41
	   at Xamarin.Android.Build.Tests.PackagingTest.CheckSignApk(Boolean useApkSigner, Boolean perAbiApk) in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.Android.Build.Tests\PackagingTest.cs:line 381
	--TypeInitializationException
	   at SixLabors.ImageSharp.Image.Load(Stream stream, IImageFormat& format)
	   at Xamarin.ProjectTools.XamarinAndroidCommonProject..cctor() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Android\XamarinAndroidCommonProject.cs:line 40
	--FileLoadException
	   at SixLabors.ImageSharp.Configuration..ctor(IConfigurationModule[] configurationModules)
	   at SixLabors.ImageSharp.Configuration.CreateDefaultInstance()
	   at System.Lazy`1.CreateValue()
	   at System.Lazy`1.LazyInitValue()
	   at SixLabors.ImageSharp.Configuration..cctor()

I could not figure out a way to make `SixColors.ImageSharp` work with
the other newer NuGet package versions.

*Remove* use of `SixColors.ImageSharp`, and instead have
`Xamarin.ProjectTools.dll` reference the various `.png` resources
contained in the `dotnet new android` template.

…which sounded like a good idea, except those resources caused XA0102
warnings when validating with lint (?!):

	dotnet new android -n lint-check
	cd lint-check
	dotnet build -p:AndroidLintEnabled=True \
	  "-p:AndroidLintDisabledIssues=StaticFieldLeak%2cObsoleteSdkInt%2cAllowBackup%2cExportedReceiver%2cRedundantLabel"

results in:

	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]
	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]
	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]
	warning XA0102: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]

(Note use of hex-encoded `,` as `%2c` so that
`$(AndroidLintDisabledIssues)` can be specified on the command-line.)

Update the `appicon.png` resources in
`src/Microsoft.Android.Templates/android` so that these lint warnings
are no longer generated.  This in turn requires updating various
`.apkdesc` files, as the new `appicon.png` files are smaller than the
images produced by `SixColors.ImageSharp`, resultling in smaller
`.apk` files in our unit tests.

Then we hit a set of assembly resolution errors around
`System.Runtime.CompilerServices.Unsafe`:

	System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
	----> System.IO.FileLoadException : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
	   at System.MemoryExtensions.AsSpan(String text)
	   at Microsoft.Build.Evaluation.Expander`2.Function`1.ExtractPropertyFunction(String expressionFunction, IElementLocation elementLocation, Object propertyValue, UsedUninitializedProperties usedUnInitializedProperties, IFileSystem fileSystem)
	   at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertyBody(String propertyBody, Object propertyValue, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
	   at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveTypedAndEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
	   at Microsoft.Build.Evaluation.Expander`2.PropertyExpander`1.ExpandPropertiesLeaveEscaped(String expression, IPropertyProvider`1 properties, ExpanderOptions options, IElementLocation elementLocation, UsedUninitializedProperties usedUninitializedProperties, IFileSystem fileSystem)
	   at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation)
	   at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander)
	   at Microsoft.Build.Evaluation.ToolsetReader.EvaluateAndSetProperty(ToolsetPropertyDefinition property, PropertyDictionary`1 properties, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& toolsPath, String& binPath, Expander`2& expander)
	   at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
	   at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties)
	   at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion)
	   at Microsoft.Build.Evaluation.ToolsetReader.<ReadAllToolsets>g__ReadConfigToolset|12_0(<>c__DisplayClass12_0& )
	   at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations)
	   at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader)
	   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly, Boolean useAsynchronousLogging)
	   at Microsoft.Build.Evaluation.ProjectCollection.get_GlobalProjectCollection()
	   at Xamarin.ProjectTools.DotNetXamarinProject.Construct() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Common\DotNetXamarinProject.cs:line 101
	   at Xamarin.ProjectTools.XamarinAndroidCommonProject.Construct() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Android\XamarinAndroidCommonProject.cs:line 53
	   at Xamarin.ProjectTools.DotNetXamarinProject.SaveProject() in C:\a\_work\1\s\src\Xamarin.Android.Build.Tasks\Tests\Xamarin.ProjectTools\Common\DotNetXamarinProject.cs:line 141
	   at Xamarin.ProjectTools.XamarinProject.Save(Boolean saveProject) in C:\a\_work\

Resolve these errors by updating the various `App.config` files so
that they use `<bindingRedirect/>` versions which match
`MSBuild.exe.config` in Visual Studio, and ensure that the referenced
NuGet packages use the same versions as the `<bindingRedirect/>`.

NuGet Package Version Bumps:

  * Microsoft.NET.Test.Sdk                      : `16.*`      -> `17.5.0-preview-20221003-04`
  * Microsoft.Win32.Registry                    : `4.7.0`     -> `5.0.0`
  * nunit                                       : `3.12.0`    -> `3.13.2`
  * NUnit.ConsoleRunner                         : `3.11.1`    -> `3.12.0`
  * NUnit3TestAdapter                           : `3.16.1`    -> `4.0.0`
  * System.CodeDom                              : `4.7.0`     -> `6.0.0`
  * System.Configuration.ConfigurationManager   : `4.7.0`     -> `6.0.1`
  * System.Reflection.Metadata                  : `1.8.0`     -> `6.0.1`

Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>

@jonpryor jonpryor merged commit 4221c07 into dotnet:main Nov 18, 2022
grendello added a commit to grendello/xamarin-android that referenced this pull request Nov 18, 2022
* main:
  Bump to xamarin/xamarin-android-tools/main@fa3711b (dotnet#7501)
grendello added a commit to grendello/xamarin-android that referenced this pull request Nov 18, 2022
* main:
  Bump to xamarin/xamarin-android-tools/main@fa3711b (dotnet#7501)
grendello added a commit to grendello/xamarin-android that referenced this pull request Nov 21, 2022
* main:
  Bump to xamarin/xamarin-android-tools/main@fa3711b (dotnet#7501)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants