You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The metaproj msbuild file generated due to interproject dependencies inside the solution being built does not respect the SkipNonexistentTargets property
#11025
Open
MarkKharitonov opened this issue
Nov 23, 2024
· 0 comments
Solution wide target specified in Directory.Solution.targets produces the error MSB4057 despite the use of the MSBuild.SkipNonexistentTargets property. It only happens when the solution file captures interproject dependencies.
Now let us build the xyz target through the a.sln solution:
C:\work\msbuild_sln_bug> dotnet build .\a.sln /t:xyz
Determining projects to restore...
Restored C:\work\msbuild_sln_bug\b.csproj (in 111 ms).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:03.28
Workload updates are available. Run `dotnet workload list` for more information.
C:\work\msbuild_sln_bug>
And now using the solution b.sln:
C:\work\msbuild_sln_bug> dotnet build .\b.sln /t:xyz
Determining projects to restore...
All projects are up-to-date for restore.
C:\work\msbuild_sln_bug\a.csproj : error MSB4057: The target "xyz" does not exist in the project.
Build FAILED.
C:\work\msbuild_sln_bug\a.csproj : error MSB4057: The target "xyz" does not exist in the project.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.89
Workload updates are available. Run `dotnet workload list` for more information.
C:\work\msbuild_sln_bug>
Expected Behavior
Both solutions build the xyz target in exactly the same fashion - no errors on the non existing target xyz.
Actual Behavior
The solution with the interproject dependencies fails.
Analysis
When there are interproject dependencies extra metaproj msbuild files are created in addition to the one corresponding to the solution itself. These extra metaproj files replicate the xyz solution wide target, but omit the SkipNonexistentTargets property found in the original Directory.Solution.targets file.
Versions & Configurations
C:\work\msbuild_sln_bug> msbuild -version
MSBuild version 17.11.9+a69bbaaf5 for .NET Framework
17.11.9.46202
C:\work\msbuild_sln_bug>
The text was updated successfully, but these errors were encountered:
Issue Description
Solution wide target specified in
Directory.Solution.targets
produces the errorMSB4057
despite the use of theMSBuild.SkipNonexistentTargets
property. It only happens when the solution file captures interproject dependencies.Steps to Reproduce
Consider the following trivial project layout:
Where:
a.csproj
b.csproj is identical to a.csproj
a.sln
b.sln
Directory.Solution.targets
Notice that the
b.sln
file is a copy of thea.sln
, except that one project is made to depend on the other project inside the solution fileb.sln
:Now let us build the
xyz
target through thea.sln
solution:And now using the solution
b.sln
:Expected Behavior
Both solutions build the
xyz
target in exactly the same fashion - no errors on the non existing targetxyz
.Actual Behavior
The solution with the interproject dependencies fails.
Analysis
When there are interproject dependencies extra metaproj msbuild files are created in addition to the one corresponding to the solution itself. These extra metaproj files replicate the
xyz
solution wide target, but omit theSkipNonexistentTargets
property found in the originalDirectory.Solution.targets
file.Versions & Configurations
The text was updated successfully, but these errors were encountered: