dotnet / dotnet/msbuild

[Bug]: Properties not set when both <TargetFramework> and <TargetFrameworks> in project

Open
#9,216 7 comments 0 reactions 0 assignees View on GitHub
backlog Feature: Warning Waves Priority:2 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

### Issue Description

This was reported against Grpc.Tools in https://github.com/grpc/grpc/issues/34306

When a project contains both `` and `` then the properties defined in the NuGet package Grpc.Tools are not set (causing later problems). When just one of `` and `` is present (either one) then the properties are set and the build succeeds as expected.

### Steps to Reproduce

Here is a simple project file to reproduce the problem:

```xml


Library
enable
enable


net6.0;net7.0
net7.0









```

Run with:
`dotnet build`

### Expected Behavior

Successful (e.g. only `` set:
```
PS E:\work\grpc\issues\is34306> dotnet build
MSBuild version 17.7.1+971bf70db for .NET
Determining projects to restore...
Restored E:\work\grpc\issues\is34306\project.csproj (in 135 ms).
project -> E:\work\grpc\issues\is34306\bin\Debug\net7.0\project.dll
**** Protobuf_PackagedToolsPath = C:\Users\tonyn\.nuget\packages\grpc.tools\2.58.0\tools

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:01.20
```

### Actual Behavior

Failure when both set:
```
PS E:\work\grpc\issues\is34306> dotnet build
MSBuild version 17.7.1+971bf70db for .NET
Determining projects to restore...
All projects are up-to-date for restore.
project -> E:\work\grpc\issues\is34306\bin\Debug\net7.0\project.dll
**** Protobuf_PackagedToolsPath =

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:03.82
```

Note: `Protobuf_PackagedToolsPath` has not been set above

### Analysis

_No response_

### Versions & Configurations

MSBuild version: 17.7.1+971bf70db

(Also seen with other versions)

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.