[英]How to fix target framework reference for windows application pack in visual studio
我有一个 asp web 服务器目标框架是 .NET Framework 4.6.1,
<TargetFramework>net461</TargetFramework>
我想将此项目添加到 Windows 应用程序包并生成安装程序。 构建包后,出现错误消息:
target'net461' 它不能被以'.NETCore,Version=v5.0' 为目标的项目引用。
严重性代码描述项目文件行抑制状态错误项目“..\\Example\\Example.csproj”针对“net461”。 它不能被以“.NETCore,Version=v5.0”为目标的项目引用。 ExamplePackage C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\MSBuild\\Current\\Bin\\Microsoft.Common.CurrentVersion.targets 1653
我认为是因为 windows 应用程序打包有一个默认的目标框架,但我不知道如何更改它。 有人可以帮我解决这个问题吗?
我找到了一个解决方案:
您应该在项目 xml 上的每个引用下指定要使用的目标框架,如下所示:
<SetTargetFramework>TargetFramework=net461</SetTargetFramework>
给定参考的完整示例
<ProjectReference Include="theProject.csproj">
<Name>theProject</Name>
<Project>{46e70050-559c-442f-b47d-99a3ad73afd3}</Project>
<Private>True</Private>
<DoNotHarvest>True</DoNotHarvest>
<RefProjectOutputGroups>Binaries;Content;Satellites</RefProjectOutputGroups>
<RefTargetDir>INSTALLFOLDER</RefTargetDir>
<SetTargetFramework>TargetFramework=net461</SetTargetFramework>
</ProjectReference>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.