wpf
wpf copied to clipboard
Switch away from using PresentationBuildTasks and Microsoft.WinFx.targets from C:\Windows
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:
- https://github.com/microsoft/dotnet/issues/1197
- https://github.com/dotnet/msbuild/pull/2701
- https://github.com/dotnet/msbuild/issues/3254
- https://github.com/dotnet/msbuild/issues/3483
- https://github.com/dotnet/sdk/issues/15395
- https://github.com/dotnet/sdk/pull/15465
- https://github.com/dotnet/sdk/pull/15790
- https://github.com/dotnet/sdk/issues/34438
- https://github.com/dotnet/sourcelink/issues/601
- https://github.com/dotnet/wpf/issues/810
- https://github.com/dotnet/wpf/pull/1056
- https://github.com/dotnet/wpf/issues/1718
- https://github.com/dotnet/wpf/issues/3308
- https://github.com/dotnet/wpf/issues/3404
- https://github.com/dotnet/wpf/pull/3585
- https://github.com/dotnet/wpf/pull/3846
- https://github.com/dotnet/wpf/pull/3890
- https://github.com/dotnet/wpf/issues/3963
- https://github.com/dotnet/wpf/issues/3974
- https://github.com/dotnet/wpf/pull/4009
- https://github.com/dotnet/wpf/issues/4067
- https://github.com/dotnet/wpf/issues/4302
- https://github.com/dotnet/wpf/issues/4311
- https://github.com/NuGet/Home/issues/4515
- https://github.com/NuGet/Home/issues/4532
- https://github.com/NuGet/Home/issues/4652
- https://github.com/NuGet/Home/issues/5894
- https://github.com/NuGet/NuGet.Client/pull/1786
Our ecosystem is hurting:
- https://github.com/microsoft/CsWin32/issues/7
- https://github.com/grpc/grpc/pull/22067
- https://github.com/dotnet/Nerdbank.GitVersioning/issues/147
- https://github.com/dotnet/Nerdbank.GitVersioning/issues/175
- https://github.com/dotnet/Nerdbank.GitVersioning/issues/404
- https://github.com/dotnet/Nerdbank.GitVersioning/pull/405
- https://github.com/manuelroemer/Nullable/issues/11
- https://github.com/manuelroemer/Nullable/issues/20
- https://github.com/devlooped/ThisAssembly/issues/14
- https://github.com/dotnet/roslyn-sdk/pull/94
- https://github.com/dotnet/roslyn-sdk/issues/647
- https://github.com/dotnet/roslyn-tools/issues/154
- https://github.com/pakrym/jab/issues/41
- https://github.com/dotnet/roslyn/issues/52427
- https://github.com/canton7/PropertyChanged.SourceGenerator/issues/1
- https://github.com/novotnyllc/MSBuildSdkExtras/pull/27
- https://github.com/novotnyllc/MSBuildSdkExtras/issues/32
- https://github.com/novotnyllc/MSBuildSdkExtras/issues/66
- https://github.com/novotnyllc/MSBuildSdkExtras/pull/68
- https://github.com/reactiveui/ReactiveUI/pull/1587
- https://github.com/dotnet/sourcelink/issues/62
- https://github.com/dotnet/sourcelink/issues/91
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.
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
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.
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.
@ThomasGoulet73 yes
@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