dotnet/msbuild

Usage of msbuild switch /graphBuild appears to cause after.[solutionname].sln.targets not being loaded

Open

#10,657 建立於 2024年9月12日

在 GitHub 查看
 (4 留言) (0 反應) (0 負責人)C# (5,062 star) (1,364 fork)batch import
help wantedtriaged

描述

This issue has been moved from a ticket on Developer Community.


I recently notice that if I use the /graphBuild:true switch for msbuild.exe command line, it will ignore the targets specified in the after.[solutionname].sln.targets file.

For a quick repro, just use Visual Studio project creation template and to create a c++ console program project, and at the location where the solution .sln file is created, add a after.[solutionname].sln.targets file and in the file add the content

<Project>
 <Target Name="EmitCustomMessage" BeforeTargets="Build">
   <Message Importance="High" Text="---- Test Message ----" />
 </Target>
</Project>

When I do a build using msbuild.exe, I see that "Test Message" output:

D:\tmp\vs2022\TestSolution>"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" "/p:Configuration=Release;Platform=x64" /t:build
MSBuild version 17.10.4+10fbfbf2e for .NET Framework
Build started 9/11/2024 10:25:11 AM.

Project "D:\tmp\vs2022\TestSolution\TestSolution.sln" on node 1 (build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Release|x64".
EmitCustomMessage:
  ---- Test Message ----
Project "D:\tmp\vs2022\TestSolution\TestSolution.sln" (1) is building "D:\tmp\vs2022\TestSolution\TestProject\TestProject.vcxproj" (2) on node 1 (default targets).
PrepareForBuild:
...

But if I deleted the output folder and try again with /graphBuild:true, I don't see the "Test Message" being displayed as if that file doesn't exist.

D:\tmp\vs2022\TestSolution>"C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin\MSBuild.exe" "/p:Configuration=Release;Platform=x64" /t:build /graphBuild:true
MSBuild version 17.10.4+10fbfbf2e for .NET Framework
Build started 9/11/2024 10:25:38 AM.

Static graph loaded in 0.11 seconds: 1 nodes, 0 edges
Project "D:\tmp\vs2022\TestSolution\TestProject\TestProject.vcxproj" on node 1 (build target(s)).
PrepareForBuild:
...

Can someone fix this?


Original Comments

(no comments)


Original Solutions

(no solutions)

貢獻者指南