dotnet/msbuild

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

Open

#10.657 aberto em 12 de set. de 2024

Ver no GitHub
 (4 comments) (0 reactions) (0 assignees)C# (1.364 forks)batch import
help wantedtriaged

Métricas do repositório

Stars
 (5.062 stars)
Métricas de merge de PR
 (Mesclagem média 11d 7h) (125 fundiu PRs em 30d)

Description

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)

Guia do colaborador