dotnet / dotnet/msbuild

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

Open
#10,657 4 comments 0 reactions 1 assignee Claimed by @VolPlita View on GitHub
help wanted triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/Usage-of-msbuild-switch-graphBuild-appe/10743440)._

---
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

```



```

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)

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.