novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
347 stars 43 forks source link

Don't include WindowsDesktop.props for 5.0 SDK #249

Closed Daniel-Svensson closed 3 years ago

Daniel-Svensson commented 3 years ago

Don't include Microsoft.NET.Sdk.WindowsDesktop.props when using .net 5.0 SDK because 5.0 SDK already includes it. This prevents MSB4011 build warnings which can lead to nuget package restore errors preventing builds in CI environments

The fix should resolve the following build warnings

warning MSB4011: "C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk.WindowsDesktop\targets\Microsoft.NET.Sdk.WindowsDesktop.props" cannot be imported again. It was already imported at "C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.props (147,3)". This is most likely a build authoring error. This subsequent import will be ignored.

MagicAndre1981 commented 3 years ago

I also get this with VS2019 16.8.2. Any idea when this gets merged and released to nuget?

Daniel-Svensson commented 3 years ago

After setting ExtrasUseWindowsDesktopApp to false the workaround no longer works (Page elements does not work correct on net framework and probably more issues)

I do not know when I will get the time to look into this further so I am considering to close/abandon this PR. I do however think it might be a good start for someone to continue on.

A quite simple solution that should work would be to use _ExtrasHasNet5OrGreaterSDK instead and make add a condition '$(_ExtrasHasNet5OrGreaterSDK)' != 'true' to the following 2 imports $(MicrosoftWindowsDesktopSdkPath)\Microsoft.NET.Sdk.WindowsDesktop.props and $(MicrosoftWindowsDesktopSdkPath)\Microsoft.NET.Sdk.WindowsDesktop.targets

clairernovotny commented 3 years ago

Closing as fixed in #251

clairernovotny commented 3 years ago

Closing as fixed in #251