-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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.targets not imported when cross-targeting #1721
Comments
@srivatsn FYI |
Nevermind I repro'd this incorrectly. You are correct, the outer build does not import |
We don't import common targets by design because there are a lot of assumptions in it that don't hold for outer build. It is not really possible to give meaningful semantics to every target in common targets in the outer context. That said, not importing Directory.* is an oversight. We may want to introduce Directory.CrossTargeting.targets so that we can support the scenario in a non breaking way. This would be consistent with nuget model where separate files are used to augment inner and outer build. |
Do we really need a separate file? The detection whether the current build is inner or outer is simple, if anyone needs to distinguish in the file. |
I agree with @tmat, we should just import |
If we use only one file, this would be a breaking change so we need to decide that we're prepared to make it or push to get it in right now. I'm not near a dev setup right now, but I would think that Directory.Build.props is already imported. If so, this can be used to hack a workaround: Set CustomAfterMicrosoftCommonCrossTargetingTargets to Directory.Build.targets in Directory.Build.props. However, those CustomXxx points are perilous, because they suffer from the "What if two components do this?" problem. |
|
I mean it's breaking if we ship MSBuild 15 like it is now and then start importing it in MSBuild 16. |
Consider a common case: AfterTargets="Build", this would run only in inner build today, but start to run in both after change. |
Ah I see, I misunderstood. So you're saying if we don't fix it for RTM, then we'll need a new file for future releases.... |
Or maybe honor a safe opt-in from Directory.Build.props: Or have the courage and permission to break. |
We should at least talk about it (bar check it as potentially now-or-never) in ship room. Just fixing it will simplify things for the long haul. |
I did more experiments and it seems like Directory.build.props is imported but Directory.build.targets isn't. Odd. |
We're going to bar check this with management to see what they think. The change is a copy/paste from one file to another so the risk is very low but it might be too late. |
FYI this will have to be in a future update. It won't be in VS2017 RTW. |
Hi. What's the state of this issue? |
@JunielKatarn looks like the changes from #1722 are available in our latest packages (I checked Microsoft.Build.Runtime 15.2.0-preview-000103-02, but not yet pulled into the CLI or VS builds. I believe this will go out with the 15.3 update. |
@rainersigwald thanks! I think this use case is worth a short sample in the official docs. Is there a way to contribute to them? |
Microsoft.Common.CrossTargeting.targets doesn't import these. As a result properties and tasks defined in Directory.build.props, Directory.build.targets are not available in the outer build.
Repro:
If the project targets a single framework like so:
The target is invoked as expected:
The text was updated successfully, but these errors were encountered: