microsoft / microsoft/MSBuildSdks

ProjectReferences do not work for a NoTargets project that sets TargetFrameworks and NoTargetsDoNotReferenceOutputAssemblies

Open
#469 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
508
Forks
94
Avg merge
6h 40m
Merged PRs (30d)
2

Description

It seems that the NoTargets project is getting confused if it's in an outer or inner build.

Try the attached repro:
noBuildCrossTargeting.zip

When building this you'll see:

C:\Program Files\dotnet\sdk\8.0.100-preview.7.23369.9\Microsoft.Common.CurrentVersion.targets(1842,5): error : Project
'..\lib\lib.csproj' targets 'net8.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.0'. [
C:\scratch\noBuildCrossTargeting\notargets\notargets.proj]

This is happening because common targets is setting TargetFrameworkIdentifier and TargetFrameworkVersion. Probably the fix here is to see what happens in outer build of a CSProj and try to match that.

cc @carlossanlop @ViktorHofer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the attached noBuildCrossTargeting.zip repro and compare the outer and inner builds of the NoTargets project with a CSProj outer build. Inspect how Microsoft.Common.CurrentVersion.targets sets TargetFrameworkIdentifier and TargetFrameworkVersion. Done means ProjectReferences build without the reported .NETFramework/net8.0 compatibility error when TargetFrameworks and NoTargetsDoNotReferenceOutputAssemblies are used.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.