Skip to content

Move from netcoreapp3.1 to net6.0 #195

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

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented 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 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

nugetConfigPath: NuGet.config

- task: MSBuild@1
- script: dotnet build Xamarin.Android.Tools.sln -bl:$(Build.ArtifactStagingDirectory)/build.binlog
Copy link
Member

Choose a reason for hiding this comment

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

It may be preferable to use DotNetCoreCLI@2 here, though it shouldn't make much of a difference

  - task: DotNetCoreCLI@2
    displayName: 'Build solution Xamarin.Android.Tools.sln'
    inputs:
      projects: Xamarin.Android.Tools.sln
      arguments: -bl:$(Build.ArtifactStagingDirectory)/build.binlog

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 thought I would also have to put command: build or command: pack.

Does it do anything extra that is helpful? Like insert warnings inline in PRs? Something else?

Otherwise a one-line script: block seems simpler?

Copy link
Member

@pjcollins pjcollins Oct 11, 2022

Choose a reason for hiding this comment

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

The command: build param is used by default, so it doesn't need to be set when building. You would need to set command: pack for packing though.

I think the only advantage to using the task over a script is that it will probe multiple locations for dotnet, but since we're using the UseDotNet task there shouldn't be a difference either way.

There may also be some improvements to the Checks tab of PRs/commits when things fail like you suggested (for instance some extra logger settings are set), though I am not positive.

@@ -73,15 +59,13 @@ jobs:
Write-Host "##vso[task.setvariable variable=xat.nuget.version]$version"
condition: and(succeeded(), eq(variables['agent.os'], 'Windows_NT'))

- task: MSBuild@1
- script: dotnet pack src/Xamarin.Android.Tools.AndroidSdk/Xamarin.Android.Tools.AndroidSdk.csproj -p:Version=$(xat.nuget.version) -p:PackageOutputPath=$(Build.ArtifactStagingDirectory) -bl:$(Build.ArtifactStagingDirectory)/pack.binlog
Copy link
Member

Choose a reason for hiding this comment

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

We could also use DotNetCoreCLI@2 here instead.

@pjcollins pjcollins requested a review from tondat October 11, 2022 15:44
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
@pjcollins
Copy link
Member

@tondat is there anything we need to consider on the IDE side of things for this?

@jonathanpeppers
Copy link
Member Author

@tondat is there anything we need to consider on the IDE side of things for this?

I think the IDEs would all use the netstandard2.0 assemblies, such as:

<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>

Copy link
Contributor

@tondat tondat left a comment

Choose a reason for hiding this comment

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

Please try to verify the build of androidtools repo with the bump of this change

@jonathanpeppers jonathanpeppers merged commit 9f56dec into dotnet:main Oct 11, 2022
@jonathanpeppers jonathanpeppers deleted the net6.0 branch October 11, 2022 19:32
@jonathanpeppers
Copy link
Member Author

I will test the latest in androidtools & xamarin-android shortly.

@jonathanpeppers
Copy link
Member Author

FYI @tondat seemed to work fine: https://github.com/xamarin/androidtools/pull/362

jonpryor pushed a commit to dotnet/android that referenced this pull request Oct 12, 2022
jonpryor added a commit to jonpryor/java.interop that referenced this pull request Jan 12, 2023
Changes: dotnet/android-tools@29f11f2...47f95ab

  * dotnet/android-tools@47f95ab: Fix CS0121 ambiguity errors. (dotnet/android-tools#200)
  * dotnet/android-tools@76c076f: Add support for Project Specific RegisterTaskObject. (dotnet/android-tools#199)
  * dotnet/android-tools@9f02d77: Add reference to System.Security.Cryptography.Xml (dotnet/android-tools#198)
  * dotnet/android-tools@fa3711b: [build] Update NuGet package versions (dotnet/android-tools#196)
  * dotnet/android-tools@59cac90: Enable CodeQL (dotnet/android-tools#197)
  * dotnet/android-tools@9f56dec: Move from `netcoreapp3.1` to `net6.0` (dotnet/android-tools#195)
  * dotnet/android-tools@0be567a: Use Environment.SpecialFolder.UserProfile, not SpecialFolder.Personal (dotnet/android-tools#194)
jonpryor added a commit to jonpryor/java.interop that referenced this pull request Jan 18, 2023
Changes: dotnet/android-tools@29f11f2...099fd95

  * dotnet/android-tools@099fd95: Add *Task.ProjectSpecificTaskObjectKey() for RegisterTaskObject() use (dotnet/android-tools#202)
  * dotnet/android-tools@ac9ea09: Revert IBuildEngine.ProjectFileOfTaskNode use. (dotnet/android-tools#201)
  * dotnet/android-tools@47f95ab: Fix CS0121 ambiguity errors. (dotnet/android-tools#200)
  * dotnet/android-tools@76c076f: Add support for Project Specific RegisterTaskObject. (dotnet/android-tools#199)
  * dotnet/android-tools@9f02d77: Add reference to System.Security.Cryptography.Xml (dotnet/android-tools#198)
  * dotnet/android-tools@fa3711b: [build] Update NuGet package versions (dotnet/android-tools#196)
  * dotnet/android-tools@59cac90: Enable CodeQL (dotnet/android-tools#197)
  * dotnet/android-tools@9f56dec: Move from `netcoreapp3.1` to `net6.0` (dotnet/android-tools#195)
  * dotnet/android-tools@0be567a: Use Environment.SpecialFolder.UserProfile, not SpecialFolder.Personal (dotnet/android-tools#194)
jonpryor added a commit to dotnet/java-interop that referenced this pull request Jan 25, 2023
Changes: dotnet/android-tools@29f11f2...099fd95

  * dotnet/android-tools@099fd95: Add *Task.ProjectSpecificTaskObjectKey() for RegisterTaskObject() use (dotnet/android-tools#202)
  * dotnet/android-tools@ac9ea09: Revert IBuildEngine.ProjectFileOfTaskNode use. (dotnet/android-tools#201)
  * dotnet/android-tools@47f95ab: Fix CS0121 ambiguity errors. (dotnet/android-tools#200)
  * dotnet/android-tools@76c076f: Add support for Project Specific RegisterTaskObject. (dotnet/android-tools#199)
  * dotnet/android-tools@9f02d77: Add reference to System.Security.Cryptography.Xml (dotnet/android-tools#198)
  * dotnet/android-tools@fa3711b: [build] Update NuGet package versions (dotnet/android-tools#196)
  * dotnet/android-tools@59cac90: Enable CodeQL (dotnet/android-tools#197)
  * dotnet/android-tools@9f56dec: Move from `netcoreapp3.1` to `net6.0` (dotnet/android-tools#195)
  * dotnet/android-tools@0be567a: Use Environment.SpecialFolder.UserProfile, not SpecialFolder.Personal (dotnet/android-tools#194)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants