【问题标题】:.net core in Linux - build C#Linux 中的 .net 核心 - 构建 C#
【发布时间】:2018-06-08 06:58:58
【问题描述】:

Linux 环境 - Ubuntu 16.04 LTS。我已经安装了 .net core 2.1300(最新,带 sdk)。

我正在尝试在 C# 中构建(dotnet build)一个 .csproj 文件。

So $: dotnet build CarLibTool.2010.csproj

但错误是:

/usr/share/dotnet/sdk/2.1.300/Microsoft.Common.CurrentVersion.targets(1179,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies

存在哪些可能的解决方案?

也许改变 .csproj ?

【问题讨论】:

标签: c# linux .net-core


【解决方案1】:

从 2019 年 5 月 6 日起,您可以添加 Nuget 包 Microsoft.NETFramework.ReferenceAssemblies,它允许您在 Linux 上构建您的 .NET 项目,而无需转换为 .NET Core。

【讨论】:

    【解决方案2】:

    您正在尝试在 .NET Core 平台上构建完整的 .NET (v4.6.1) 应用程序,但不受支持。

    您需要创建一个针对 .NET Core 而不是 .NET 4.6.1 框架的新项目(或解决方案)。

    如果您需要在 .NET 框架(在您的情况下为 4.6.1)和 .NET Core 之间共享代码库,您应该使用 .NET Standard 库,因为这两者都可以使用。

    请注意,.NET Core 并不支持 4.6.1 中的所有内容(这就是为什么它被称为“核心”,因为它只是核心功能)。这包括您可能正在使用的任何 GUI 组件。

    【讨论】:

      猜你喜欢
      • 2018-09-25
      • 1970-01-01
      • 1970-01-01
      • 2018-03-07
      • 1970-01-01
      • 1970-01-01
      • 2018-01-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多