Skip to content

dotnet build -graph -isolate -r <rid> fails for an app with a class library reference: GetTargetFrameworks is called without RuntimeIdentifier (MSB4252) #15711

In review

Description

@Nucs

Issue Description

With a global RuntimeIdentifier, an isolated static graph build of a console app that references a class library fails with MSB4252 in _GetProjectReferenceTargetFrameworkProperties. The same build without -r succeeds. It reproduces with the default console and classlib templates on .NET SDK 10.0.101 and 11.0.100.

Steps to Reproduce

dotnet new console -o app
dotnet new classlib -o lib
dotnet add app reference lib
dotnet restore app -r win-x64
dotnet build app -graph -isolate -r win-x64 --no-restore

The restore comes first because restore itself fails under -isolate (#6856). The RID is this machine's; any RID behaves the same way.

Expected Behavior

The build succeeds, as it does without -r:

dotnet restore app
dotnet build app -graph -isolate --no-restore

Actual Behavior

Microsoft.Common.CurrentVersion.targets(1861,5): error : MSB4252: Project "app\app.csproj" with global properties
    (NuGetInteractive=false; RuntimeIdentifier=win-x64; _CommandLineDefinedRuntimeIdentifier=true; IsGraphBuild=true)
    is building project "lib\lib.csproj" with global properties
    (NuGetInteractive=false; _CommandLineDefinedRuntimeIdentifier=true; IsGraphBuild=true)
    with the (GetTargetFrameworks) target(s) but the build result for the built project is not in the engine cache. In isolated builds this could mean one of the following:
    - the reference was called with a target which is not specified in the ProjectReferenceTargets item in project "app\app.csproj"
    - the reference was called with global properties that do not match the static graph inferred nodes
    - the reference was not explicitly specified as a ProjectReference item in project "app\app.csproj"

That is SDK 11.0.100. SDK 10.0.101 gives the same error from Microsoft.Common.CurrentVersion.targets(1844,5).

Analysis

_GetProjectReferenceTargetFrameworkProperties calls GetTargetFrameworks on each reference with RemoveProperties="...;TargetFramework;RuntimeIdentifier;SelfContained;...". So it asks for lib without the global RuntimeIdentifier=win-x64, a node the static graph did not predict, and -isolate rejects the call.

Versions & Configurations

  • .NET SDK 11.0.100 (MSBuild 18.12.2.53018), templates targeting net11.0
  • .NET SDK 10.0.101 (MSBuild 18.0.6.57005), templates targeting net10.0
  • Windows 11 x64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions