sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Specifying both -f ... and -r ... to dotnet build fails to restore if multiple frameworks are present in the project file

Open rolfbjarne opened this issue 4 years ago • 33 comments

Describe the bug

Repro:

$ dotnet new maui
$ dotnet build -f:net6.0-ios -r ios-arm64
Microsoft (R) Build Engine version 17.0.0-preview-21477-04+3a1e456fe for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
/usr/local/share/dotnet/packs/Microsoft.MacCatalyst.Sdk/15.0.101-preview.10.54/targets/Xamarin.Shared.Sdk.targets(1138,3): error : The RuntimeIdentifier 'ios-arm64' is invalid. [/Users/rolf/test/dotnet/maui/maui.csproj]

The problem is that it's trying to restore the net6.0-maccatalyst framework from the project file using the ios-arm64 RuntimeIdentifier, which fails, because ios-arm64 is not a valid RuntimeIdentifier for Mac Catalyst.

It seems that the implicit restore by "dotnet build" does not take into account the specified -f value (or takes into account the -r value when it shouldn't).

Binlog: msbuild.binlog.zip

Further technical details

dotnet --info
$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-rtm.21477.21
 Commit:    690faf288e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.6
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100-rtm.21477.21/

Host (useful for support):
  Version: 6.0.0-rtm.21477.8
  Commit:  a7e9f9fb23

.NET SDKs installed:
  2.0.3 [/usr/local/share/dotnet/sdk]
  2.1.504 [/usr/local/share/dotnet/sdk]
  2.1.700 [/usr/local/share/dotnet/sdk]
  2.1.810 [/usr/local/share/dotnet/sdk]
  2.2.107 [/usr/local/share/dotnet/sdk]
  2.2.203 [/usr/local/share/dotnet/sdk]
  2.2.204 [/usr/local/share/dotnet/sdk]
  3.0.100 [/usr/local/share/dotnet/sdk]
  3.1.100 [/usr/local/share/dotnet/sdk]
  3.1.200 [/usr/local/share/dotnet/sdk]
  3.1.201 [/usr/local/share/dotnet/sdk]
  3.1.402 [/usr/local/share/dotnet/sdk]
  5.0.100-dev [/usr/local/share/dotnet/sdk]
  5.0.100-preview.1.20155.7 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.3.20170.3 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.4.20212.3 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.4.20214.36 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.5.20223.3 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.5.20227.16 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.5.20256.10 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.5.20263.11 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.6.20265.2 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.6.20269.4 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.7.20307.3 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.7.20317.11 [/usr/local/share/dotnet/sdk]
  5.0.100-preview.8.20359.11 [/usr/local/share/dotnet/sdk]
  5.0.100-rc.1.20411.10 [/usr/local/share/dotnet/sdk]
  5.0.100-rc.1.20414.5 [/usr/local/share/dotnet/sdk]
  5.0.100-rc.1.20426.3 [/usr/local/share/dotnet/sdk]
  5.0.100-rc.2.20459.1 [/usr/local/share/dotnet/sdk]
  5.0.100-rc.2.20480.7 [/usr/local/share/dotnet/sdk]
  5.0.100-rtm.20509.5 [/usr/local/share/dotnet/sdk]
  5.0.102 [/usr/local/share/dotnet/sdk]
  5.0.200 [/usr/local/share/dotnet/sdk]
  5.0.202 [/usr/local/share/dotnet/sdk]
  6.0.100-alpha.1.20554.10 [/usr/local/share/dotnet/sdk]
  6.0.100-alpha.1.20559.4 [/usr/local/share/dotnet/sdk]
  6.0.100-alpha.1.21060.3 [/usr/local/share/dotnet/sdk]
  6.0.100-alpha.1.21062.17 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.1.21081.5 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.1.21103.13 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.2.21114.3 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.2.21153.28 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.2.21155.3 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.3.21202.5 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.4.21215.1 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.4.21218.6 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.4.21226.14 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.4.21255.9 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.5.21302.13 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.5.21303.17 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.5.21308.63 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.6.21280.2 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.6.21308.62 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.6.21309.26 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.6.21328.1 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.7.21362.12 [/usr/local/share/dotnet/sdk]
  6.0.100-preview.7.21364.4 [/usr/local/share/dotnet/sdk]
  6.0.100-rc.1.21405.1 [/usr/local/share/dotnet/sdk]
  6.0.100-rc.1.21458.1 [/usr/local/share/dotnet/sdk]
  6.0.100-rc.2.21420.30 [/usr/local/share/dotnet/sdk]
  6.0.100-rtm.21477.21 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.22 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.22 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.1.20124.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.3.20170.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.3.20170.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.4.20211.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.4.20214.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.5.20223.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.5.20227.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.5.20255.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.6.20265.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.6.20269.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.7.20307.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.7.20311.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-preview.8.20359.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.1.20405.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.1.20424.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20458.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rtm.20508.30 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-alpha.1.20526.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-alpha.1.21059.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-alpha.1.21062.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.1.21078.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.1.21103.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.2.21112.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.2.21125.25 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.2.21154.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.3.21201.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.4.21213.1 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.4.21222.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.4.21253.5 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.5.21217.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.5.21301.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21277.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21306.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.6.21325.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.7.21360.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-preview.7.21363.16 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.1.21404.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.1.21452.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rc.2.21419.24 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.0-rtm.21477.22 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.22 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.1.20120.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.3.20169.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.4.20210.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.4.20214.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.5.20223.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.5.20227.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.5.20253.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.6.20263.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.6.20264.1 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.7.20306.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.7.20317.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-preview.8.20358.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20404.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.1.20425.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20454.25 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rtm.20508.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.5 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-alpha.1.20553.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-alpha.1.20557.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-alpha.1.21059.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-alpha.1.21061.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-preview.7.21360.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21403.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.1.21451.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rc.2.21420.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.0-rtm.21477.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

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

rolfbjarne avatar Oct 08 '21 06:10 rolfbjarne

I found that restore is what causes this problem.

So you can workaround by doing something like:

$ dotnet new maui
$ dotnet restore
$ dotnet build -f net6.0-ios -r ios-arm64 --no-restore
$ dotnet build -f net6.0-android -r android-arm64 --no-restore

jonathanpeppers avatar Feb 02 '22 15:02 jonathanpeppers

Same thing happens with dotnet publish: https://github.com/xamarin/xamarin-macios/issues/14015

rolfbjarne avatar Feb 02 '22 15:02 rolfbjarne

IMO this is a critical scenario to fix. It is going to block / trip-up any developer who is trying to publish an iOS app.

$ dotnet new maui
$ dotnet publish -f net6.0-ios

Fails saying that you need to specify a RuntimeIdentifier. So then you do that:

$ dotnet publish -f net6.0-io -r ios-arm64

And that fails with this error: The RuntimeIdentifier 'ios-arm64' is invalid.

Now developers are stuck, and they have no idea what to do.

@marcpopMSFT @dsplaisted - is there anything we can do here?

eerhardt avatar Feb 02 '22 16:02 eerhardt

I think this is similar to this item: https://github.com/dotnet/sdk/issues/19487#issuecomment-898765210 Basically, TF specified on command line is not passed to the restore operation if it's not in the TargetFrameworks property of the project file. @dsplaisted we previously discussed options and should bring that up again.

marcpopMSFT avatar Feb 02 '22 19:02 marcpopMSFT

Possible solution: If the RuntimeIdentifier is specified on the command line, allow the TargetFramework from the command line to flow to the restore operation, since the RuntimeIdentifier being passed to restore will cause a re-restore anyway.

dsplaisted avatar Feb 02 '22 22:02 dsplaisted

Another developer has run into this issue: https://github.com/dotnet/runtime/pull/65747.

I believe this is going to be hit by any Maui developer. Any chance this can get looked into for the Maui release? Is there a better command line people should be passing instead of saying -r RID?

eerhardt avatar Feb 22 '22 23:02 eerhardt

IMO this is a critical scenario to fix. It is going to block / trip-up any developer who is trying to publish an iOS app.

$ dotnet new maui
$ dotnet publish -f net6.0-ios

Fails saying that you need to specify a RuntimeIdentifier. So then you do that:

$ dotnet publish -f net6.0-io -r ios-arm64

And that fails with this error: The RuntimeIdentifier 'ios-arm64' is invalid.

Now developers are stuck, and they have no idea what to do.

@marcpopMSFT @dsplaisted - is there anything we can do here?

I ran into thiswhen trying to set up an iOS Build Pipeline in Azure DevOps for my app. I was following the instructions found here and then experienced exactly these issues... is there at least a work around?

Mephisztoe avatar Mar 04 '22 13:03 Mephisztoe

@Mephisztoe I think you should be able to run dotnet restore first, then use --no-restore when you run publish.

jonathanpeppers avatar Mar 04 '22 14:03 jonathanpeppers

@Mephisztoe I think you should be able to run dotnet restore first, then use --no-restore when you run publish.

Tried that and didn't work.

Then it says: Assets file '/Users/runner/work/1/s/.../obj/project.assets.json' doesn't have a target for 'net6.0-ios/ios-arm64'. Ensure that restore has run and that you have included 'net6.0-ios' in the TargetFrameworks for your project. You may also need to include 'ios-arm64' in your project's RuntimeIdentifiers. [/Users/runner/work/1/s/.../....csproj]

I did run a restore task before and my csproj of course includes this RID.

Mephisztoe avatar Mar 04 '22 14:03 Mephisztoe

Does dotnet build work instead? dotnet publish doesn't really do anything extra on iOS/Android/etc., just copies files to another folder.

jonathanpeppers avatar Mar 04 '22 14:03 jonathanpeppers

dotnet publish doesn't really do anything extra on iOS

I believe it creates the .ipa file, which build doesn’t.

eerhardt avatar Mar 04 '22 15:03 eerhardt

dotnet publish doesn't really do anything extra on iOS

I believe it creates the .ipa file, which build doesn’t.

Correct, but you can do that with build too:

dotnet build /p:BuildIpa=true

which is ultimately what publish does for iOS.

rolfbjarne avatar Mar 04 '22 15:03 rolfbjarne

build instead of publish seems to work, btw. Thank's for this hint!

Mephisztoe avatar Mar 04 '22 16:03 Mephisztoe

@nkolev @dotnet/nuget-team I'm not sure how to fix this, I think we need to have a discussion with the NuGet team. I thought that the issue had to do with the fact that we weren't forwarding the TargetFramework property to the restore operation. However, even if we do pass TargetFramework to the restore operation, NuGet will still see the TargetFrameworks property from the project file and try to restore for both target frameworks, and error out when one of them isn't compatible with the specified RuntimeIdentifier.

dsplaisted avatar Mar 06 '22 17:03 dsplaisted

Possible solution: If the RuntimeIdentifier is specified on the command line, allow the TargetFramework from the command line to flow to the restore operation, since the RuntimeIdentifier being passed to restore will cause a re-restore anyway.

I was trying to publish an ios-arm64 app and was able to work around this by adding an ios-arm64 RuntimeIdentifier. That was enough for the restore to figure things out.

steveisok avatar Mar 11 '22 14:03 steveisok

I am running in the same issue. Followed the instructions from here https://docs.microsoft.com/en-us/dotnet/maui/ios/deployment/overview and tried out different variants according to the comments in here:

dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 error : The RuntimeIdentifier 'ios-arm64' is invalid.

dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 --no-restore error NETSDK1032: The RuntimeIdentifier platform 'ios-arm64' and the PlatformTarget 'x64' must be compatible.

dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true error : The RuntimeIdentifier 'ios-arm64' is invalid.

dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true --no-restore error NETSDK1032: The RuntimeIdentifier platform 'ios-arm64' and the PlatformTarget 'x64'

How can this be resolved?

otium99 avatar May 26 '22 22:05 otium99

@otium99 the easiest is make sure PlatformTarget is not set (it will be computed automatically). Alternatively you can set it to arm64 when using the ios-arm64 runtime identifier (and update accordingly when using a different runtime identifier).

rolfbjarne avatar May 27 '22 09:05 rolfbjarne

@rolfbjarne I am assuming that not setting the PlatformTarget means, not setting the -f parameter?

dotnet publish -c:Release /p:RuntimeIdentifier=ios-arm64 The 'Publish' target is not supported without specifying a target framework

dotnet build -c:Release /p:BuildIpa=true Build succeeded. -> but there is no *.ipa file in bin/Release/net6.0-ios/ios-arm64/publish

otium99 avatar May 27 '22 13:05 otium99

@otium99 no, I mean that you probably have <PlatformTarget>x64</PlatformTarget> in your csproj somewhere.

rolfbjarne avatar May 27 '22 13:05 rolfbjarne

For what it's worth, when I do dotnet new maui ; dotnet publish -f net6.0-ios -r ios-arm64 I get the error message:

C:\Program Files\dotnet\packs\Microsoft.MacCatalyst.Sdk\15.4.303\targets\Xamarin.Shared.Sdk.targets(1739,3): error : The RuntimeIdentifier 'ios-arm64' is invalid. [C:\src\test\mauiTest\mauiTest.csproj]

Does 15.4.303 seem like the right MacCatalyst SDK version number to you? My dotnet --info says 6.0.300, dotnet workload update says maui updated, even though it didn't seem to download anything, and dotnet workload list says:

Installed Workload Ids      Installation Source
---------------------------------------------------------------
maui                        SDK 6.0.300
ios                         VS 17.3.32523.54, VS 17.3.32519.111
android                     VS 17.3.32523.54, VS 17.3.32519.111
maui-windows                VS 17.3.32523.54, VS 17.3.32519.111
maui-maccatalyst            VS 17.3.32523.54, VS 17.3.32519.111
maui-ios                    VS 17.3.32523.54, VS 17.3.32519.111
maccatalyst                 VS 17.3.32523.54, VS 17.3.32519.111
maui-android                VS 17.3.32523.54, VS 17.3.32519.111

I'm msft internal, so have been running internal builds for years, and who knows what old stuff is on my machine from failed updates. However, I'm a little surprised that a clean project from the template doesn't work, assuming those publish arguments are actually correct/valid. I should be getting a new devbox today, and since I'll be doing a clean install, I'll try to remember to test this out.

Edit: After too many hours of effort to get this new PC ready, I installed VS 2022 public preview as the first and only software, created a MAUI project in VS, but couldn't figure out how to create an archive or publish from VS. On the command line, dotnet publish gave an error saying that a TFM needed to be selected, dotnet publish -f net6.0-ios gave an error saying that a RID needs to be supplied, and dotnet -f net6.0-ios -r ios-arm64 gave the same RID is invalid error.

zivkan avatar May 27 '22 14:05 zivkan

Does 15.4.303 seem like the right MacCatalyst SDK version number to you?

Yes, that's correct, it's the version we released.

rolfbjarne avatar May 27 '22 15:05 rolfbjarne

@otium99 no, I mean that you probably have <PlatformTarget>x64</PlatformTarget> in your csproj somewhere.

@rolfbjarne I don't. Neither the tag PlatformTarget nor the content x64.

ProjectFile.txt

otium99 avatar May 27 '22 19:05 otium99

@otium99 no, I mean that you probably have <PlatformTarget>x64</PlatformTarget> in your csproj somewhere.

@rolfbjarne I don't. Neither the tag PlatformTarget nor the content x64.

ProjectFile.txt

That's strange. Can you get a binlog (build with the /bl flag: dotnet build /bl:msbuild.binlog ...) and upload the resulting msbuild.binlog file?

rolfbjarne avatar May 30 '22 09:05 rolfbjarne

@rolfbjarne

Meanwhile I figured that when I change

<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>

to

<RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>

It starts compiling. But then I get stuck at "code signing key not found in keychain", which I am assuming is not related to the RuntimeIdentifier issue.

I've documented the whole process also here: https://stackoverflow.com/questions/72399444/errors-with-dotnet-publish

otium99 avatar May 30 '22 15:05 otium99

@rolfbjarne I created a brand new maui project from the template, and it doesn't have this issue.

otium99 avatar May 30 '22 23:05 otium99

@rolfbjarne msbuild.txt

The PlatformTarget property comes from the MonkeyFinder.csproj.user file, which the IDE creates.

If you're building from the command line, you should be able to just delete this file.

Meanwhile I figured that when I change

<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>

to

<RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>

It starts compiling. But then I get stuck at "code signing key not found in keychain", which I am assuming is not related to the RuntimeIdentifier issue.

Correct, you need to configure code signing. You can find more info here: https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/device-provisioning/

rolfbjarne avatar May 31 '22 06:05 rolfbjarne

I have exactly the same problem with The RuntimeIdentifier 'ios-arm64' is invalid. and found this issue. While I've added all the "workarounds" like removing catalyst from TargetFrameworks and deleting the csproj.user file, in the end it still failed with:

Recognized signature identity:

    Code Signing Key: "iPhone Distribution: xxx xxx (xxx)" (xxx)
    Provisioning Profile: "xxx" (xxx-xxx-xxx-xxx-xxx)
    Bundle Id: com.xxx
    App Id: xxx.com.xxx
   Completed execution of tool "xcrun" (exit code = 1).

  warning: ignoring unknown option: -z
  error: cannot parse the debug map for '/Users/xxx/Library/Caches/Xamarin/mtbs/builds/xxx/xxx
  xxx/bin/Release/net6.0-ios/ios-arm64/xxx.app/xxx
  xxx': No such file or directory

Just like everyone else:

<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
<BuildIpa>False</BuildIpa>
<Configurations>Debug;Release;ARM64</Configurations>
<Platforms>AnyCPU;ARM64</Platforms>

  <PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
    <RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>
    <CodesignKey>iPhone Distribution: xxx xxx (xxx)</CodesignKey>
    <CodesignProvision>xxx</CodesignProvision>
    <ArchiveOnBuild>true</ArchiveOnBuild>
    <TcpPort>58181</TcpPort>
  </PropertyGroup>

And build with: dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:ServerAddress=192.168.178.54 /p:ServerUser=xxx /p:ServerPassword=xxx /p:TcpPort=58181 /p:ArchiveOnBuild=true /p:_DotNetRootRemoteDirectory=/Users/xxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/

In the MS docs it sounds so simple to build using a macos host but in reality everything is just broken and fails with errors a normal user is not able to understand. Requires lots of workarounds and in the end it still doesn't work.

Symbai avatar Jun 05 '22 12:06 Symbai

@Symbai I went through a myriad of errors as well.

Now I got it to work: https://stackoverflow.com/a/72511005/5909367

Maybe it helps you too.

In short, I guess this should be changed in your example: (Singular) <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>

and then dotnet publish -f:net6.0-ios -c:Release

otium99 avatar Jun 05 '22 20:06 otium99

@otium99:

Your original error is completely different one and your solution unfortunately that only generates a new error for me:

The resource file "C:\Users\xxx\source\repos\xxx\xxx\obj\project.a
ssets.json has no target for net6.0-ios/ios-arm64. Make sure the restore is running
t and that you have included "net6.0-ios" in the TargetFrameworks for your project. You may have to
e also include "ios-arm64" in your project's RuntimeIdentifiers.

So RuntimeIdentifiers (Plural) is correct in my case. With my posted settings I am at least able to "build" and sign but it fails on last step. I've now added the server IP, username and password etc. into the csproj file. And now I no longer get the error above instead something else when it tries to optimize the assembly size (linker aka AOT):

The assembly size is optimized, this can change the behavior of the app. Make sure to post-release testing. See https://aka.ms/dotnet-illink for information.

MessagingRemoteException: An error occurred on client Build while executing a reply for topic
 xvs/build/execute-task/xxx/f3ca8f6002fMergeAppBundles [C:\xxxs\xxx\source\repos\xxx\xxx\xxx.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.303\targets\Xamarin.Shared.Sdk.targets(366,3): error : 
AggregateException: One or more errors occurred. (The method or operation is not implemented.) [C:\xxxs\xxx\source\repos\xxx\xxx\xxx.csproj]
C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\15.4.303\targets\Xamarin.Shared.Sdk.targets(366,3): error : 
NotImplementedException: The method or operation is not implemented. [C:\xxxs\xxx\source\repos\xxx\xxx\xxx.csproj]

Symbai avatar Jun 05 '22 23:06 Symbai

@Symbai Sorry to hear, that it doesn't work for you. So if I understand you correctly, you have now the same error as I had

Xamarin.Shared.Sdk.targets(366,3) MessagingRemoteException, AggregateException and NotImplementedException

but if you apply the solution that worked for me you get another error?

Today I had a new error popping up and I could solve it by deleting these folders, bin, obj and .vs

otium99 avatar Jun 06 '22 11:06 otium99