.Net SDK 6.0 RC2 - UseWPF project with multiple semi-colon delimited SDKs fails as it tries to treat the set as a single SDK
See original GitHub issueDescription
When moving our global SDK version from 5.0.402 to 6.0.100-rc.2.21505.57 (which also included switching from MSBuild 16.11.3 to 17 preview 6), one of our UseWPF projects that targets an older framework version started failing as it appears to be trying to evaluate the SDK value with multiple semi-colon delimited sdks as a single SDK inside the generated wpftmp.csproj file.
Details
The csproj starts with the following:
<Project Sdk="Build.Before;Microsoft.NET.Sdk.WindowsDesktop;Build.After">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<AssemblyName>GraphAnalyzer</AssemblyName>
<NeutralLanguage>en</NeutralLanguage>
<UseWPF>true</UseWPF>
<TargetFramework>net472</TargetFramework>
While that works when using the .NET 5 SDK, after switching to .NET 6 RC2 it now fails with the following:
graphanalyzer_xdtcdvpd_wpftmp.csproj(9,3): error : %DOTNET_ROOT%\sdk\6.0.100-rc.2.21505.57\Sdks\Build.Before;Microsoft.NET.Sdk.WindowsDesktop;Build.After\Sdk not found. Check that a recent enough .NET SDK is installed and/or increase the version specified in global.json. graphanalyzer_xdtcdvpd_wpftmp.csproj(9,31): error MSB4236: The SDK ‘Build.Before;Microsoft.NET.Sdk.WindowsDesktop;Build.After’ specified could not be found.
graphanalyzer_xdtcdvpd_wpftmp.csproj appears to be the generated TemporaryTargetAssemblyProjectName built by the _CompileTemporaryAssembly target.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (2 by maintainers)
Top GitHub Comments
Those
Import
elements are generated here: https://github.com/dotnet/wpf/blob/4d7a80a2cbf0f96a1da7775a5ca0fad1499005f5/src/Microsoft.DotNet.Wpf/src/PresentationBuildTasks/Microsoft/Build/Tasks/Windows/GenerateTemporaryTargetAssembly.cs#L771-L805I think that code in dotnet/wpf needs to be changed to split the semicolon-delimited list and generate separate imports for each SDK.
The code was added to .NET 5 in https://github.com/dotnet/wpf/pull/3846 and to .NET 6 in https://github.com/dotnet/wpf/pull/3951. In .NET 5 though, the
IncludePackageReferencesDuringMarkupCompilation
property isfalse
by default, which causes the code not to be executed and thus prevents the error. For .NET 6, the default was changed totrue
in https://github.com/dotnet/wpf/pull/4089.Replacing the delimited-list
Sdk
attribute with multipleSdk
elements should work around the bug.Closing this issue as the fix is already merged.