dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.11k stars 1.17k forks source link

Switch away from using PresentationBuildTasks and Microsoft.WinFx.targets from C:\Windows #9112

Open KirillOsenkov opened 11 months ago

KirillOsenkov commented 11 months ago

For WPF projects targeting net472, we should see if it's feasible to use the modern PresentationBuildTasks and Microsoft.WinFx.targets used by modern .NET 6/7/8.

We are already importing Microsoft.WinFx.targets from: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.WinFX.targets

However that's just a shim that's loading the C:\Windows copy using $(MSBuildFrameworkToolsPath)\Microsoft.WinFx.targets"

Modern WPF projects import this file instead: C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets at (163;3)

Should we see if we can import this for desktop too?

This issue is causing an insane amount of pain in our ecosystem.

Related links:

Our ecosystem is hurting:

KirillOsenkov commented 11 months ago

In this file: https://github.com/dotnet/msbuild/blob/main/src/Tasks/Microsoft.WinFx.targets

we should experiment with adding logic that, if an opt-in property is set, we import the modern WPF tasks from the SDK (C:\Program Files\dotnet\sdk\8.0.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.WinFX.targets) instead of the legacy tasks from C:\Windows.

I suggest that the MSBuild team spikes an experiment to see how cheap this is.

KirillOsenkov commented 8 months ago

I forgot to mention another motivation behind this.

If we modernize WPF build tasks we'll be able to build WPF projects on Linux, which is currently not possible. Very often a codebase could have built on Linux but the WPF projects fail to build.

FYI @JanKrivanek

rainersigwald commented 6 months ago

The only people who can provide the support needed to do this are the owners of the WPF tooling, so moving this to dotnet/wpf. The MSBuild team will happily help out.

ThomasGoulet73 commented 6 months ago

Am I understanding correctly that the goal of this issue is for non-SDK style projects to use the same PresentationBuildTasks and Microsoft.WinFx.targets as SDK style projects ?

IIRC, SDK style .Net Framework projects already use the PresentationBuildTasks and Microsoft.WinFx.targets from the SDK.

KirillOsenkov commented 6 months ago

@ThomasGoulet73 yes

KirillOsenkov commented 5 months ago

@ThomasGoulet73 a minor correction: another goal (that I personally care the most about) is for SDK-style projects that use legacy WPF and target desktop framework (instead of UseWpf=true and targeting modern .NET) to work using the latest markup compiler and not the legacy targets/tasks from C:\Windows