Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory.Build.props is ignored on target framework resolution #166

Open
Inok opened this issue Jan 24, 2021 · 5 comments
Open

Directory.Build.props is ignored on target framework resolution #166

Inok opened this issue Jan 24, 2021 · 5 comments
Labels
⚠ Bug Something isn't working as expected

Comments

@Inok
Copy link

Inok commented Jan 24, 2021

When Buildalizer tries to resolve target framework of a project and to choose an appropriate MSBuild version (Core vs .NET Framework), it reads target framework from csproj file. The problem is, we set target framework globally in a single Directory.Build.props file instead of configuring it at all csproj files.
When Buildalizer doesn't know target framework, it always chooses .NET Framework version of MSBuild, ignoring the fact that our projects targets .NET 5.
The build still works, so maybe there is no difference between those MSBuild versions and the issue is minor. But it leads us to another problem described at #165

@daveaglick daveaglick added the ⚠ Bug Something isn't working as expected label Jan 24, 2021
@daveaglick
Copy link
Collaborator

That's a good find. Even if the build is working for your project (sometimes the differences between the Framework and Core MSBuild don't come into play), there are definitely times when this will result in a bad build.

@leonardochaia
Copy link

Hi. Side question, is there a way to know that a project has received any configuration from Directory.Build.props?

I'm considering using this package under the hood for dotnet-affected
Supporting which projects are affected by changes made to a Directory.Build.props is a desired feature.

Regards,
Leo.

@daveaglick
Copy link
Collaborator

is there a way to know that a project has received any configuration from Directory.Build.props

Probably not, at least not without some additional work. Buildalyzer is primarily aimed at capturing what gets sent to the Csc (or other language compiler) task. To do that it hooks MSBuild and logs MBuild events, so other information is going to be flowing through that stream, but at the moment we don't really capture or process any of it.

If we were to expand what gets captured it would probably need to happen here: https://github.com/daveaglick/Buildalyzer/blob/main/src/Buildalyzer/Logging/EventProcessor.cs

@leonardochaia
Copy link

Hi @daveaglick , thanks for the link. I did some debugging and I discovered there are properties for DirectoryBuildPropsPath already that includes the path when a Directory.Build.props file is present. I think that'll be enough for my use case.

For the record: DirectoryBuildPropsPath, DirectoryBuildTargetsPath, DirectoryPackagesPropsPath

@ricardoboss
Copy link

My experience with Directory.Build.props not being loaded is a little different, but still problematic. When performing the design time build, the resulting IAnalyzerResults contains no source files.
Funnily enough, this only happens on Windows. On macOS this works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚠ Bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

4 participants