xamarin-macios icon indicating copy to clipboard operation
xamarin-macios copied to clipboard

nuget looking for (old, not mono) Microsoft.NETCore.App.Runtime.maccatalyst-arm64

Open spouliot opened this issue 3 years ago • 1 comments

This is semi-related to https://github.com/dotnet/sdk/issues/21877 where a .csproj has several target frameworks.

<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst;net6.0-macos</TargetFrameworks>

This leads to the known issues :( but this one seems different.

The main project imports another file that contains

<TargetFramework>net6.0-macos</TargetFramework>
<RuntimeIdentifier>osx-arm64</RuntimeIdentifier>

That's to avoid (some) of the issues with https://github.com/dotnet/sdk/issues/21877

That works well to do a dotnet restore for macOS. However switching to MacCatalyst leads to nuget errors to retrieve the runtime package.

<TargetFramework>net6.0-maccatalyst</TargetFramework>
<RuntimeIdentifier>maccatalyst-arm64</RuntimeIdentifier>

Steps to Reproduce

  1. dotnet restore inside a project with multiple framework targets.
$ dotnet restore                                                                                                                              
  Determining projects to restore...
/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj : error NU1102: Unable to find package Microsoft.NETCore.App.Runtime.maccatalyst-arm64 with version (= 6.0.6)
/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj : error NU1102:   - Found 2 version(s) in nuget.org [ Nearest version: 6.0.0-preview.3.21201.4 ]
/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj : error NU1102:   - Found 0 version(s) in /usr/local/share/dotnet/library-packs
  Failed to restore /Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj (in 609 ms).
  • Microsoft.NETCore.App.Runtime.maccatalyst-arm64 does not exists (anymore)
  • Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64 was its replacement.
  • Somehow, somewhere, something is still looking for the old/original name.
  • The error comes from nuget but I don't think it has the knowledge of the runtime filenames.

Expected Behavior

Successful restore.

$ dotnet restore                                                                                                                         Determining projects to restore...
  Restored /Users/poupou/git/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj (in 1.99 sec).

Actual Behavior

Nuget error NU1102.

Environment

Version information
$ dotnet --info    
.NET SDK (reflecting any global.json):
 Version:   6.0.301
 Commit:    43f9b18481

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  12.4
 OS Platform: Darwin
 RID:         osx.12-arm64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.301/

Host (useful for support):
  Version: 6.0.6
  Commit:  7cca709db2

.NET SDKs installed:
  6.0.100 [/usr/local/share/dotnet/sdk]
  6.0.101 [/usr/local/share/dotnet/sdk]
  6.0.200 [/usr/local/share/dotnet/sdk]
  6.0.201 [/usr/local/share/dotnet/sdk]
  6.0.202 [/usr/local/share/dotnet/sdk]
  6.0.203 [/usr/local/share/dotnet/sdk]
  6.0.300 [/usr/local/share/dotnet/sdk]
  6.0.301 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Build Logs

Example Project (If Possible)

spouliot avatar Aug 09 '22 14:08 spouliot

Also, when switching to iOS dotnet restore works just fine

<TargetFramework>net6.0-ios</TargetFramework>
<RuntimeIdentifier>iossimulator-arm64</RuntimeIdentifier>

spouliot avatar Aug 09 '22 15:08 spouliot

Thanks, we will have a look at it!

dalexsoto avatar Aug 12 '22 15:08 dalexsoto

using maccatalyst-x64 seems to work

dotnet build -f net6.0-maccatalyst -r maccatalyst-x64 --no-restore                                                                     
MSBuild version 17.3.0+92e077650 for .NET
/usr/local/share/dotnet/sdk/6.0.400/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(1114,5): warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used. [/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj]
  Detected signing identity:

    Bundle Id: com.companyname.changeme
    App Id: com.companyname.changeme
  DebugMyApp.Mobile -> /Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/bin/Debug/net6.0-maccatalyst/maccatalyst-x64/DebugMyApp.Mobile.dll
  Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink

Build succeeded.

/usr/local/share/dotnet/sdk/6.0.400/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(1114,5): warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used. [/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj]
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:20.96

but still no luck with maccatalyst-arm64

dotnet build -f net6.0-maccatalyst -r maccatalyst-arm64 --no-restore                                                                   MSBuild version 17.3.0+92e077650 for .NET
/usr/local/share/dotnet/sdk/6.0.400/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(1114,5): warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used. [/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj]
  Detected signing identity:

    Bundle Id: com.companyname.changeme
    App Id: com.companyname.changeme
/usr/local/share/dotnet/sdk/6.0.400/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/obj/project.assets.json' doesn't have a target for 'net6.0-maccatalyst/maccatalyst-arm64'. Ensure that restore has run and that you have included 'net6.0-maccatalyst' in the TargetFrameworks for your project. You may also need to include 'maccatalyst-arm64' in your project's RuntimeIdentifiers. [/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj]

Build FAILED.

/usr/local/share/dotnet/sdk/6.0.400/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(1114,5): warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used. [/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj]
/usr/local/share/dotnet/sdk/6.0.400/Sdks/Microsoft.NET.Sdk/targets/Microsoft.PackageDependencyResolution.targets(267,5): error NETSDK1047: Assets file '/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/obj/project.assets.json' doesn't have a target for 'net6.0-maccatalyst/maccatalyst-arm64'. Ensure that restore has run and that you have included 'net6.0-maccatalyst' in the TargetFrameworks for your project. You may also need to include 'maccatalyst-arm64' in your project's RuntimeIdentifiers. [/Users/poupou/git/uno/uno-debug-test/DebugMyApp/DebugMyApp.Mobile/DebugMyApp.Mobile.csproj]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:01.15

It does not seems possible to have a project with multiple platforms that target MacCatalyst with arm64 :(

spouliot avatar Aug 28 '22 00:08 spouliot

This error:

error NETSDK1047: Assets file ...

occurs when a project hasn't been restored for the RID in question, and you're passing in --no-restore to dotnet build, so that makes sense.

rolfbjarne avatar Aug 29 '22 13:08 rolfbjarne

This csproj restores just fine for me:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
	<PropertyGroup>
		<TargetFrameworks>net6.0-ios;net6.0-maccatalyst;net6.0-macos</TargetFrameworks>
		<RuntimeIdentifier>maccatalyst-arm64</RuntimeIdentifier>
	</PropertyGroup>
</Project>
$ dotnet restore
Determining projects to restore...
Restored MySimpleApp.csproj (in 212 ms).

Can you provide a test project?

rolfbjarne avatar Aug 29 '22 13:08 rolfbjarne

Hi @spouliot. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

msftbot[bot] avatar Aug 29 '22 13:08 msftbot[bot]

@rolfbjarne yes, restore works - but you can't build a maccatalyst-arm64 binary of a default maui template.

dotnet build -f:net6.0-maccatalyst -r:maccatalyst-arm64                                                                                                                                     MSBuild version 17.3.0+92e077650 for .NET
  Determining projects to restore...
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.430/targets/Xamarin.Shared.Sdk.targets(1744,3): error : The RuntimeIdentifier 'maccatalyst-arm64' is invalid. [/Users/poupou/projects/maui/maui.csproj]

Since you're back to https://github.com/dotnet/sdk/issues/21877 which mix SDK, like Microsoft.iOS.Sdk, and identifiers, like maccatalyst-arm64). The workaround is where the --no-restore is being used.

When I restore independently and build with --no-restore then I hit the above error.

How would you build the maccatalyst-arm64 binary of a default maui template from the command-line ?

spouliot avatar Aug 29 '22 14:08 spouliot

This seems to work for me:

$ dotnet restore /p:RuntimeIdentifier=maccatalyst-arm64
$ dotnet build -f net6.0-maccatalyst /p:RuntimeIdentifier=maccatalyst-arm64 --no-restore *.csproj

rolfbjarne avatar Aug 31 '22 15:08 rolfbjarne

Hi @spouliot. We have added the "need-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

msftbot[bot] avatar Aug 31 '22 15:08 msftbot[bot]

@rolfbjarne was your project based on the default MAUI template for all (at least multiple) platforms ?

$ dotnet restore /p:RuntimeIdentifier=maccatalyst-arm64                                                                                                                                                Determining projects to restore...
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/15.4.430/targets/Xamarin.Shared.Sdk.targets(1744,3): error : The RuntimeIdentifier 'maccatalyst-arm64' is invalid. [/Users/poupou/projects/maui/maui.csproj]

spouliot avatar Sep 01 '22 02:09 spouliot

Try updating to 15.4.447: https://github.com/xamarin/xamarin-macios/releases/tag/dotnet-6.0.4xx-447, where we've done this: https://github.com/xamarin/xamarin-macios/pull/15491

rolfbjarne avatar Sep 01 '22 14:09 rolfbjarne

Thanks! Works for MAUI and likely on my original code (need to remove some workaround to try it). I thought I updated to 447 but I now remember the downloads were failing at the time and forgot to try updating again.

spouliot avatar Sep 01 '22 15:09 spouliot