microsoft / microsoft/MSBuildSdks

Traversal SDK ignores SetTargetFramework metadata on ProjectReference

Open
#582 0 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

I have a traversal that is responsible for build and publishing of projects. As such, any references to multi-targeting projects must be referenced with the TargetFramework global property explicitly set, to avoid a build error like this:

C:\Users\User\agent_work_tool\dotnet\sdk\8.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.CrossTargeting.targets(31,5): error NETSDK1129: The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, you must specify one of the following frameworks in order to publish: net8.0, net8.0-windows10.0.22621.0, net8.0-macOS [C:\Users\User\agent_work\1\s\src\Nerdbank.Zcash.App\Nerdbank.Zcash.App.Desktop\Nerdbank.Zcash.App.Desktop.csproj]

So I set the typical ProjectReference metadata to target just the TargetFramework appropriate for the build agent:

<SetTargetFramework>TargetFramework=net8.0-windows10.0.22621.0</SetTargetFramework>

But this was totally ignored, and the project built without TargetFramework set, and it failed on Publish.

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 traversal that builds and publishes projects and the ProjectReference metadata containing SetTargetFramework; reproduce the publish failure described in the issue. The work is done when the specified TargetFramework is honored for the multi-targeting reference and publishing no longer fails with NETSDK1129.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.