我在一个之前为.NET Framework 4.5构建的WPF程序中遇到了以下警告,但现在正在为.NET 5构建。
Warning NETSDK1137 It is no longer necessary to use the Microsoft.NET.Sdk.WindowsDesktop SDK.
Consider changing the Sdk attribute of the root Project element to 'Microsoft.NET.Sdk'.
ListEditor
C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets 376
点击警告会在第376行打开文件Microsoft.NET.Sdk.DefaultItems.targets
。该文件以一个注释开始,内容为DO NOT MODIFY(请勿修改)
。
<!--
***********************************************************************************************
Microsoft.NET.Sdk.DefaultItems.targets
WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
created a backup copy. Incorrect changes to this file will make it
impossible to load or build your projects from the command-line or the IDE.
Copyright (c) .NET Foundation. All rights reserved.
***********************************************************************************************
-->
第376行位于此XML元素中...
<Target Name="_CheckForUnnecessaryWindowsDesktopSDK"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(_TargetFrameworkVersionWithoutV), '5.0')) and '$(_MicrosoftWindowsDesktopSdkImported)' == 'true' and '$(TargetFrameworks)' == ''">
<NETSdkWarning ResourceName="UnnecessaryWindowsDesktopSDK" />
</Target>
有一个Project元素包含整个文件。该元素如下...
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...omissions...
</Project>
由于该元素未提及 Microsoft.NET.Sdk.WindowsDesktop SDK
,因此项目元素似乎不是应放置替换 Microsoft.NET.Sdk
的点。
我该如何消除此警告的原因?