从.netframework4.6迁移到.Net core 3.1。

问题描述 投票:0回答:1

事实上,我正在从.NetFramework4.6迁移到.Netcore3.1,但我面临着这个错误。enter image description here

我的csproj文件

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

    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="xunit" Version="2.3.0-beta2-build3683" />
        <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" />
    </ItemGroup>

    <ItemGroup>
      <Folder Include="Properties\" />
    </ItemGroup>

</Project>

APp.confg文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
    </startup>
</configuration>

enter image description here

c# asp.net-core .net-framework-version
1个回答
3
投票

你的应用程序以类库形式编译。你需要将输出类型改为控制台应用。

添加 OutputType 对你的 .csproj 像下面这样的文件。

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <OutputType>Exe</OutputType>
  </PropertyGroup>

你也可以在Visual Studio中的Project Properties -> Application -> Output Type中更改。

© www.soinside.com 2019 - 2024. All rights reserved.