-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Cannot multi-target to netcoreapp < 3.0 and use WindowsDesktop SDK unconditionally #327
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
Comments
Looks to me like the project is using This seems to work for me though.
|
This also relates to the composability of the WindowsDesktop SDK so things like my Extras can use them.... |
@vatsan-madhavan That is true. Consider that the project in the repro steps is easier to read and maintain, and this tracks a feature request to allow it. I think this is a natural thing that users would expect to work. Even I had to look at the code to figure it out, and the error today does not provide a lot of insight into a solution. Also, having a good error will be complicated to implement. I think it would be simpler and better to allow this. |
Also, you will get duplicate import warnings with that:
|
Related: dotnet/installer#181 |
To avoid the duplicate import warnings, you need: <Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" Condition="'$(TargetFramework)' != 'netcoreapp3.0'" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk.WindowsDesktop" Condition="'$(TargetFramework)' == 'netcoreapp3.0'" />
<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;netcoreapp3.0</TargetFrameworks>
<UseWPF>true</UseWPF>
</PropertyGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" Condition="'$(TargetFramework)' != 'netcoreapp3.0'" />
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk.WindowsDesktop" Condition="'$(TargetFramework)' == 'netcoreapp3.0'" />
</Project> I tried the less verbose |
Updated title and description accordingly. |
I agree with your point about maintainability @nguerrera, and I hadn't originally considered the problem with double-import of Sdk.props. It makes my workaround more complex and even harder to maintain, I think. I feel like it would be odd to be able to write We have seen real-world examples of developers inadvertently trying to build WPF applications but getting the Sdk wrong (using Would we be ok supporting this with a suppressible warning (assuming it can be implemented easily enough) – something like |
cc @merriemcgaw |
I'd rather not have to set some new property to suppress a warning. Why not just use But ya, the error that is printed by the build gives no indication regarding the target framework being built at the time. This is in fact a general problem with multi-targeting today: when a warning/error is printed, MSBuild only tells us the project that produced it--not it's target framework, which is all-too-relevant for many issues, especially this one. I honestly thought it was the netcoreapp3.0 target that was complaining since that was the one I was working on upgrading when I hit this. Also: is it really necessary to even have a special SDK just for WindowsDesktop? Can't WPF/WinForms support be built into the regular SDK? I'm not sure which way is the right way here, but it seems that a single SDK would make the resolution to this much easier to identify. |
/cc @DustinCampbell |
NoWarn today doesn't work for arbitrary MSBuild warnings, each tool has to consume it manually. There is a MSBuildWarningsAsMessages that does almost the same thing. I have argued NoWarn should have the same impact in informal conversation, but I don't think there's a tracking issue. cc @rainersigwald |
@nguerrera is this the right repo for this issue? if i understand this correctly, this belongs in the msbuild repo, yeah? |
Related: #255 |
- #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.
- #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.
…eWinforms and multi-targeting experience (#1027) * Fixes the following: - #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.
winver
): N/A, build time errorProblem description:
If a project targets netcoreapp1.x or netcoreapp2.x in addition to netcoreapp3.0, and uses WindowsDesktop SDK in order to use WPF conditionally on 3.0, it fails to build. (Importing SDKs conditionally is possible, but difficult to get right and hard to maintain.)
The implicit framework reference is conditioned only on TargetFrameworkIdentifier being .NETCoreApp. It ignores TargetFrameworkVersion.
Minimal repro:
dotnet build
this:Actual behavior:
Expected behavior:
Successful build
cc @AArnott @dsplaisted @vatsan-madhavan
The text was updated successfully, but these errors were encountered: