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

Don't double import WinFX targets #2976

Merged
merged 4 commits into from
Jan 12, 2021

Conversation

Nirmal4G
Copy link
Contributor

@Nirmal4G Nirmal4G commented May 10, 2020

Don't import .NET Framework's WinFX targets, When the SDK's implementation is being used and vice versa.
Also, there's no straight forward way to switch between either WinFX targets as needed. This patch provides such mechanism through ImportFrameworkWinFXTargets.

Reason

We (and possibly many others like me) have a large set of NETCLR WPF projects that can't move to CoreCLR right now. I have recently converted them to sdk-style projects with the WindowsDesktop SDK which includes custom tasks that are meant for Full framework projects. We also have some silverlight projects to maintain and I recently converted them to sdk-style too. Seems they also need WinFX targets.

So, to use the official WindowsDesktop, we want to switch between either WinFX targets for our custom tasks to take effect. This patch is just allowing that. We're migrating our projects and tools to .NET CoreCLR and it'll take some time. Until then, we need this ability to maintain our projects.

Reference: dotnet/msbuild#4948

@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label May 10, 2020
@ghost ghost requested review from fabiant3, ryalanms and SamBent May 10, 2020 22:58
@Nirmal4G Nirmal4G marked this pull request as ready for review May 10, 2020 22:58
@Nirmal4G Nirmal4G requested a review from a team as a code owner May 10, 2020 22:58
@rainersigwald
Copy link
Member

Please don't merge this until discussion on dotnet/sdk#11606 has come to a decision whether it's the right thing to do. I suspect it won't be necessary.

@vatsan-madhavan
Copy link
Member

vatsan-madhavan commented May 21, 2020

Typing from memory, please verify before acting on this information.

When using WindowsDesktop SDK -

  • When MSBuildRuntimeType==Core, NetFx copy of WinFx.targets is not imported anyway, IIRC.
  • When MSBuildRuntimeType==Full, WindowsDesktop SDK's copy of WinFx.props (for which there is no analogue in NetFx) is imported early on and effectively supersedes settings included by NetFx's copy of WinFx.targets.

I'm not sure how this interacts with UseWpf==false && UseWindowsForms==false. My guess is that WinFx.props based supersedence would work irrespective of UseWpf/UseWindowsForms settings.

When not using WindowsDesktop SDK,

  • If MSBuildRuntimeType==Core, NetFx's copy of WinFx.targets is not imported; same as before.
  • If MSBuildRuntimeType==Full, NetFx's copy of WinFx.targets is likely imported, but WindowsDesktop SDK's copy of WinFx.props is not imported; thus there is no supersedence in place for ensuring that NetFx's copy of WinFx.targets gets turned off overridden.

This only matters when both UseWpf==false && UseWindowsForms==false. Setting either one without including the WindowsDesktop SDK is a warning state in the base NET.Sdk (which can be suppressed).

The net is that I'm not sure why a further change is needed in the WindowsDesktop SDK. Whenever the WindowsDesktop SDK is imported, it effectively nullifies the effect of the NetFx copy of WinFx.targets.

I can see the value of solving this in the base NET.Sdk though when neither WPF nor WinForms are in use by default, but NetFx copy of WinFX.targets comes into play anyway when MSBuildRuntimeType==Full.

@Nirmal4G
Copy link
Contributor Author

With the .NET Sdk's change I proposed, it'll make import optional but disabled by default.

Whenever the WindowsDesktop SDK is imported, it effectively nullifies the effect of the NETFX copy of WinFX.targets.

In this PR, I just make sure that it's effectively disabled when using WindowsDesktop SDK.

I can see the value of solving this in the base NET.Sdk

They did. But I wanted to make it optional so that I can still use the inbox targets when needed.

@Nirmal4G Nirmal4G force-pushed the hotfix/disable-netfx-winfx branch 2 times, most recently from f1c1262 to a25cd3e Compare June 10, 2020 19:20
@vatsan-madhavan
Copy link
Member

Since dotnet/sdk#11606 seems close to being worked out, is this really needed any more?

@Nirmal4G
Copy link
Contributor Author

Nirmal4G commented Jun 12, 2020

We have to ensure that only when WinFX targets from sdk is used, the NETFX WinFX targets gets disabled permanently.

@vatsan-madhavan
Copy link
Member

Why? I mean what’s the problem you are trying to solve?

As far as I can tell the current situation is benign.

@Nirmal4G
Copy link
Contributor Author

The sdk PR solves the issue I'm facing. So, no problem there.

Just as you said, even if we import both of them, the sdk version takes over. I'm just ensuring the correctness of the imports in this PR. That's all.

This property have to be a toggle for both the imports. Like, when NETFX version is disabled, the sdk version is enabled and vice-versa. Both must not be enabled at the same time.

@vatsan-madhavan
Copy link
Member

Fair enough!

@Nirmal4G Nirmal4G changed the title Don't import .NET Framework's WinFX targets Don't double import WinFX targets Jul 10, 2020
@Nirmal4G
Copy link
Contributor Author

PR #3155 broke mine as it removed WinFX.props which I was using it. I have resolved the conflicts by moving the logic into WindowsDesktop.props. No other changes.

@ryalanms Can we merge this now? It's been too long.

@vatsan-madhavan
Copy link
Member

image

If it's indeed an update from master, then can this be merged from master cleanly?

@dotnet/wpf-developers PTAL, review and and consider for merging. There was much effort by @Nirmal4G, @dsplaisted, and myself across this PR and dotnet/sdk#11606 to get this in shape.

@dotnet/dnceng why aren't the checks reporting success correctly for this PR ?

image

@riarenas
Copy link
Member

They look correct to me. Was there a large delay between the build completing and the check reporting success? Or was there a delay between all the build legs completing and the build reporting it had finished?

@Nirmal4G
Copy link
Contributor Author

All Green for me too! I did resolve the conflicts a few days ago but forgot to push. That might be why the latest merge from master is few commits old from the current one. But there are no conflicts, so it's safe to merge.

@vatsan-madhavan
Copy link
Member

Or was there a delay between all the build legs completing and the build reporting it had finished?

This. When I looked, all the individual checks were green at least for a couple of mins, yet the "dotnet-wpf CI" summary was showing "in-progress". A few seconds lag seems reasonable.... but if the status stayed that way throughout the amount of time it took me to compose my comment (not-very-short), take a couple screenshots, highlight them etc., then at least to me it looked non-responsive.

@riarenas
Copy link
Member

Azdo builds have delays when reporting that an entire stage has finished, and then another delay when all stages have finished before it reports that a build has completed. This has to do with how the agents report a successful build and it can be frustrating.

Additionally, there are also sometimes delays between a build finishing, and the GitHub checks reflecting it. We had another report of delays when running the checks, so there might have been a transient issue with the communication between AzDO and GitHub. I sent email to the AzDO experts to see if there was a known outage at any point this morning.

@Nirmal4G
Copy link
Contributor Author

Please merge this as soon as possible, the existing PRs are breaking this one.

@ryalanms ryalanms added this to the 6.0.0 milestone Nov 25, 2020
@Nirmal4G Nirmal4G force-pushed the hotfix/disable-netfx-winfx branch 2 times, most recently from 9644ee0 to fd4d3c0 Compare December 19, 2020 07:08
Respect EditorConfig preferences for whitespace and newlines
The MSBuild items & targets that were defined after the WinFX targets import doesn't depend on anything from the WinFX targets.
So, it is safe and better to declare the import after those items and targets definitions.
When the SDK's implementation is being used.
Currently there's no way to properly switch between NETFX's and CoreCLR's WinFX targets.
This adds an opt-out, just in case, if we want to use the NETFX's WinFX targets instead.
@ryalanms
Copy link
Member

Thank you for fixing this, @Nirmal4G.

@ryalanms ryalanms merged commit 08c104b into dotnet:master Jan 12, 2021
@Nirmal4G
Copy link
Contributor Author

Finally! 🥳

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants