Skip to content

[build] Bump to Mono with MSBuild 16.10 - #6014

Merged
pjcollins merged 1 commit into
dotnet:mainfrom
pjcollins:mono-msbuild-16.10
Jun 21, 2021
Merged

[build] Bump to Mono with MSBuild 16.10#6014
pjcollins merged 1 commit into
dotnet:mainfrom
pjcollins:mono-msbuild-16.10

Conversation

@pjcollins

@pjcollinspjcollins commented Jun 9, 2021

Copy link
Copy Markdown
Member

Changes: https://github.com/xamarin/monodroid/compare/1f2ce156245ef1bf63ec8014882d283b3224216b...36536006a74d9fa9b08b14301f73b2e7da93d75d

  • xamarin/monodroid@d111a7a: [tools/msbuild] Add additional fallbacks to GetPrimaryCpuAbi.
  • xamarin/monodroid@3653600: Bump to xamarin/androidtools@14e679e and ee49249

Changes: dotnet/android-tools@49936d6...c055fa8

We've been seeing a NuGet restore issue when running prepare on a macOS
system with .NET 6 Preview 4 (or greater) installed:

Restoring packages for /Users/peter/source/java.interop/tools/logcat-parse/logcat-parse.csproj...
NU1202: Package Mono.CSharp 4.0.0.143 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Mono.CSharp 4.0.0.143 supports: net45 (.NETFramework,Version=v4.5)
...
Errors in /Users/peter/source/java.interop/tools/logcat-parse/logcat-parse.csproj
NU1202: Package Mono.CSharp 4.0.0.143 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Mono.CSharp 4.0.0.143 supports: net45 (.NETFramework,Version=v4.5)

I have encountered other issues with .NET 6 Preview 4 and greater when
building some projects targeting net6.0:

Version 'x' of the .NET Core SDK requires at least version 16.10.0 of MSBuild. The current available version of MSBuild is 16.9.0. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.

These issues should be addressed by using MSBuild 16.10 on macOS.

@pjcollins
pjcollins marked this pull request as ready for review June 9, 2021 21:58
@pjcollins
pjcollins requested a review from jonpryor as a code ownerJune 9, 2021 21:58
@pjcollins
pjcollins marked this pull request as draft June 9, 2021 22:01
@pjcollins

Copy link
Copy Markdown
MemberAuthor

The windows issues are likely a result of: https://github.com/xamarin/xamarin-android-tools/blob/bdcf899968d6549fd07917819d295f0feb0db562/src/Microsoft.Android.Build.BaseTasks/MSBuildReferences.projitems#L21-L38. We copy some MSBuild assemblies from the Mono installation to our test output directory when building our MSBuild tests. We then upload the test assemblies from the macOS build and use them on both macOS and Windows environments.

@jonathanpeppersjonathanpeppers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If the error we get is:

System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack trace
at Microsoft.Build.Evaluation.Expander`2.MetadataExpander.ExpandMetadataLeaveEscaped(String expression, IMetadataTable metadata, ExpanderOptions options, IElementLocation elementLocation)
at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Evaluation/Expander.cs:line 414
at Microsoft.Build.Evaluation.ToolsetReader.ExpandPropertyUnescaped(ToolsetPropertyDefinition property, Expander`2 expander) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ToolsetReader.cs:line 683
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) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ToolsetReader.cs:line 659
at Microsoft.Build.Evaluation.ToolsetReader.ReadToolset(ToolsetPropertyDefinition toolsVersion, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ToolsetReader.cs:line 456
at Microsoft.Build.Evaluation.ToolsetReader.ReadEachToolset(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ToolsetReader.cs:line 423
at Microsoft.Build.Evaluation.ToolsetReader.ReadToolsets(Dictionary`2 toolsets, PropertyDictionary`1 globalProperties, PropertyDictionary`1 initialProperties, Boolean accumulateProperties, String& msBuildOverrideTasksPath, String& defaultOverrideToolsVersion) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ToolsetReader.cs:line 357
at Microsoft.Build.Evaluation.ToolsetReader.ReadAllToolsets(Dictionary`2 toolsets, ToolsetRegistryReader registryReader, ToolsetConfigurationReader configurationReader, PropertyDictionary`1 environmentProperties, PropertyDictionary`1 globalProperties, ToolsetDefinitionLocations locations) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ToolsetReader.cs:line 144
at Microsoft.Build.Evaluation.ProjectCollection.InitializeToolsetCollection(ToolsetRegistryReader registryReader, ToolsetConfigurationReader configReader) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ProjectCollection.cs:line 1763
at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ProjectCollection.cs:line 362
at Microsoft.Build.Evaluation.ProjectCollection.get_GlobalProjectCollection() in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Definition/ProjectCollection.cs:line 420
at Xamarin.ProjectTools.DotNetXamarinProject.Construct() in /Users/builder/azdo/_work/1/s/xamarin-android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Common/DotNetXamarinProject.cs:line 97
at Xamarin.ProjectToo...

Can you try updating xamarin-android-tools to use 16.10?

https://www.nuget.org/packages/Microsoft.Build/16.10.0

jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Jun 10, 2021
Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4857598&view=logs&j=fb3518d4-6415-56d8-56e7-3e01113bd696&t=339edcd9-c55f-51d5-0409-e3f1c4277c4d
Context: https://discord.com/channels/732297728826277939/732297837953679412/852637194221125683
Context: dotnet#6014
Looks like dotnet#6014 attempted to bump to a system
mono, and that bump broke ~everything:
226) Error : Xamarin.Android.Build.Tests.SingleProjectTest.AndroidManifestProperties
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.Build.Evaluation.Expander`2.MetadataExpander.ExpandMetadataLeaveEscaped(String expression, IMetadataTable metadata, ExpanderOptions options, IElementLocation elementLocation)
at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Evaluation/Expander.cs:line 414
…
Set `$(MonoRequiredMaximumVersion)` to 6.12.0.137, to *constrain*
which system mono we use. Hopefully this will "un-bork" CI.
jonpryor added a commit that referenced this pull request Jun 11, 2021
Xamarin.Android v11.4.0 will be shipped as part of
Visual Studio 2019 16.11 Preview 3 and subsequent releases.
Changes: https://github.com/xamarin/monodroid/compare/76c04cd15eca7afc269a6d26296e9d2db6f79be2...fab2d0b3e5205cb97d03e7a33a367245dbd211aa
* xamarin/monodroid@fab2d0b3e: Branching for d16-11. (#1209)
Update `azure-pipelines.yaml` so that the macOS Designer Tests use
the xamarin/UITools/d16-10 branch, *not* the default d16-11 branch.
Using the UITools/d16-11 branch results in build errors:
/Users/runner/work/1/s/UITools/Designer/external/Xamarin.PropertyEditing/Xamarin.PropertyEditing.Mac/Controls/BaseDateTimeEditorControl.cs(2,7):
error CS0246: The type or namespace name 'AppKit' could not be found (are you missing a using directive or an assembly reference?)
[/Users/runner/work/1/s/UITools/Designer/external/Xamarin.PropertyEditing/Xamarin.PropertyEditing.Mac/Xamarin.PropertyEditing.Mac.csproj]
…plus 931 other errors…
Finally, constrain mono to v6.12.0.137 by updating
`$(MonoRequiredMaximumVersion)`. This is done to "work around" some
unit test errors we observed because #6014 had
updated the system mono:
226) Error : Xamarin.Android.Build.Tests.SingleProjectTest.AndroidManifestProperties
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.Build.Evaluation.Expander`2.MetadataExpander.ExpandMetadataLeaveEscaped(String expression, IMetadataTable metadata, ExpanderOptions options, IElementLocation elementLocation)
at Microsoft.Build.Evaluation.Expander`2.ExpandIntoStringLeaveEscaped(String expression, ExpanderOptions options, IElementLocation elementLocation) in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/msbuild-15/src/Build/Evaluation/Expander.cs:line 414
…
Limiting system mono to 6.12.0.137 prevents these errors.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this pull request Jun 11, 2021
Context: dotnet#6014
We are occasionally seeing test failures with many forms of:
Could not load file or assembly 'Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
This seems to be caused by Mono 6.12.0.145 installed on some of the
build machines.
We can undo this change when dotnet#6014 goes in.
jonpryor pushed a commit that referenced this pull request Jun 14, 2021
Context: #6014
We are occasionally seeing test failures with many forms of:
Could not load file or assembly 'Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
This seems to be caused by Mono 6.12.0.145 installed on some of the
build machines.
We can undo this change when #6014 goes in.
@pjcollins

Copy link
Copy Markdown
MemberAuthor

Can you try updating xamarin-android-tools to use 16.10?

I'm still seeing dotnet/msbuild#2554 on macOS when using MSBuild 16.10.0 NuGet packages, so I think we'll still need some OS specific logic for now...

@pjcollins

Copy link
Copy Markdown
MemberAuthor

The workaround to set the MSBUILD_EXE_PATH environment variable seemed to work for me locally, lets see how far this gets with that and the changes in https://github.com/xamarin/xamarin-android-tools/compare/msbuild-16.9?expand=1.

@pjcollins
pjcollinsforce-pushed the mono-msbuild-16.10 branch 4 times, most recently from 43978ee to 7290658CompareJune 16, 2021 20:54
grendello pushed a commit to grendello/xamarin-android that referenced this pull request Jun 16, 2021
Context: dotnet#6014
We are occasionally seeing test failures with many forms of:
Could not load file or assembly 'Microsoft.NET.StringTools, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
This seems to be caused by Mono 6.12.0.145 installed on some of the
build machines.
We can undo this change when dotnet#6014 goes in.
@dellis1972

Copy link
Copy Markdown
Contributor

@pjcollins I tested this branch in VSCode on Mac OS. I can still debug the MSBuild Task tests so this looks good to me :)

pjcollins added a commit to dotnet/android-tools that referenced this pull request Jun 17, 2021
Related: dotnet/android#6014
Drops the OS specific MSBuild NuGet and system references and instead
uses MSBuild 16.10.0 NuGet packages. This introduces an issue in our
usage of `Microsoft.Build.Construction.ProjectRootElement.Create` in
xamarin/xamarin-android on macOS, however we can work around it there.
Changes: http://github.com/xamarin/monodroid/compare/1f2ce156245ef1bf63ec8014882d283b3224216b...36536006a74d9fa9b08b14301f73b2e7da93d75d
* xamarin/monodroid@d111a7a: [tools/msbuild] Add additional fallbacks to GetPrimaryCpuAbi.
* xamarin/monodroid@3653600: Bump to xamarin/androidtools@14e679e and dotnet/android@ee49249
Changes: dotnet/android-tools@49936d6...c055fa8
* dotnet/android-tools@c055fa8: [Microsoft.Android.Build] Bump to MSBuild 16.10.0
We've been seeing a NuGet restore issue when running prepare on a macOS
system with .NET 6 Preview 4 (or greater) installed:
Restoring packages for /Users/peter/source/java.interop/tools/logcat-parse/logcat-parse.csproj...
NU1202: Package Mono.CSharp 4.0.0.143 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Mono.CSharp 4.0.0.143 supports: net45 (.NETFramework,Version=v4.5)
...
Errors in /Users/peter/source/java.interop/tools/logcat-parse/logcat-parse.csproj
NU1202: Package Mono.CSharp 4.0.0.143 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Mono.CSharp 4.0.0.143 supports: net45 (.NETFramework,Version=v4.5)
I have encountered other issues with .NET 6 Preview 4 and greater when
building some projects targeting net6.0:
Version 'x' of the .NET Core SDK requires at least version 16.10.0 of MSBuild. The current available version of MSBuild is 16.9.0. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
These issues should be addressed by using MSBuild 16.10 on macOS.
@pjcollins
pjcollins marked this pull request as ready for review June 21, 2021 19:10
@pjcollins

pjcollins commented Jun 21, 2021

Copy link
Copy Markdown
MemberAuthor

This should be ready to go, I think the emulator test issues against JDK 1.8 are being discussed/addressed in #6033

@pjcollins
pjcollins merged commit a45f84d into dotnet:mainJun 21, 2021
@pjcollins
pjcollins deleted the mono-msbuild-16.10 branch June 21, 2021 20:06
jonathanpeppers pushed a commit that referenced this pull request Jun 21, 2021
Changes: xamarin/monodroid@1f2ce15...3653600
* xamarin/monodroid@d111a7a: [tools/msbuild] Add additional fallbacks to GetPrimaryCpuAbi.
* xamarin/monodroid@3653600: Bump to xamarin/androidtools@14e679e and ee49249
Changes: dotnet/android-tools@49936d6...c055fa8
* dotnet/android-tools@c055fa8: [Microsoft.Android.Build] Bump to MSBuild 16.10.0
We've been seeing a NuGet restore issue when running prepare on a macOS
system with .NET 6 Preview 4 (or greater) installed:
Restoring packages for /Users/peter/source/java.interop/tools/logcat-parse/logcat-parse.csproj...
NU1202: Package Mono.CSharp 4.0.0.143 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Mono.CSharp 4.0.0.143 supports: net45 (.NETFramework,Version=v4.5)
...
Errors in /Users/peter/source/java.interop/tools/logcat-parse/logcat-parse.csproj
NU1202: Package Mono.CSharp 4.0.0.143 is not compatible with net6.0 (.NETCoreApp,Version=v6.0). Package Mono.CSharp 4.0.0.143 supports: net45 (.NETFramework,Version=v4.5)
I have encountered other issues with .NET 6 Preview 4 and greater when
building some projects targeting net6.0:
Version 'x' of the .NET Core SDK requires at least version 16.10.0 of MSBuild. The current available version of MSBuild is 16.9.0. Change the .NET Core SDK specified in global.json to an older version that requires the MSBuild version currently available.
These issues should be addressed by using MSBuild 16.10 on macOS.
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Jan 25, 2024
Sign up for freeto 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.

3 participants

@pjcollins@dellis1972@jonathanpeppers