Solution dependency leads to error MSB4057: The target "GetTargetPath" does not exist in the project
See original GitHub issueThere 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
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>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
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.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:6
- Comments:21 (2 by maintainers)
Top Results From Across the Web
MSBuild: error MSB4057: The target does not exist in ...
The problem comes from the fact that such project is nested inside a solution folder ( Tests in this example) in the Solution...
Read more >Mix of old-style and new SDK-style .csproj files in the same ...
I'm currently stuck at “error MSB4057: The target “GetTargetPath” does not exist in the project.” - which I don't understand - everything I ......
Read more >MSB4057 The target [...] does not exist in the project
When I try to build solution via Menu Build -> Build Solution everything goes fine. ... (I've got localized MSBuild and the real...
Read more >The target "GetTargetPath" does not exist
Hi the following error occurs when i build a solution containing my VSPackage project and a windowsApplication. Error 1 The target ...
Read more >Referencing native projects in Visual Studio (MSBuild).
Native projects must implement GetNativeTargetPath to return list of output files. At run time this target is called and returns list of DLL ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had the same error and somewhat similar to @sebashek, I had two identical project references listed in a single project file. Removing one of the references fixed the issue.
After long struggles with the problem using
include_external_msproject()I finally found an applicable workaround on https://github.com/wixtoolset/issues/issues/5705: