question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.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 issue

Description

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
KalleOlaviNiemitalocommented, Oct 28, 2021

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-L805

I 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 is false by default, which causes the code not to be executed and thus prevents the error. For .NET 6, the default was changed to true in https://github.com/dotnet/wpf/pull/4089.

Replacing the delimited-list Sdk attribute with multiple Sdk elements should work around the bug.

0reactions
dipeshmsftcommented, Aug 24, 2022

Closing this issue as the fix is already merged.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NETSDK1045: The current .NET SDK does not support ...
This error occurs when the build tools can't find the version of the .NET SDK that's needed to build a project. This is...
Read more >
SDK Resolver Failure - Net 7 - Net 6
18 sdk using add remove programs and then changed the TargetFramework in the project file to use 7.0 and then I was able...
Read more >
The current .NET SDK does not support targeting . ...
I want to create a class library project with Target Framework .NET Standard 2.0. I've updated my Visual Studio 2017 to Version 15.3...
Read more >
The SDK 'Microsoft.NET.Sdk' specified could not be found. ...
Since Visual Studio 2022 updated from version 17.4 to 17.5, I couldn't load my project. and get the error "The SDK 'Microsoft.NET.
Read more >
MSBuildSdkExtras
MSBuild.Sdk.Extras. Summary. This package contains a few extra extensions to the SDK-style projects that are currently not available in Microsoft.NET.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found