WinForms 从 .NET 4.x 迁移到 .NET 5 - 如何从项目中删除 AspNetCore 依赖项?
WinForms Migration from .NET 4.x to .NET 5 - How do I remove AspNetCore dependencies from project?
我最近使用新的预览版 .NET 升级助手将 .NET Framework 4.8 WinForms 项目迁移到 .NET 5。我已经通过代码解决了不兼容问题,但我 运行我尝试构建应用程序时无法弄清楚的错误。
Severity Code Description Project File Line Suppression State
Error MSB4096 The item "C:\TFSRoot\SEImportDatabase\SE Import Database 5.0\DataCleansing\obj\x64\Debug\net5.0-windows\apphost.exe" in item list "ContentWithTargetPath" does not define a value for metadata "TargetPath". In order to use this metadata, either qualify it by specifying %(ContentWithTargetPath.TargetPath), or ensure that all items in this list define a value for this metadata. DataCleansing C:\Program Files (x86)\dotnet\sdk.0.201\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 203
目标文件中引用的部分是:
<ItemGroup>
<_WebRootFiles Include="@(ContentWithTargetPath)" Condition="$([System.String]::Copy('%(TargetPath)').Replace('\','/').StartsWith('wwwroot/'))" />
<_ReferencedStaticWebAssets Include="@(StaticWebAsset)" Condition="'%(SourceType)' != ''" />
</ItemGroup>
我还看到了以下我不理解的 AspNetCore 依赖项,因为这是一个 WinForms 应用程序,而不是 ASP.NET 核心应用程序:
Dependencies>Analyzers>Microsoft.AspNetCore.Analyzers
Dependencies>Analyzers>Microsoft.AspNetCore.Components.Analyzers
Dependencies>Analyzers>Microsoft.AspNetCore.Mvc.Analyzers
Dependencies>Frameworks>Microsoft.AspNetCore.app
我假设是 Frameworks 依赖项导致了上述错误,但我不知道它为什么存在或如何删除它。
如何从我的 WinForms 项目中删除这些依赖项?或者是否有其他原因导致此错误?
这是我的依赖项的屏幕截图:
编辑:这是我要求的 csproj 内容。
<Project Sdk="Microsoft.NET.Sdk.Web">
<!--<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />-->
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<AssemblyName>SE Import Data Cleansing Application</AssemblyName>
<ManifestCertificateThumbprint>{data here}</ManifestCertificateThumbprint>
<ManifestKeyFile>DataCleansing_TemporaryKey.pfx</ManifestKeyFile>
<GenerateManifests>true</GenerateManifests>
<SignManifests>false</SignManifests>
<IsWebBootstrapper>false</IsWebBootstrapper>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<PublishUrl>\lifeaction.net\dfs\download\Life Action\SE Import Database Core\</PublishUrl>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<TargetCulture>en-US</TargetCulture>
<ProductName>SE Import Data Cleansing Application (Core)</ProductName>
<PublisherName>Life Action Ministries</PublisherName>
<CreateWebPageOnPublish>false</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>734</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>File import.ico</ApplicationIcon>
<UserSecretsId>{data here}</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Reference Include="LifeAction.Common.Utilities">
<HintPath>\lifeaction.net\dfs\download\.NET Libraries\LifeAction.Common.Utilities\LifeAction.Common.Utilities.dll</HintPath>
</Reference>
<Reference Include="LifeAction.SmartyStreets, Version=1.0.5490.16347, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>\lifeaction.net\dfs\download\Life Action\SmartyStreets\LifeAction.SmartyStreets.dll</HintPath>
</Reference>
<Reference Update="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Update="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="DataGridView2.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<!--<Content Include="appsettings.json" />-->
<!--<Content Include="Splash.png" />-->
<None Update="App.Debug.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<None Update="App.Release.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<!--<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
<TransformOnBuild>true</TransformOnBuild>
</Content>-->
<None Update="NLog.Debug.config">
<DependentUpon>NLog.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<None Update="NLog.Release.config">
<DependentUpon>NLog.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<None Update="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<!--<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>-->
<!--<ItemGroup>
<Content Include="File import.ico" />
</ItemGroup>-->
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<PublishFile Include="Microsoft.Practices.ObjectBuilder2">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Assembly</FileType>
</PublishFile>
<PublishFile Include="Microsoft.Practices.Unity">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Assembly</FileType>
</PublishFile>
<PublishFile Include="Win32">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Assembly</FileType>
</PublishFile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataCleansing.BLL\DataCleansing.BLL.csproj" />
<ProjectReference Include="..\DataCleansing.Common\DataCleansing.Common.csproj" />
<ProjectReference Include="..\DataCleansing.DAL\DataCleansing.DAL.csproj" />
<ProjectReference Include="..\DataCleansing.DTO\DataCleansing.DTO.csproj" />
<ProjectReference Include="..\DataCleansing.Interfaces\DataCleansing.Interfaces.csproj" />
<ProjectReference Include="..\DataCleansing.Plugins\DataCleansing.Plugins.csproj" />
<ProjectReference Include="..\DataCleansing.SE.API\DataCleansing.SE.API.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.3.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="5.0.0" />
<PackageReference Include="Microsoft.Recognizers.Text.DateTime" Version="1.5.0" />
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.2.26" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="NLog.Config" Version="4.7.8" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.2.212405">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<!--<ItemGroup>
-->
<!--<Compile Remove="frmAddressValidation.cs" />-->
<!--
-->
<!--<Compile Remove="frmAddressValidation.Designer.cs" />-->
<!--
-->
<!--<Compile Remove="frmMediaOutlets.cs" />
<Compile Remove="frmMediaOutlets.Designer.cs" />-->
<!--
<Compile Remove="frmAddressValidation.cs" />
<Compile Remove="frmAddressValidation.Designer.cs" />
<Compile Remove="InputBoxDialog.cs" />
<EmbeddedResource Remove="frmAddressValidation.resx" />
-->
<!--<Compile Remove="LayerFactory.cs" />-->
<!--
-->
<!--<EmbeddedResource Remove="frmAddressValidation.resx" />-->
<!--
-->
<!--<EmbeddedResource Remove="frmMediaOutlets.resx" />-->
<!--
<EmbeddedResource Remove="InputBoxDialog.resx" />
</ItemGroup>-->
<ItemGroup>
<None Remove="DataCleansing.csproj.vspscc" />
</ItemGroup>
<!--<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />-->
<Import Project="..\packages\Microsoft.VisualStudio.SlowCheetah.3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets')" />
</Project>
您使用的 SDK 有误。
Windows Forms Projects 的权利 SDK 是 Microsoft.NET.Sdk.WindowsDesktop
;但是,从 .NET 5.0 开始,WinForms 项目应该指定 Microsoft.NET.Sdk
而不是 Microsoft.NET.Sdk.WindowsDesktop
,如下所示:
- 设置sdk为
<Project Sdk="Microsoft.NET.Sdk">
- 将目标框架设置为
<TargetFramework>net5.0-windows</TargetFramework>
- 设置
<UseWindowsForms>true</UseWindowsForms>
它也可以使用 <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
;但是,根据 documentations
将 TargetFramework
设置为 net5.0-windows
并将 UseWindowsForms
设置为 true
将自动导入 Windows 桌面 SDK。如果您的项目面向 .NET 5.0 或更高版本并指定 Microsoft.NET.Sdk.WindowsDesktop SDK,您将收到生成警告 NETSDK1137。
我最近使用新的预览版 .NET 升级助手将 .NET Framework 4.8 WinForms 项目迁移到 .NET 5。我已经通过代码解决了不兼容问题,但我 运行我尝试构建应用程序时无法弄清楚的错误。
Severity Code Description Project File Line Suppression State
Error MSB4096 The item "C:\TFSRoot\SEImportDatabase\SE Import Database 5.0\DataCleansing\obj\x64\Debug\net5.0-windows\apphost.exe" in item list "ContentWithTargetPath" does not define a value for metadata "TargetPath". In order to use this metadata, either qualify it by specifying %(ContentWithTargetPath.TargetPath), or ensure that all items in this list define a value for this metadata. DataCleansing C:\Program Files (x86)\dotnet\sdk.0.201\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 203
目标文件中引用的部分是:
<ItemGroup>
<_WebRootFiles Include="@(ContentWithTargetPath)" Condition="$([System.String]::Copy('%(TargetPath)').Replace('\','/').StartsWith('wwwroot/'))" />
<_ReferencedStaticWebAssets Include="@(StaticWebAsset)" Condition="'%(SourceType)' != ''" />
</ItemGroup>
我还看到了以下我不理解的 AspNetCore 依赖项,因为这是一个 WinForms 应用程序,而不是 ASP.NET 核心应用程序:
Dependencies>Analyzers>Microsoft.AspNetCore.Analyzers
Dependencies>Analyzers>Microsoft.AspNetCore.Components.Analyzers
Dependencies>Analyzers>Microsoft.AspNetCore.Mvc.Analyzers
Dependencies>Frameworks>Microsoft.AspNetCore.app
我假设是 Frameworks 依赖项导致了上述错误,但我不知道它为什么存在或如何删除它。
如何从我的 WinForms 项目中删除这些依赖项?或者是否有其他原因导致此错误?
这是我的依赖项的屏幕截图:
编辑:这是我要求的 csproj 内容。
<Project Sdk="Microsoft.NET.Sdk.Web">
<!--<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.props')" />-->
<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<AssemblyName>SE Import Data Cleansing Application</AssemblyName>
<ManifestCertificateThumbprint>{data here}</ManifestCertificateThumbprint>
<ManifestKeyFile>DataCleansing_TemporaryKey.pfx</ManifestKeyFile>
<GenerateManifests>true</GenerateManifests>
<SignManifests>false</SignManifests>
<IsWebBootstrapper>false</IsWebBootstrapper>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<PublishUrl>\lifeaction.net\dfs\download\Life Action\SE Import Database Core\</PublishUrl>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<UpdateEnabled>true</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<TargetCulture>en-US</TargetCulture>
<ProductName>SE Import Data Cleansing Application (Core)</ProductName>
<PublisherName>Life Action Ministries</PublisherName>
<CreateWebPageOnPublish>false</CreateWebPageOnPublish>
<WebPage>publish.htm</WebPage>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<ApplicationRevision>734</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>bin\x64\Debug\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>File import.ico</ApplicationIcon>
<UserSecretsId>{data here}</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Reference Include="LifeAction.Common.Utilities">
<HintPath>\lifeaction.net\dfs\download\.NET Libraries\LifeAction.Common.Utilities\LifeAction.Common.Utilities.dll</HintPath>
</Reference>
<Reference Include="LifeAction.SmartyStreets, Version=1.0.5490.16347, Culture=neutral, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>\lifeaction.net\dfs\download\Life Action\SmartyStreets\LifeAction.SmartyStreets.dll</HintPath>
</Reference>
<Reference Update="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Update="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Update="DataGridView2.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<!--<Content Include="appsettings.json" />-->
<!--<Content Include="Splash.png" />-->
<None Update="App.Debug.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<None Update="App.Release.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<!--<Content Include="NLog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
<TransformOnBuild>true</TransformOnBuild>
</Content>-->
<None Update="NLog.Debug.config">
<DependentUpon>NLog.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<None Update="NLog.Release.config">
<DependentUpon>NLog.config</DependentUpon>
<IsTransformFile>true</IsTransformFile>
</None>
<None Update="NLog.xsd">
<SubType>Designer</SubType>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<!--<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
<Visible>False</Visible>
<ProductName>.NET Framework 2.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
<Visible>False</Visible>
<ProductName>.NET Framework 3.0 %28x86%29</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>-->
<!--<ItemGroup>
<Content Include="File import.ico" />
</ItemGroup>-->
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Resources\" />
</ItemGroup>
<ItemGroup>
<PublishFile Include="Microsoft.Practices.ObjectBuilder2">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Assembly</FileType>
</PublishFile>
<PublishFile Include="Microsoft.Practices.Unity">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Assembly</FileType>
</PublishFile>
<PublishFile Include="Win32">
<Visible>False</Visible>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>Assembly</FileType>
</PublishFile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DataCleansing.BLL\DataCleansing.BLL.csproj" />
<ProjectReference Include="..\DataCleansing.Common\DataCleansing.Common.csproj" />
<ProjectReference Include="..\DataCleansing.DAL\DataCleansing.DAL.csproj" />
<ProjectReference Include="..\DataCleansing.DTO\DataCleansing.DTO.csproj" />
<ProjectReference Include="..\DataCleansing.Interfaces\DataCleansing.Interfaces.csproj" />
<ProjectReference Include="..\DataCleansing.Plugins\DataCleansing.Plugins.csproj" />
<ProjectReference Include="..\DataCleansing.SE.API\DataCleansing.SE.API.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.3.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="5.0.0" />
<PackageReference Include="Microsoft.Recognizers.Text.DateTime" Version="1.5.0" />
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.2.26" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.2" />
<PackageReference Include="NLog.Config" Version="4.7.8" />
<PackageReference Include="System.Collections.Immutable" Version="5.0.0" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.2.212405">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<!--<ItemGroup>
-->
<!--<Compile Remove="frmAddressValidation.cs" />-->
<!--
-->
<!--<Compile Remove="frmAddressValidation.Designer.cs" />-->
<!--
-->
<!--<Compile Remove="frmMediaOutlets.cs" />
<Compile Remove="frmMediaOutlets.Designer.cs" />-->
<!--
<Compile Remove="frmAddressValidation.cs" />
<Compile Remove="frmAddressValidation.Designer.cs" />
<Compile Remove="InputBoxDialog.cs" />
<EmbeddedResource Remove="frmAddressValidation.resx" />
-->
<!--<Compile Remove="LayerFactory.cs" />-->
<!--
-->
<!--<EmbeddedResource Remove="frmAddressValidation.resx" />-->
<!--
-->
<!--<EmbeddedResource Remove="frmMediaOutlets.resx" />-->
<!--
<EmbeddedResource Remove="InputBoxDialog.resx" />
</ItemGroup>-->
<ItemGroup>
<None Remove="DataCleansing.csproj.vspscc" />
</ItemGroup>
<!--<Import Project="..\packages\EntityFramework.6.4.4\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.4\build\EntityFramework.targets')" />-->
<Import Project="..\packages\Microsoft.VisualStudio.SlowCheetah.3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.SlowCheetah.3.2.26\build\Microsoft.VisualStudio.SlowCheetah.targets')" />
</Project>
您使用的 SDK 有误。
Windows Forms Projects 的权利 SDK 是 Microsoft.NET.Sdk.WindowsDesktop
;但是,从 .NET 5.0 开始,WinForms 项目应该指定 Microsoft.NET.Sdk
而不是 Microsoft.NET.Sdk.WindowsDesktop
,如下所示:
- 设置sdk为
<Project Sdk="Microsoft.NET.Sdk">
- 将目标框架设置为
<TargetFramework>net5.0-windows</TargetFramework>
- 设置
<UseWindowsForms>true</UseWindowsForms>
它也可以使用 <Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
;但是,根据 documentations
将 TargetFramework
设置为 net5.0-windows
并将 UseWindowsForms
设置为 true
将自动导入 Windows 桌面 SDK。如果您的项目面向 .NET 5.0 或更高版本并指定 Microsoft.NET.Sdk.WindowsDesktop SDK,您将收到生成警告 NETSDK1137。