dotnet / dotnet/msbuild

Solution dependency leads to error MSB4057: The target "GetTargetPath" does not exist in the project

Open
#4,303 24 comments 12 reactions 0 assignees View on GitHub
Area: Solution (.sln) triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

There is a problem with solution dependencies that I believe was introduced with MSBuild 15.9, and is also a problem with 16.0.

The following scenario causes the problem;
- There is a project that has `true` set
- It has a solution dependency on a second project, and that project is multi-targeted.

### Steps to reproduce

Build the attached project with `MSBuild.exe` or `dotnet build`: [GetTargetPathRepro.zip](https://github.com/Microsoft/msbuild/files/3070674/GetTargetPathRepro.zip)

### Expected behavior

The solution should compile without errors.

### Actual behavior
The following error occurs:
```
"C:\Users\Brandon\source\repos\GetTargetPathRepro\GetTargetPathRepro.sln" (default target) (1:2) ->
"C:\Users\Brandon\source\repos\GetTargetPathRepro\ClassLibrary1\ClassLibrary1.csproj.metaproj" (default target) (4) ->
"C:\Users\Brandon\source\repos\GetTargetPathRepro\ClassLibrary1\ClassLibrary1.csproj" (default target) (2:6) ->
"C:\Users\Brandon\source\repos\GetTargetPathRepro\ClassLibrary1\ClassLibrary1.csproj" (_GetFrameworkAssemblyReferences target) (2:10) ->
"C:\Users\Brandon\source\repos\GetTargetPathRepro\ClassLibrary2\ClassLibrary2.csproj" (GetTargetPath target) (3:15) ->
C:\Users\Brandon\source\repos\GetTargetPathRepro\ClassLibrary2\ClassLibrary2.csproj : error MSB4057: The target "GetTargetPath" does not exist in the project.

0 Warning(s)
1 Error(s)
```

### Environment data
It repros with MSBuild 15.9.21.664 and 16.0.461.62831.
It also repros with .NET Core SDK 2.2.106 and 3.0.100-preview3-010431

I believe it worked fine before MSBuild 15.9, but I don't know an exact version.

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.