首页 > 解决方案 > 如何将框架 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>

这行代码,但没有奏效。因为每当我构建此代码时,我的系统都会挂起,任何人都可以帮我解决这个问题

标签: asp.net.netasp.net-coreasp.net-core-3.1.net-core-3.1

解决方案


.NET Core 2.0 及更高版本(包括最新版本的.NET Core 3.1 和即将推出的.NET 5.0)具有SDK 项目的项目模型。这些 csproj/vbproj/fsproj 文件(取决于您使用的语言)始终在其第一行包含此 XML:

<Project Sdk="Microsoft.NET.Sdk">

这些是 SDK 项目中的其他显着差异:

  1. SDK 项目没有嵌入项目 GUID,就像您拥有的那样:<ProjectGuid>...</ProjectGuid>. 其他 XML 元素也会被忽略,例如AppDesignerFolder, RootNamespace
  2. SDK 项目无法使用TargetFrameworkVersion,因为此元素旨在供在 Visual Studio 中创建的 .NET Framework 项目使用,这就是为什么此元素中的值始终指代 .NET Framework 版本的原因。
  3. SDK 项目默认不需要单独的调试/发布条件。

没有工具可以自动/帮助将非 SDK 项目转换为 SDK 项目。因此需要手动编辑。

此文档链接上提供了详细的分步说明: https ://docs.microsoft.com/en-us/dotnet/core/migration/#migration-from-earlier-net-core-csproj-formats- to-rtm-csproj


推荐阅读