dotnet / dotnet/msbuild

Building vcxproj with P2P to multi-targeting csproj fails in Visual Studio build or CLI with BuildProjectReferences=false

Open
#7,518 5 comments 1 reaction 0 assignees View on GitHub
bug needs-design Partner request triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

vcxproj fails to set the `TargetFramework` global property on a P2P to a multi-targeting csproj when `BuildProjectReferences` is set to false, which VS does by default.

### Steps to Reproduce

Repro solution: [MTvcTest.zip](https://github.com/dotnet/msbuild/files/8414587/MTvcTest.zip)

1. Create a VS solution
2. Add a csproj (SDK style) that targets net6.0 and net472
3. Add a vcxproj
4. Add a P2P from the vcxproj to the csproj
5. Build

### Expected Behavior

The build succeeds in VS and msbuild.exe

### Actual Behavior

The build succeeds at the command line and fails in VS.
It also fails at the CLI when `/p:buildprojectreferences=false` is specified.
See [binlog](https://microsoft-my.sharepoint.com/:u:/p/andarno/EWS3j458QutJuQLo4mE5TQgBnRJZfOFiCpbg1w6N3XMztg?e=jEdMHU).

> "C:\temp\MTvcTest\VCApp\VCApp.vcxproj" (default target) (1) ->
"C:\temp\MTvcTest\CSharpLib\CSharpLib.csproj" (GetTargetPath target) (2:4) ->
C:\temp\MTvcTest\CSharpLib\CSharpLib.csproj : error MSB4057: The target "GetTargetPath" does not exist in the project.

### Analysis

The `TargetFramework` global property isn't set when invoking the P2P.

### Versions & Configurations

Microsoft (R) Build Engine version 17.2.0-preview-22178-04+ce7523296 for .NET Framework

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.