Open flakey-bit opened 9 months ago
Ironically, Directory.Build.Props
& Directory.Build.Targets
files make keeping things consistent easier - however they make checking things are consistent harder 🤔
Good spotting @flakey-bit. Fixing this would be reasonably straight-forward. I'll either get to it eventually, or someone can pick it up, I've labelled it a good first issue if someone happens to come by and wants to contribute.
Fixing this would be reasonably straight-forward
@andrewabest do you have some thoughts in mind as to how we could address this?
I was thinking you would essentially have to replicate what MSBuild does - for any project, locate the directory.build.props file closest to it, and consider its values in applying the convention (docs)
It can get a bit complex, but we could support the simpler version of it: don't support multiple props files, just support the nearest one per project.
I think you're suggesting that we should fully evaluate the project XML and pass the "composed" csproj
(i.e. post-application of Directory.Build.Props
& Directory.Build.Targets
) to Conventional conventions (in other words, treating it as a templating system).
If so, I agree 👍
It would be neat if we could do so by leveraging MSBuild, rather than reimplementing it. If we can find a way to do that I guess we'd get full support (multiple props files etc) "for free".
Yup, strong agree there. I know dotnet-affected uses MsBuild internally (example), so it is very possible that that is a doable thing.
MSBuild allows templating / "meta-programming" of
csproj
files viaDirectory.Build.Props
&Directory.Build.Targets
- see this page for more background but basicallyDirectory.Build.Props
allows setting default property values across all projects in the directory (recursively)Directory.Build.Targets
allows setting dependant property values (i.e. incorporating customizations from individual projects)At least that's my understanding - haven't used
Directory.Build.Targets
myself.Existing conventions like
MustNotReferenceDllsFromTransientOrSdkDirectoriesConventionSpecification
that parse the project XML are unaware of this functionality and are arguably broken as a result.For example, a
Directory.Build.Props
file could add an (assembly) Reference w/ a HintPath to all projects in the directory, whichMustNotReferenceDllsFromTransientOrSdkDirectoriesConventionSpecification
would be unaware of when examing the project XML, leading to false-negative.