C
C#2y ago
aggieben

✅ Insert a Directory.Build target into project dependency pipeline

The question was a bit too long to fit into this format, so I posted it here: https://stackoverflow.com/questions/76132805/insert-a-directory-build-target-into-project-dependency-pipeline TL;DR; - I have a target in Directory.Build.targets that I want to execute during the build of every project built by my solution, especially when it's building projects that are pulled in by project reference as dependencies, but it only runs for some projects.
Stack Overflow
Insert a Directory.Build target into project dependency pipeline
I have projects spread across two solutions, call them Mine.sln and Theirs.sln (and they live in separate repositories). The projects in Theirs are all dependencies for Mine. The two solutions are
15 Replies
JakenVeina
JakenVeina2y ago
I think, in theory, you should be able to have your Directory.Build.targets file override all the <HintPath> values to null, with just MSBuild syntax like, I use Directory.Build.targets to partially-override PackageReference options, as follows
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Update="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Update="System.Reactive" Version="5.0.0" />
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Update="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
<PackageReference Update="System.Reactive" Version="5.0.0" />
so, something like
<PackageReference Update="*" HintPath="" />
<PackageReference Update="*" HintPath="" />
might work? really, this whole setup sounds kinda nuts
aggieben
aggiebenOP2y ago
unfortunately I don't even have PackageReference to work with; this is pre-SDK yes
JakenVeina
JakenVeina2y ago
you're pulling projects NOT in your own source control into your solution
aggieben
aggiebenOP2y ago
it is my own source control, just separate repositories (because separate teams)
JakenVeina
JakenVeina2y ago
right spanning a solution across multiple repositories just reeeeeally seems like a poor setup
aggieben
aggiebenOP2y ago
this setup is 100% nuts, but I was hoping to do this more-or-less in isolation; if I try to tackle the real problem, then it's a whole cross-team thing with lots of process and friction
JakenVeina
JakenVeina2y ago
understandable which is why I'm not gonna just say "you're dumb, change your setup" professionals do all kindsa dumb shit in the real world, to get by
aggieben
aggiebenOP2y ago
innit, tho?
JakenVeina
JakenVeina2y ago
but yeah, I dunno of a good solution here I kinda forget what the precursor to PackageReference is but it OUGHT to behave the same sorta way as PackageReference as far as MSBuild syntax goes
aggieben
aggiebenOP2y ago
there wasn't really a precursor. it's AssemblyReference with HintPath, and it's managed by the IDE.
JakenVeina
JakenVeina2y ago
well, that's what I was referring to
aggieben
aggiebenOP2y ago
the super weird thing here is that even if I just attach my target to a target (like Build) that has to run for literally every project and project dependency, recursively, I don't get the Message output I would expect.
aggieben
aggiebenOP2y ago
Stack Overflow
How does ResolveProjectReferences work?
I want to profile and tweak our build hoping to save few seconds here and there. I was able to create a task that derives from ResolveAssemblyReferences and use it instead, but I'm having problems in
aggieben
aggiebenOP2y ago
and I wonder if that MSBuild task that actually builds the dependencies doesn't pick up the Directory.Build.targetsfile from the originating solution although that doesn't completely answer it for me, because I do get messages for a couple of the dependency projects and I haven't yet figured out why aha. I think I figured that part out: there's another Directory.Build.targets in the Theirs.sln solution directory <:picard_facepalm:616692703685509130>
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server