-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 should be imported before SDK props do anything #924
Comments
Isn't this an MSBuild issue? It is the one who imports the Sdk.props and then the |
So in this case, its and SDK issue not an MSBuild issue. That is unless we want to change the SDK to import https://github.com/Microsoft/msbuild/blob/xplat/src/Tasks/Microsoft.Common.props#L133 |
My point is: if we import If we think |
That's up to the Sdk. MSBuild's evaluation order constraints make this complicated--usually you want to set some stuff early and some stuff after common.props. We can't disconnect the directory.build.props import from common.props (it has to be somewhere). If it's not in the right place for
This is a limitation of the ordered-evaluation + import-whole-files + extensibility nature of MSBuild. We could change the order of imports but that only postpones the problem. We could shard into more files, but that pushes complexity into other layers (it'd be unpleasant if SDK.props had to import a dozen files from common in the right relative order, just to allow the possibility of avoiding this problem. |
I think it generally makes sense for an SDK to pull in d.b.props first and disable the common.props import. The idea of d.b.props is that it's imported early. In the (old) default template, the common.props import was the first line, and the d.b.props import is very early in common.props--so d.b.props in the old world is basically first. If we wind up making the core SDK a package (dotnet/msbuild#1686), we could separate out the d.b.props import into its own file so it could be more easily called by an SDK. Then the pattern for sdks could be <Import Project="Directory.Build.props" Sdk="Core" />
<Import Project="$(MSBuildThisFileDirectory)..\build\Microsoft.NET.Sdk.props" />
<Import Project="Microsoft.Common.props" Sdk="Core" /> It's unfortunate that this would be a "standard pattern" rather than "done for you" but I don't see a way around it that keeps explicit, ordered imports. |
…0190902.3 (dotnet#924) - Microsoft.AspNetCore.Mvc.Analyzers - 3.0.0-rc1.19452.3 - Microsoft.AspNetCore.Mvc.Api.Analyzers - 3.0.0-rc1.19452.3 - Microsoft.AspNetCore.Analyzers - 3.0.0-rc1.19452.3 - Microsoft.AspNetCore.Components.Analyzers - 3.0.0-rc1.19452.3
Using a
Directory.Build.props
file is one way we've told people to set properties before the common props run (see dotnet/msbuild#1603). However,Directory.Build.props
is currently evaluated afterMicrosoft.NET.Sdk.props
, which means setting some properties such as theConfiguration
orPlatform
inDirectory.Build.props
leads to inconsistent results, as there are other default property values which are based on them inMicrosoft.NET.Sdk.props
.A fix to this would be to duplicate the logic from MSBuild that imports
Directory.Build.props
in the SDK targets, and then setImportDirectoryBuildProps
to false so that the common props don't try to import it again.This would be a breaking change for projects that rely (likely accidentally) on the current behavior, so we'd need to assess the compat risk of this change.
The text was updated successfully, but these errors were encountered: