不应仅在Visual Studio 2019上构建的交叉定位(外部)中,不应使用非crosstargeting getTargetFrameWorks目标
我有一个具有一个具有控制台项目的解决方案,该项目指的是一个类库项目。它在Visual Studio 2017中的预期工作。但是,当我尝试在Visual Studio 2019中构建解决方案时,它在控制台应用程序项目中给出了以下错误。
不应在 交叉定位(外部)构建
类库CSPROJ文件。
<PropertyGroup>
<TargetFrameworks>net472</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E05F3549-01FC-4012-A2CA-5BF009608E80}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FxRateCalculationLib</RootNamespace>
<AssemblyName>FxRateCalculationLib</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
控制台应用程序CSPROJ文件。
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{34A8C575-F374-4C50-8ADC-EC74A6423055}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp1</RootNamespace>
<AssemblyName>ConsoleApp1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
我试图从那时变化
<PropertyGroup>
<TargetFrameworks>net472</TargetFrameworks>
</PropertyGroup>
到
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
那时,它成功地构建了。但是当我运行时,它会开始给出运行时错误。
因此,我有一个问题,为什么它在VS 2017中起作用,而在2019年不起作用。以及如何以最小和适当的更改来解决此问题。
编辑:最初,我认为这是一个旧的旧版项目,因此我使用Visual Studio 2019添加了一个新的控制台应用程序项目。但是上面的问题中提到了相同的汇编错误。
edit2 :完整的错误消息
严重性代码描述项目文件行抑制状态 错误内部msbuild错误:非crostargeting getTargetFrameworks 目标不应用于交叉靶向(外部) 构建consoleapp1
I have a Solution that has a console project which is referring to one class library project. It's working as expected in Visual Studio 2017. But When I try to build the solution in Visual Studio 2019 it gives the below error in the console app project.
Non-CrossTargeting GetTargetFrameworks target should not be used in
cross targeting (outer) build
Class library csproj file.
<PropertyGroup>
<TargetFrameworks>net472</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E05F3549-01FC-4012-A2CA-5BF009608E80}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FxRateCalculationLib</RootNamespace>
<AssemblyName>FxRateCalculationLib</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
Console app csproj file.
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{34A8C575-F374-4C50-8ADC-EC74A6423055}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConsoleApp1</RootNamespace>
<AssemblyName>ConsoleApp1</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
I tried to change changing from
<PropertyGroup>
<TargetFrameworks>net472</TargetFrameworks>
</PropertyGroup>
to
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
then it builds successfully. but When I run It starts giving runtime errors.
So I have a question why is it working in VS 2017, but not in 2019. and how to fix this issue with minimum and proper changes.
Edit: initially I thought that it was an old legacy project, so I add a new console application project using visual studio 2019. But same compilation error is mentioned above in the question.
Edit2: Complete error message
Severity Code Description Project File Line Suppression State
Error Internal MSBuild error: Non-CrossTargeting GetTargetFrameworks
target should not be used in cross targeting (outer)
build ConsoleApp1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论