-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add warnings to Microsoft.NET.Sdk.WindowsDesktop to improve UseWpf/UseWinforms and multi-targeting experience #1027
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
Conversation
/cc @davidwengier, @davkean |
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets
Show resolved
Hide resolved
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.targets
Outdated
Show resolved
Hide resolved
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Outdated
Show resolved
Hide resolved
- #685: Remove **/*.xaml from None - #327: Cannot multi-target netcoreap < 3.0 and use WindowsDesktop SDK unconditionally. - #867: Show error when neither UseWpf nor UseWindowsForms is set to true - #746: [Epic] Support WPF and WinForms specific FrameworkReferences a Profiles Also cleans up the way in which we import Microsoft.WinFX.targets - UseLegacyPresentationBuildTasks has been broken for some time now and unusable.
- Make the condition in _WindowsDesktopFrameworkRequiresUseWpfOrUseWindowsForms specific to applicable TFM's
27b83c6
to
5db998a
Compare
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Show resolved
Hide resolved
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have tests covering these fixes, for example that you can multitarget .NET Core 2.x and 3.0 using the WindowsDesktop SDK. Do you have a way of testing the WindowsDesktop SDK in this repo?
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Outdated
Show resolved
Hide resolved
packaging/Microsoft.NET.Sdk.WindowsDesktop/targets/Microsoft.NET.Sdk.WindowsDesktop.props
Outdated
Show resolved
Hide resolved
96b5347
to
0aa98ff
Compare
Not yet. I'll sync with you next week to figure out how to seed this repo with some tests based off of dotnet/sdk. For now, these are tested locally using a WPF app, WinForms app and a Console App, and using <!-- WPF project -->
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>netcoreapp3.0;net40;net45;net46;net452;net472;netcoreapp2.2;net35</TargetFrameworks>
<UseWPF>true</UseWPF> <!-- change to false to test NETSDK1106 -->
<UseWindowsForms>false</UseWindowsForms>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
</PropertyGroup>
<PropertyGroup>
<!--<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NETSDK1096;NETSDK1105;NETSDK1107</MSBuildWarningsAsMessages>-->
<!--<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NETSDK1105</MSBuildWarningsAsMessages>-->
</PropertyGroup>
<PropertyGroup>
<FrameworkPathOverride Condition="$(TargetFramework.StartsWith('net3'))">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
</PropertyGroup>
...
</Project> <!-- WinForms project -->
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks Condition="'$(MSBuildRuntimeType)'!='Core'">netcoreapp3.0;net30;net35;net40;net45;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(MSBuildRuntimeType)'=='Core'">netcoreapp3.0;net40;net45;net472</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup>
<FrameworkPathOverride Condition="$(TargetFramework.StartsWith('net3'))">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
</PropertyGroup>
</Project> <!-- Console project -->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWpf>true</UseWpf>
<!--<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);NETSDK1096;NETSDK1105;NETSDK1107</MSBuildWarningsAsMessages>-->
</PropertyGroup>
</Project> |
Would it be in scope to warn if property |
@drewnoakes, Are you suggesting that we should warn if We would need to add another warning string in the sdk - so we can't tag this change along here. /cc @merriemcgaw |
I'd think |
@vatsan-madhavan yes that's what I meant. Thanks for creating the issue. @RussKie I agree (I filed issues against the new project dialog to make sure "winforms" actually returned any results) but in code the full name "WindowsForms" is used throughout. This is why I think an additional warning here would help a non-trivial number of people succeed here, especially since the current design of the project file around enable winforms/wpf is so difficult for us on the project system team to tool that customers are likely to need to write this XML by hand from memory. |
Thank you for clarifications. I'd spin it from a customer perspective - how we call it in our codebase is an internal detail and immaterial outside the codebase. |
It's not about internal details of the code base. The namespace and assembly name is System.Windows.Forms, not something like System.WinForms. That is visible to customers. Project templates in VS, documentation, etc. all say Windows Forms instead of WinForms. |
Good point about |
please don't change this to |
I agree that the template My personal preference would be in the project file as well since it is consistent with , clear (everyone knows what is WinForms, WindowsForms doesn't add any value), brief (users don't need to type more) and I'd also guesstimate the name "WinForms" is used more often than "Windows Forms". I'd make the correct property and prompt users if they are using . That being said I realize this would break existing WinForms Core apps, but if we want to make this change - the preview is the right time to do so. @merriemcgaw, what do you think? |
We are locking down tomorrow noon for preview 7. A change like this requires coordinated changes in dotnet/sdk and dotnet/wpf. I recommend that we pursue an approach that augments the existing design by recognizing |
Lots of "gut feelings" in this thread. "Windows Forms" has been consistently through documentation, training, Visual Studio UI, templates, etc since the beginning of its existence. |
Regardless of what's used, I maintain customers who hand edit their project file and use the incorrect version will appreciate guidance that they're not quite doing what's needed. Currently there's no feedback. This is not the pit of success. |
Strongly agree with David, but also agree that either a warning for using the wrong property name (or possibly just allowing either property name) is a good idea. |
Yep, sorry didn't mean to say that shouldn't happen RE warning. Accepting both definitions I think would be a mistake, as there are already downstream consumers of this (our capabilities are already driven off this) |
Following your argument, we should use |
Please move the conversation over to dotnet/winforms#1226 |
Fixes the following:
Also cleans up the way in which we import Microsoft.WinFX.targets - UseLegacyPresentationBuildTasks has been broken for some time now and unusable.