Skip to content
New issue

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

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

Already on GitHub? # to your account

Bump to .NET 8 #7451

Merged
merged 1 commit into from
Oct 26, 2022
Merged

Bump to .NET 8 #7451

merged 1 commit into from
Oct 26, 2022

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Oct 10, 2022

Changes: dotnet/installer@11f6b8f...d552037
Changes: dotnet/linker@5f9bfd9...493ce62
Changes: dotnet/runtime@6d10e4c...b8d4980

A summary of what it took to get this working:

  • Run darc update-dependencies --id 152596

  • Setup .NET 6,7,8 "multi-targeting"

  • Setup dotnet6/dotnet7/dotnet8 NuGet feeds

  • $(DotNetTargetFrameworkVersion) should be 8.0

  • Rename API diff for net8.0

  • Fix AutoImport.props for 8.0

  • Update .apkdesc files

  • Update CheckIncludedAssemblies test

  • Use .NET Core 3.1.x

Trying to avoid:

dotnet-install: Failed to locate the latest version in the channel '3.1.417' with 'preview' quality for 'dotnet-sdk', os: 'win', architecture: 'x64'.
  • Install .NET 6 for legacy MSBuild tests

  • [Mono.Android.Export] fix NotSupportedException

Context: https://github.com/mono/mono/blob/242ac50598e4f596e1a42f9dd377701096ea3a74/mcs/class/referencesource/mscorlib/system/reflection/emit/dynamicmethod.cs#L276-L277
Context: dotnet/runtime@e465230

System.NotSupportedException: Wrong MethodAttributes or CallingConventions for DynamicMethod. Only public, static, standard supported
  • Use correct Mono pack names for $(AotAssemblies)

  • Fix DotNetPublish test

Was failing with:

Build should be using C:\a_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.Android.Ref.33\34.0.0-ci.pr.gh7451.52\ref\net7.0\Mono.Android.dll

Expected: True
But was: False

  • Remove a net7.0 assertion for build warnings

See: dotnet/runtime#77385

  • Pass -SkipNonVersionedFiles to dotnet-install scripts to avoid:

    dotnet --info
    Exited with code: 137

@jonathanpeppers jonathanpeppers force-pushed the net8.0 branch 6 times, most recently from 099a846 to e8904f6 Compare October 10, 2022 22:01
@jonpryor
Copy link
Member

prepare-20221010T181316.msbuild.xat-restore.log contains:

ls-jdks.csproj: error NU1102: Unable to find package Microsoft.NETCore.App.Host.osx-x64 with version (= 3.1.31)
ls-jdks.csproj: error NU1102:   - Found 100 version(s) in dotnet-public [ Nearest version: 5.0.0-preview.1.20120.5 ] 
ls-jdks.csproj: error NU1102:   - Found 1 version(s) in dotnet-eng [ Nearest version: 5.0.0-alpha.1.19618.1 ]

Looks like it doesn't like netcoreapp3.1? https://github.com/xamarin/xamarin-android-tools/blob/0be567a991396bd26dd2a92ee11d84fd294f57c7/tools/ls-jdks/ls-jdks.csproj#L5

@jonathanpeppers
Copy link
Member Author

.NET Core 3.1.31 is probably a servicing release that isn't out yet... The feed for it is probably internal (I'll check), but the easiest fix here is probably to update various projects to at least net6.0?

jonathanpeppers added a commit to jonathanpeppers/xamarin-android-tools that referenced this pull request Oct 11, 2022
I believe this is a good idea anyway, but this should assist with:

dotnet/android#7451

Which is hitting the error:

    error NU1102: Unable to find package Microsoft.NETCore.App.Host.osx-x64 with version (= 3.1.31)

.NET Core 3.1.31 is not released yet and is likely on a private feed.

Also pass `6.0.x` to the [`UseDotNet`][0] yaml task.

[0]: https://learn.microsoft.com/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer
jonathanpeppers added a commit to jonathanpeppers/xamarin-android-tools that referenced this pull request Oct 11, 2022
I believe this is a good idea anyway, but this should assist with:

dotnet/android#7451

Which is hitting the error:

    error NU1102: Unable to find package Microsoft.NETCore.App.Host.osx-x64 with version (= 3.1.31)

.NET Core 3.1.31 is not released yet and is likely on a private feed.

Also pass `6.0.x` to the [`UseDotNet`][0] yaml task.

After these changes, the build failed with:

    error MSB3971: The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.

Mono MSBuild probably can't build .NET 6 projects?

So I fixed various things in the build:

* Use `dotnet build` instead of MSBuild, remove NuGet commands

* No tests were running:

```
[warning] Project file(s) matching the specified pattern were not found.
```

* Fixed the path to test assemblies!

* Upload artifacts based on the

* Use `$(PackageOutputPath)` instead of `$(OutputPath)`

[0]: https://learn.microsoft.com/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer
jonathanpeppers added a commit to jonathanpeppers/xamarin-android-tools that referenced this pull request Oct 11, 2022
I believe this is a good idea anyway, but this should assist with:

dotnet/android#7451

Which is hitting the error:

    error NU1102: Unable to find package Microsoft.NETCore.App.Host.osx-x64 with version (= 3.1.31)

.NET Core 3.1.31 is not released yet and is likely on a private feed.

Also pass `6.0.x` to the [`UseDotNet`][0] yaml task.

After these changes, the build failed with:

    error MSB3971: The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.

Mono MSBuild probably can't build .NET 6 projects?

So I fixed various things in the build:

* Use `dotnet build` instead of MSBuild, remove NuGet commands
* No tests were running:
```
[warning] Project file(s) matching the specified pattern were not found.
```
* Fixed the `$(XATBuildingForNetCoreApp)` property
* Upload artifacts based on the pool name: `$(vmImage)`
* Use `$(PackageOutputPath)` instead of `$(OutputPath)`
* `PublishBuildArtifacts` is deprecated use `PublishPipelineArtifact`
* Save `.binlog` files as artifacts

[0]: https://learn.microsoft.com/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer
jonathanpeppers added a commit to dotnet/android-tools that referenced this pull request Oct 11, 2022
I believe this is a good idea anyway, but this should assist with:

dotnet/android#7451

Which is hitting the error:

    error NU1102: Unable to find package Microsoft.NETCore.App.Host.osx-x64 with version (= 3.1.31)

.NET Core 3.1.31 is not released yet and is likely on a private feed.

Also pass `6.0.x` to the [`UseDotNet`][0] yaml task.

After these changes, the build failed with:

    error MSB3971: The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher. Update Visual Studio and/or your .NET SDK.

Mono MSBuild probably can't build .NET 6 projects?

So I fixed various things in the build:

* Use `dotnet build` instead of MSBuild, remove NuGet commands

* No tests were running:

    [warning] Project file(s) matching the specified pattern were not found.

* Fixed the `$(XATBuildingForNetCoreApp)` property, so tests run.

* Upload artifacts based on the pool name: `$(vmImage)`

* Use `$(PackageOutputPath)` instead of `$(OutputPath)`

* `PublishBuildArtifacts` is deprecated use `PublishPipelineArtifact`

* Save `.binlog` files as artifacts

[0]: https://learn.microsoft.com/azure/devops/pipelines/tasks/tool/dotnet-core-tool-installer
@jonathanpeppers
Copy link
Member Author

It builds!

Now builds apps is failing with:

Microsoft.NET.TargetFrameworkInference.targets(112,5): error NETSDK1139: The target platform identifier android was not recognized.

So likely some workload issue so far.

Changes: dotnet/installer@11f6b8f...d552037
Changes: dotnet/linker@5f9bfd9...493ce62
Changes: dotnet/runtime@6d10e4c...b8d4980

A summary of what it took to get this working:

* Run `darc update-dependencies --id 152596`

* Setup .NET 6,7,8 "multi-targeting"

* Setup dotnet6/dotnet7/dotnet8 NuGet feeds

* `$(DotNetTargetFrameworkVersion)` should be 8.0

* Rename API diff for `net8.0`

* Fix `AutoImport.props` for 8.0

* Update `.apkdesc` files

* Update `CheckIncludedAssemblies` test

* Use .NET Core `3.1.x`

Trying to avoid:

    dotnet-install: Failed to locate the latest version in the channel '3.1.417' with 'preview' quality for 'dotnet-sdk', os: 'win', architecture: 'x64'.

* Install .NET 6 for legacy MSBuild tests

* [Mono.Android.Export] fix `NotSupportedException`

Context: https://github.com/mono/mono/blob/242ac50598e4f596e1a42f9dd377701096ea3a74/mcs/class/referencesource/mscorlib/system/reflection/emit/dynamicmethod.cs#L276-L277
Context: dotnet/runtime@e465230

    System.NotSupportedException: Wrong MethodAttributes or CallingConventions for DynamicMethod. Only public, static, standard supported

* Use correct Mono pack names for `$(AotAssemblies)`

* Fix `DotNetPublish` test

Was failing with:

    Build should be using C:\a_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.Android.Ref.33\34.0.0-ci.pr.gh7451.52\ref\net7.0\Mono.Android.dll
Expected: True
But was:  False

* Remove a `net7.0` assertion for build warnings

See: dotnet/runtime#77385

* Pass `-SkipNonVersionedFiles` to `dotnet-install` scripts to avoid:

   dotnet --info
   Exited with code: 137
@jonathanpeppers
Copy link
Member Author

The past run was pretty much green, I squashed/rebased this to clean it up.

Copy link
Contributor

@dellis1972 dellis1972 left a comment

Choose a reason for hiding this comment

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

This all looks good if the build is green :)
Can we run the nightly's as well before we merge?

@jonathanpeppers
Copy link
Member Author

Here is a nightly run, if I did it right:

https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6872423&view=results

I did branch refs/pull/7451/head, and commit 5861cc818d0c9ab968aac1dfbcf3af2f328d42e5. I rebased this with main this morning.

<Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.net7.android-arm" />
<Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.net7.android-arm64" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Runtime.MonoAOTCompiler.Task" />
<Import Project="Sdk.props" Sdk="Microsoft.NETCore.App.Runtime.AOT.Cross.android-x86" />
Copy link
Member

Choose a reason for hiding this comment

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

…wait, what? The dotnet/runtime team didn't rename these packages to contain net8? What are the long-term implications of this?

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 think there are some package names that were updated for 7 and not in main yet.

The .NET 8 version here is a couple weeks old, so if it's not fixed in the next bump I will file an issue to get it fixed.


new object[] {
"net7.0",
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we also assert that net7 builds continue to work? I'm not sure I understand this change.

Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -107,5 +89,5 @@
"Size": 1904
}
},
"PackageSize": 2730619
"PackageSize": 2590859
Copy link
Member

Choose a reason for hiding this comment

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

Nice that the package size shrank with net8!

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 think this is probably this one: dotnet/runtime#74828

We got this change on .NET 7 release branches already, but not main.

@jonpryor
Copy link
Member

PR text says:

Setup .NET 6,7,8 "multi-targeting"

I don't understand how .NET 7 is installed? use-dot-net.yaml appears to only provision .NET 6 and "latest" (.NET 8). How's .NET 7 get into the mix?

@jonathanpeppers
Copy link
Member Author

use-dot-net.yaml is only needed for being able to build/restore xaprepare, which is now net7.0. We also added net6.0 there to fix Mono MSBuild for some of the classic test lanes.

xaprepare provisions .NET 8 for the rest of our build & tests.

Setup .NET 6,7,8 "multi-targeting"

This is actually talking about workload changes. So you will be able to build net8.0-android, net7.0-android, and net6.0-android apps. We can think about dropping 6 in another PR, but it was easy enough to just make it work for now.

@jonathanpeppers
Copy link
Member Author

jonathanpeppers commented Oct 26, 2022

Notes on -SkipNonVersionedFiles:

When installing multiple .NET SDKs into a single folder with the dotnet-install.sh/ps1 script, you can hit an issue where dotnet no longer runs:

dotnet --info
Exited with code: 137

The problem is the dotnet binary can get overwritten by an older .NET, and be completely broken.

The solution is:

  • Install the newest .NET first, followed by any older versions
  • Pass -SkipNonVersionedFiles, so the dotnet binary isn't overwritten

This results with the newest .NET SDK, with a side-by-side older .NET SDK installed as well.

@jonpryor
Copy link
Member

jonpryor commented Oct 26, 2022

Changes: https://github.com/dotnet/installer/compare/11f6b8f7129e34d5317f47ccbc110b2b11c05749...d552037815b75e01be05b6e8d269d54413363e7f
Changes: https://github.com/dotnet/linker/compare/5f9bfd94d9c687207872ae03f751ea19704381c0...493ce626f3278b2d0fd883330bf11a64254981bb
Changes: https://github.com/dotnet/runtime/compare/6d10e4c8bcd9f96ccd73748ff827561afa09af57...b8d49801fe03b96d2fead3d97a11dce1e723dd17

Context: https://github.com/dotnet/runtime/issues/77273
Context: https://github.com/dotnet/runtime/commit/e46523032d72c8b0d2b14ce4b14229a8c268a6e5
Context: https://github.com/dotnet/runtime/issues/77385

Build and run under .NET 8!

.NET 8 is used by default for the default build.

Running unit tests also requires installing .NET 6 and .NET 7 as well.

Configure dotnet6 + dotnet7 + dotnet8 NuGet feeds.

Run `darc update-dependencies --id 152596` to update the
dotnet/installer version in `eng/Version.Details.xml`.
(ID values come from [Maestro][0].)

Update `AutoImport.props` to only evaluate default android items
in .NET 8.

Update `$(DotNetTargetFrameworkVersion)` to 8.0, and
`$(DotNetStableTargetFramework)` to `net7.0`.  (Technically .NET 7
isn't stable *yet*, but it will be soon enough…)

Update `*.apkdesc` files so that unit tests pass.

Update `PackagingTest.CheckIncludedAssemblies()` test to remove
assemblies which are no longer included in .NET 8-based apps.

Update `use-dot-net.yaml` to take a new `quality` parameter, and
install .NET Core 3.1 quality=GA, not 3.1.417 specifically.
Avoids the error:

	dotnet-install: Failed to locate the latest version in the channel '3.1.417' with 'preview' quality for 'dotnet-sdk', os: 'win', architecture: 'x64'.

Update `src/Mono.Android.Export` to pass
`MethodAttributes.Static | MethodAttributes.Public` to the
`DynamicMethod` constructor, not just `MethodAttributes.Static`.
This avoids a `NotSupportedException` under .NET 8;
see also dotnet/runtime@e4652303 and dotnet/runtime#77273:

	System.NotSupportedException: Wrong MethodAttributes or CallingConventions for DynamicMethod. Only public, static, standard supported
	   at System.Reflection.Emit.DynamicMethod.CheckConsistency(MethodAttributes attributes, CallingConventions callingConvention)
	   at System.Reflection.Emit.DynamicMethod.Init(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] signature, Type owner, Module m, Boolean skipVisibility, Boolean transparentMethod)
	   at System.Reflection.Emit.DynamicMethod..ctor(String name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Module m, Boolean skipVisibility)
	   at Java.Interop.DynamicCallbackCodeGenerator.GenerateNativeCallbackDelegate()
	   at Java.Interop.DynamicCallbackCodeGenerator.GetCallback()
	   at Java.Interop.DynamicCallbackCodeGenerator.Create(MethodInfo method)
	   at System.Reflection.MethodInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)

Update `XASdkTests.DotNetPublish()` for .NET 8.  With 745214deb0
we asserted that builds using the *non-* latest target framework
would use a `Mono.Android.dll` reference assembly *from the build*,
not from an existing published/NuGet-provided `Microsoft.Android.Ref`
package.  This started failing because
`$(TargetFramework)`=net7.0-android is no longer the latest framework
and thus *should* be using published packages, not in-tree bits:

	Build should be using C:\a_work\1\s\xamarin-android\bin\Release\dotnet\packs\Microsoft.Android.Ref.33\34.0.0-ci.pr.gh7451.52\ref\net7.0\Mono.Android.dll
	Expected: True
	But was:  False

Update the test to instead make this assertion only for the latest
target framework (`net8.0-android`), skipping .NET 7.

Remove an assertion of no build warnings under `net7.0`; this isn't
currently possible, due to dotnet/runtime#77385.

Update the `Microsoft.NETCore.App.Runtime.AOT.Cross` SDK package names
when `$(AotAssemblies)`=True; the names do not (yet?) include the
.NET version in the package names.

When installing multiple .NET SDKs into a single folder with the
`dotnet-install.{.sh,ps1}` script -- needed to run the unit tests --
you can hit an issue where `dotnet` no longer runs:

	dotnet --info
	Exited with code: 137

The problem is that the `dotnet` binary can get overwritten by an
older .NET, and be completely broken.

The solution is:

 1. Install the newest .NET first, followed by any older versions

 2. Use `dotnet-install.ps1 -SkipNonVersionedFiles` or
    `dotnet-install.sh --skip-non-versioned-files` so the `dotnet`
    binary isn't overwritten

This results in the newest .NET SDK, with side-by-side older .NET SDKs
installed as well.

Rename `tests/api-compatibility/acceptable-breakages-vReference-net7.0.txt`
to use `-net8.0`, as the default `$(TargetFramework)` for
`Mono.Android.dll` changed.

[0]: https://maestro-prod.westus2.cloudapp.azure.com/3074/https:%2F%2Fgithub.heygears.com%2Fdotnet%2Finstaller/latest/graph

@jonpryor jonpryor merged commit 5b7c5bf into dotnet:main Oct 26, 2022
@jonathanpeppers jonathanpeppers deleted the net8.0 branch October 26, 2022 19:21
grendello added a commit to grendello/xamarin-android that referenced this pull request Oct 27, 2022
* main:
  [readme] Be more explicit about support status. (dotnet#7494)
  Bump to dotnet/installer@d5520378 8.0.200-alpha.1.22511.1 (dotnet#7451)
  Bump external/android-api-docs from `52d8515` to `bfbe38e` (dotnet#7483)
  [dependabot] Update submodule ignore list (dotnet#7492)
grendello added a commit to grendello/xamarin-android that referenced this pull request Oct 27, 2022
* main:
  [readme] Be more explicit about support status. (dotnet#7494)
  Bump to dotnet/installer@d5520378 8.0.200-alpha.1.22511.1 (dotnet#7451)
  Bump external/android-api-docs from `52d8515` to `bfbe38e` (dotnet#7483)
  [dependabot] Update submodule ignore list (dotnet#7492)
grendello added a commit to grendello/xamarin-android that referenced this pull request Oct 27, 2022
grendello added a commit to grendello/xamarin-android that referenced this pull request Oct 27, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants