在 Linux 上构建 Web API .net 核心



我正在使用与Microsoft(R(Visual Studio (R(团队服务的持续集成。在我的 ubnuntu 服务器上成功运行的 dotnet restore 命令之后,我dot net build运行构建命令并发生下一个错误:

(GetReferenceAssemblyPaths target) -> /usr/share/dotnet/sdk/1.0.0-preview3-004056/Microsoft.Common.CurrentVersion.targets(1107,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.5" 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. Therefore your assembly may not be correctly targeted for the framework you intend.

我做错了什么?我尝试将 .net 版本修改为 4.0,我还查看了一些命令以获取 linux 的目标包,但我找不到解决方案。

我的系统运行:

  • 优麒麟 16.04.1 LTS
  • .NET Core 1.0.0 预览版 3

根据错误,您的项目引用 .net Framework 4.5,您需要引用 .net core。

  1. 打开项目.json
  2. 检查框架部分,代码应该是这样的(如果值为"net452"{},请修改它(:

法典:

"frameworks": {
    //"net452": { }
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

最新更新