Skip to content

Conversation

pjcollins
Copy link
Member

@pjcollins pjcollins commented Mar 24, 2021

I've been encountering various issues when building and packing .NET 6
content with dotnet build.

Using an older version of dotnet with <Exec/> tasks that invoke a
newer version of dotnet seems to be problematic:

(CreateAllPacks target) -> 
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: The "ResolvePackageAssets" task failed unexpectedly. [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'NuGet.ProjectModel, Version=5.9.0.7122, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified. [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: File name: 'NuGet.ProjectModel, Version=5.9.0.7122, Culture=neutral, PublicKeyToken=31bf3856ad364e35' [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader.CreateReaderFromMemory(ResolvePackageAssets task, Byte[] settingsHash) [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.CacheReader..ctor(ResolvePackageAssets task) [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ReadItemGroups() [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResolvePackageAssets.ExecuteCore() [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/.dotnet/sdk/5.0.201/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(241,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj] [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]
  /Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Directory.Build.targets(81,5): error MSB3073: The command "/Users/builder/Library/Android/dotnet/dotnet pack -p:Configuration=Release -p:NuGetLicense=/Users/builder/azdo/_work/2/s/xamarin-android/external/monodroid/tools/scripts/License.txt -p:AndroidRID=android-arm -p:AndroidABI=armeabi-v7a-net6 "/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Runtime.proj"" exited with code 1. [/Users/builder/azdo/_work/2/s/xamarin-android/build-tools/create-packs/Microsoft.Android.Sdk.proj]

The same scenario fails even earlier if the nested project build also
targets a newer .NET SDK version:

BuildILLinkCustomStep:
  C:\Users\Peter\android-toolchain\dotnet\dotnet build -p:Configuration=Release "C:\Users\Peter\source\pj\xamarin-android\src\Microsoft.Android.Sdk.ILLink\Microsoft.Android.Sdk.ILLink.csproj"
  Microsoft (R) Build Engine version 16.10.0-preview-21175-01+afd0b6210 for .NET
  Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  C:\Program Files\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(141,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 6.0.  Either target .NET 5.0 or lower, or use a version of the .NET SDK that supports .NET 6.0. [C:\Users\Peter\source\pj\xamarin-android\src\Microsoft.Android.Sdk.ILLink\Microsoft.Android.Sdk.ILLink.csproj] [C:\Users\Peter\source\pj\xamarin-android\build-tools\create-packs\Microsoft.Android.Ref.proj]

We do not need to build any of our .NET 6 content with .NET 6. All of
our .NET 6 sources and dependencies can be built and packed with a
target framework of netstandard2.0 or net5.0. To fix these issues
and simplify things, our .NET 6 build and packaging targets have been
updated to use the system dotnet. This version has been bumped to
.NET 5.0.201 in CI.

A new make rule create-nupkgs has been added to reduce the number of
places where we were previously calling msbuild /t:CreateAllPacks in
yaml. The create-installers rule now depends on this new rule.

The Windows Dotnet Build and Smoke Test job has been updated to run
tests against the netcoreapp3.1 version of Xamarin.Android.Build.Tests.
A duplicate solution build has also been removed, as the PackDotNet
target will build the entire Xamarin.Android.sln.

A duplicate file reference for Java.Interop.Tools.Generator.dll has
been removed from the Microsoft.Android.Sdk packs.

@pjcollins pjcollins force-pushed the bump-net-5.0.201 branch 2 times, most recently from 662b6d6 to 0b4c274 Compare March 29, 2021 18:26
@pjcollins pjcollins force-pushed the bump-net-5.0.201 branch 2 times, most recently from f2ff2d5 to 9ff3d4a Compare April 10, 2021 16:45
@pjcollins pjcollins changed the title [CI] Bump to .NET 5.0.201 [ci] Build and pack updates, bump to .NET 5.0.201 Apr 10, 2021
@pjcollins pjcollins marked this pull request as ready for review April 12, 2021 14:23
@pjcollins pjcollins requested a review from jonpryor as a code owner April 12, 2021 14:23

<Target Name="BuildILLinkCustomStep">
<Exec Command="$(DotNetPreviewTool) build -p:Configuration=$(Configuration) &quot;$(XamarinAndroidSourcePath)src\Microsoft.Android.Sdk.ILLink\Microsoft.Android.Sdk.ILLink.csproj&quot;" />
<Exec Command="dotnet build -p:Configuration=$(Configuration) &quot;$(XamarinAndroidSourcePath)src\Microsoft.Android.Sdk.ILLink\Microsoft.Android.Sdk.ILLink.csproj&quot;" />
Copy link
Member

Choose a reason for hiding this comment

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

Should we put a note, we could potentially build this project normally when we get #5806? Then msbuild on Mac could build net5.0, and we could put it in Xamarin.Android.sln like a normal project?

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 dropped a note on the other PR, we can potentially include these changes there 👍

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

Otherwise LTGM 👍

@pjcollins pjcollins merged commit b7bdd1c into dotnet:main Apr 12, 2021
@pjcollins pjcollins deleted the bump-net-5.0.201 branch April 12, 2021 19:05
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 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.

3 participants