msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Item to define custom non-ProjectReference edge in graph

Open rainersigwald opened this issue 2 years ago • 2 comments

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.

rainersigwald avatar Sep 15 '21 14:09 rainersigwald

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

cdmihai avatar Sep 16 '21 01:09 cdmihai

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.

AArnott avatar Jul 30 '22 03:07 AArnott

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?

AArnott avatar Oct 19 '22 02:10 AArnott

I would break -graph -isolate without hesitation in your scenario; do you have any customers that you're aware of that use it?

rainersigwald avatar Oct 19 '22 14:10 rainersigwald

No customers for that, no. I just anticipated them and wanted to be future proof.

AArnott avatar Oct 19 '22 20:10 AArnott

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.

filipnavara avatar Oct 19 '22 20:10 filipnavara

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.

AArnott avatar Oct 20 '22 04:10 AArnott

The 3.6 update of NB.GV will remove the ProjectReference item except when IsGraphBuild=true. https://github.com/dotnet/Nerdbank.GitVersioning/pull/847

AArnott avatar Oct 22 '22 16:10 AArnott