asp.net - 如何将框架 4.6.1 类库转换为核心 3.1?
问题描述
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$...." Condition="Exists('$.....')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DE7456FD-4BE4-4C9A-BA8C-9148EA6793A0}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Lynx.Core</RootNamespace>
<AssemblyName>Lynx.Core</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
我用了
<TargetFramework>netcoreapp3.1</TargetFramework>
并且还使用了
<TargetFrameworks>netstandard1.6;dnxcore50</TargetFrameworks>
<DefineConstants>$(DefineConstants);CORE</DefineConstants>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<TargetFrameworkIdentifiers>.NEtStandard;.NETCoreApp</TargetFrameworkIdentifiers>
<TargetFrameworkVersion>v1.6</TargetFrameworkVersion>
这行代码,但没有奏效。因为每当我构建此代码时,我的系统都会挂起,任何人都可以帮我解决这个问题
解决方案
.NET Core 2.0 及更高版本(包括最新版本的.NET Core 3.1 和即将推出的.NET 5.0)具有SDK 项目的项目模型。这些 csproj/vbproj/fsproj 文件(取决于您使用的语言)始终在其第一行包含此 XML:
<Project Sdk="Microsoft.NET.Sdk">
这些是 SDK 项目中的其他显着差异:
- SDK 项目没有嵌入项目 GUID,就像您拥有的那样:
<ProjectGuid>...</ProjectGuid>
. 其他 XML 元素也会被忽略,例如AppDesignerFolder
,RootNamespace
。 - SDK 项目无法使用
TargetFrameworkVersion
,因为此元素旨在供在 Visual Studio 中创建的 .NET Framework 项目使用,这就是为什么此元素中的值始终指代 .NET Framework 版本的原因。 - SDK 项目默认不需要单独的调试/发布条件。
没有工具可以自动/帮助将非 SDK 项目转换为 SDK 项目。因此需要手动编辑。
此文档链接上提供了详细的分步说明: https ://docs.microsoft.com/en-us/dotnet/core/migration/#migration-from-earlier-net-core-csproj-formats- to-rtm-csproj
推荐阅读
- java - 如何在构造函数中传递数组元素?
- tcl - 如何将鼠标移动到所有比例小部件?
- python - Python设置字符串的差异
- python - 如何访问 pytest 中的整体运行时?
- lua - 如何使用这个 LUA 表?
- android - 只要应用程序不可见,就暂停 CountDownTimer
- kubernetes - Getting "CrashLoopBackOff" as status of deployed pod
- php - 生成 500 万个唯一代码
- arrays - 我如何在猫鼬中查询以获得“答案”数组,其中“答案”数组中的“目标”是“意识”
- powershell - Start-Service cmdlet:在失败的情况下获取基础错误