Skip to content
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

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

Closed
nkolev92 opened this issue Mar 7, 2022 · 13 comments · Fixed by NuGet/NuGet.Client#4587
Assignees
Labels
Functionality:Restore Partner:CLI-SDK Partner:Xamarin Priority:1 High priority issues that must be resolved in the current sprint. Product:dotnet.exe Type:DCR Design Change Request
Milestone

Comments

@nkolev92
Copy link
Member

nkolev92 commented Mar 7, 2022

Original bug: dotnet/sdk#21877

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

@nkolev92
Copy link
Member Author

nkolev92 commented Mar 7, 2022

The gist is that NuGet respects both TargetFramework and TargetFrameworks, but in some scenarios, people want to build only for a specific TargetFramework, and NuGet simply wouldn't even look at TargetFramework because TargetFrameworks is set.

2 options:

There are a few trade-offs with either approach.

The first one is a more general solution, but it also has the potential to break more things.
The second is a more specific solution, but if people run `dotnet msbuild -f:TargetFramework=net6.0-ios -p:RuntimeIdentifier:ios-arm64

@nkolev92
Copy link
Member Author

nkolev92 commented Mar 7, 2022

After talking to @dsplaisted, sounds like they want this to be fixed in the next minor release, 6.0.300.

cc @jonathanpeppers @aortiz-msft @JonDouglas

@nkolev92
Copy link
Member Author

nkolev92 commented Mar 8, 2022

In the new issues, we'll discuss it during our next triage meeting Thursday.

fyi @dsplaisted @jonathanpeppers

@dsplaisted
Copy link

@nkolev92 Any update on this? Will this make it into 17.2?

@nkolev92
Copy link
Member Author

We didn't get to it unfortunately.

cc @aortiz-msft @JonDouglas

I think 17.2 is not likely to happen as this is something that would have ideally been scheduled at the beginning of the sprint if it were to make into 17.2.

@nkolev92
Copy link
Member Author

Just adding onto #11653 (comment), both approaches are functionally equivalent for the dotnet build scenario and they'd both fix it.

The first approach allows dotnet msbuild /r /p:TargetFramework to work, but the 2nd approach does not.

@JonDouglas
Copy link
Contributor

@jonathanpeppers & @rolfbjarne would the options above meet your CLI requirements in dotnet/sdk#21877 (comment)?

@rolfbjarne
Copy link

I've never seen anyone do dotnet msbuild ..., and I think it's acceptable to require people to use dotnet build ... instead (at the very least until we know it's an issue in certain scenarios).

@jonathanpeppers
Copy link

I agree dotnet msbuild isn't as important as dotnet build, but we should probably test what happens in an IDE? F5 in Visual Studio would run .NET framework MSBuild and probably passes in -p:TargetFramework.

@nkolev92
Copy link
Member Author

VS doesn't really run msbuild restore, it runs it's own. So when you run F5, you're only building for one framework, but restore is still running for all of them, so the equivalent problem shouldn't exist there.

@nkolev92 nkolev92 added the Priority:1 High priority issues that must be resolved in the current sprint. label Mar 24, 2022
@nkolev92 nkolev92 self-assigned this Mar 30, 2022
@nkolev92
Copy link
Member Author

Whatever we decide to do, the following target would need to be updated to respect is as well:

	<Target Name="_ValidateRuntimeIdentifier"
		Condition="'$(RuntimeIdentifier)' != '' And '$(_RuntimeIdentifierValidation)' != 'false'"
		BeforeTargets="Restore;Build;ResolvedFrameworkReference;ResolveRuntimePackAssets;ProcessFrameworkReferences">
		<PropertyGroup>
			<_IsValidRuntimeIdentifier Condition="@(_XamarinValidRuntimeIdentifier->WithMetadataValue('Platform', '$(_PlatformName)')->WithMetadataValue('Filename', '$(RuntimeIdentifier)')->Count()) &gt; 0">true</_IsValidRuntimeIdentifier>
		</PropertyGroup>
		<Error Condition="'$(_IsValidRuntimeIdentifier)' != 'true'" Text="The RuntimeIdentifier '$(RuntimeIdentifier)' is invalid." />
	</Target>

It's coming from C:\Program Files\dotnet\packs\Microsoft.MacCatalyst.Sdk\15.2.302-preview.14.122\targets\Xamarin.Shared.Sdk.targets on my end.

It would need the exact same logic that we add in NuGet/SDK.
Maybe it's best if we can have a sync with myself, @dsplaisted and whoever is the owner on the Xamarin side?

@rolfbjarne
Copy link

Maybe it's best if we can have a sync with myself, @dsplaisted and whoever is the owner on the Xamarin side?

That would be me.

@nkolev92
Copy link
Member Author

I have something that seems to work, cleaning it up now.
Unfortunately static graph doesn't work #11761.

@nkolev92 nkolev92 modified the milestone: Sprint 2022-05 Apr 25, 2022
@jeffkl jeffkl added this to the 6.3 milestone May 31, 2022
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this issue Jun 27, 2022
Validating that projects are only restored using valid runtime identifiers
have turned out to be an interesting rabbit hole.

Nobody seems to dispute the fact that it's a correct validation, the problem
is that it apparently turns out quite complicated to not do the wrong thing
for projects with multiple target frameworks.

In some scenarios apparently the Restore target might want to restore all
target frameworks, which breaks down if whatever the user wants to do requires
setting a runtime identifier, because then that runtime identifier is set for
all target frameworks.

So for the sake of simplicity, we're going to try removing this validation for
the Restore target (we're keeping it for the Build target).

There are thus two potential scenarios:

1. The Restore succeeds using invalid runtime identifiers. This shouldn't
   affect valid builds (since those should be completely separate due to using
   different runtime identifiers).
2. Something else breaks. At worst the user will be given a less
   comprehensible error message. Time will tell if this is better or worse
   than the current experience.

Ref: NuGet/Home#11653
Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1558247
vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Jul 13, 2022
Validating that projects are only restored using valid runtime identifiers
have turned out to be an interesting rabbit hole.

Nobody seems to dispute the fact that it's a correct validation, the problem
is that it apparently turns out quite complicated to not do the wrong thing
for projects with multiple target frameworks.

In some scenarios apparently the Restore target might want to restore all
target frameworks, which breaks down if whatever the user wants to do requires
setting a runtime identifier, because then that runtime identifier is set for
all target frameworks.

So for the sake of simplicity, we're going to try removing this validation for
the Restore target (we're keeping it for the Build target).

There are thus two potential scenarios:

1. The Restore succeeds using invalid runtime identifiers. This shouldn't
   affect valid builds (since those should be completely separate due to using
   different runtime identifiers).
2. Something else breaks. At worst the user will be given a less
   comprehensible error message. Time will tell if this is better or worse
   than the current experience.

Ref: NuGet/Home#11653
Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1558247
vs-mobiletools-engineering-service2 pushed a commit to vs-mobiletools-engineering-service2/xamarin-macios that referenced this issue Jul 13, 2022
Validating that projects are only restored using valid runtime identifiers
have turned out to be an interesting rabbit hole.

Nobody seems to dispute the fact that it's a correct validation, the problem
is that it apparently turns out quite complicated to not do the wrong thing
for projects with multiple target frameworks.

In some scenarios apparently the Restore target might want to restore all
target frameworks, which breaks down if whatever the user wants to do requires
setting a runtime identifier, because then that runtime identifier is set for
all target frameworks.

So for the sake of simplicity, we're going to try removing this validation for
the Restore target (we're keeping it for the Build target).

There are thus two potential scenarios:

1. The Restore succeeds using invalid runtime identifiers. This shouldn't
   affect valid builds (since those should be completely separate due to using
   different runtime identifiers).
2. Something else breaks. At worst the user will be given a less
   comprehensible error message. Time will tell if this is better or worse
   than the current experience.

Ref: NuGet/Home#11653
Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1558247
rolfbjarne added a commit to xamarin/xamarin-macios that referenced this issue Jul 14, 2022
…tore. (#15491)

Validating that projects are only restored using valid runtime identifiers
have turned out to be an interesting rabbit hole.

Nobody seems to dispute the fact that it's a correct validation, the problem
is that it apparently turns out quite complicated to not do the wrong thing
for projects with multiple target frameworks.

In some scenarios apparently the Restore target might want to restore all
target frameworks, which breaks down if whatever the user wants to do requires
setting a runtime identifier, because then that runtime identifier is set for
all target frameworks.

So for the sake of simplicity, we're going to try removing this validation for
the Restore target (we're keeping it for the Build target).

There are thus two potential scenarios:

1. The Restore succeeds using invalid runtime identifiers. This shouldn't
   affect valid builds (since those should be completely separate due to using
   different runtime identifiers).
2. Something else breaks. At worst the user will be given a less
   comprehensible error message. Time will tell if this is better or worse
   than the current experience.

Ref: NuGet/Home#11653
Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1558247


Backport of #15357

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
rolfbjarne added a commit to xamarin/xamarin-macios that referenced this issue Jul 14, 2022
…tore. (#15490)

Validating that projects are only restored using valid runtime identifiers
have turned out to be an interesting rabbit hole.

Nobody seems to dispute the fact that it's a correct validation, the problem
is that it apparently turns out quite complicated to not do the wrong thing
for projects with multiple target frameworks.

In some scenarios apparently the Restore target might want to restore all
target frameworks, which breaks down if whatever the user wants to do requires
setting a runtime identifier, because then that runtime identifier is set for
all target frameworks.

So for the sake of simplicity, we're going to try removing this validation for
the Restore target (we're keeping it for the Build target).

There are thus two potential scenarios:

1. The Restore succeeds using invalid runtime identifiers. This shouldn't
   affect valid builds (since those should be completely separate due to using
   different runtime identifiers).
2. Something else breaks. At worst the user will be given a less
   comprehensible error message. Time will tell if this is better or worse
   than the current experience.

Ref: NuGet/Home#11653
Ref: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1558247


Backport of #15357

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Functionality:Restore Partner:CLI-SDK Partner:Xamarin Priority:1 High priority issues that must be resolved in the current sprint. Product:dotnet.exe Type:DCR Design Change Request
Projects
None yet
7 participants