简体   繁体   English

在Linux上构建Web API .NET Core

[英]Build web api .net core on linux

I'm using continuous integration with Microsoft (R) Visual Studio (R) Team Services . 我正在与Microsoft(R)Visual Studio(R)Team Services进行持续集成。 After the dotnet restore command which successfully runs on my ubnuntu server, then I run the build command dot net build and the next error occurs: 在成功在我的ubnuntu服务器上运行的dotnet restore命令之后,我运行了build命令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.

What did I wrong? 我怎么了 I tried to modify the .net version to 4.0, I also looked into some commands to get the targeting pack for linux but I can't find a solution. 我尝试将.net版本修改为4.0,我还研究了一些命令以获取linux的目标包,但找不到解决方案。

My system runs: 我的系统运行:

  • Ubuntu 16.04.1 LTS Ubuntu 16.04.1 LTS
  • .net core 1.0.0 preview 3 .net core 1.0.0预览版3

Based on the error, your project references to .net framework 4.5, you need to reference to .net core. 基于该错误,您的项目引用.net framework 4.5,因此您需要引用.net core。

  1. Open project.json 打开project.json
  2. Check the section of frameworks, the code should be like this (modify it if the value is “net452”{}): 检查框架部分,代码应如下所示(如果值为“ net452” {},请对其进行修改):

Code: 码:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM