msbuild
msbuild copied to clipboard
Item to define custom non-ProjectReference edge in graph
Several build processes (repos, SDKs, and NuGet packages) have a pattern where they want to do a thing "once per build"--maybe set up versioning, or run some code generator, or something.
Ideally it would be easy to express this in a -graph -isolate
compatible way by creating an item something like
<MSBuildGraphEdge Include="my/weird/project.proj"
Targets="This;List;Overrides"
Properties="Foo=Bar;" />
This would be a totally new edge, ignoring target propagation.
This would probably also be the solution to making the notorious nuget pack
work with static graph builds: https://github.com/dotnet/msbuild/issues/6197
Friendly ping on this, @rainersigwald. We have a VS UI manifesting bug that I'm guessing might not be fixed, so it would be great if we could solve this graph edge problem without creating a ProjectReference item.
I've had at least 10 bugs in Nerdbank.GitVersioning reported because of NB.GV trying to be a good citizen by declaring a ProjectReference item for its self-invocation via an msbuild task. Without this ProjectReference item, -graph -isolate
fails for Nerdbank.GitVersioning projects. But with this item, at least 10 project types fail to build because they indiscriminately execute their ProjectReference items with assumptions about how they should behave, targets they implement, or files that would be in one of their directories.
I'm about to just remove the ProjectReference item and break -graph -isolate scenarios given how much trouble it's caused for customers. Can you give me an alternative?
I would break -graph -isolate
without hesitation in your scenario; do you have any customers that you're aware of that use it?
No customers for that, no. I just anticipated them and wanted to be future proof.
FWIW I wanted to be one of those customers but I never got far enough to get there. Nerdbank.GitVersioning was one of the obstacles.
There is an msbuild property for graph-based builds, I think. Is there for isolated graph builds as well? If so, maybe NB.GV could add a condition on the ProjectReference
item so it only exists for (isolated) graph based builds. That way folks like @filipnavara remain unblocked but it stays out of the way for a majority of customers.
The 3.6 update of NB.GV will remove the ProjectReference
item except when IsGraphBuild=true
.
https://github.com/dotnet/Nerdbank.GitVersioning/pull/847