使用.NET库参考构建错误Team City .NET Core

时间:2016-12-19 13:12:00

标签: deployment msbuild asp.net-core teamcity

我正在努力找出使用Team City使用csproj引用构建.NET Core项目的问题,我实际上是新手相关的团队城市流程,但我还读过其他类似的问题但是没有一个解决方法适合我。 这是Team City显示的消息:

error NU1001: The dependency Microsoft.ApplicationInsights.AspNetCore >= 1.0.0 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(4, 39): error NU1001: The dependency Microsoft.AspNetCore.Mvc >= 1.0.1 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(11, 50): error NU1001: The dependency Microsoft.AspNetCore.Server.Kestrel >= 1.0.1 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(13, 64): error NU1001: The dependency Microsoft.Extensions.Configuration.FileExtensions >= 1.0.0 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(14, 54): error NU1001: The dependency Microsoft.Extensions.Configuration.Json >= 1.0.0 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(16, 51): error NU1001: The dependency Microsoft.Extensions.Logging.Console >= 1.0.0 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(17, 49): error NU1001: The dependency Microsoft.Extensions.Logging.Debug >= 1.0.0 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(18, 67): error NU1001: The dependency Microsoft.Extensions.Options.ConfigurationExtensions >= 1.0.0 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(24, 43): error NU1001: The dependency Microsoft.AspNetCore.Session >= 1.0.0 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(25, 34): error NU1001: The dependency Swashbuckle >= 6.0.0-beta901 could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(27, 25): error NU1001: The dependency ***.Utilities - .net 4.5.0 project*** could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(30, 24): error NU1001: The dependency ***.Data - .net 4.5.2 project *** could not be resolved. 
•   C:\BuildAgent\work\1e2a73a15b18c502\ProjectFolder\ProjectCore\project.json(33, 28): error NU1001: The dependency ***.Domain - .net 4.5.2 project*** could not be resolved. 

这是我的project.json

{
  "dependencies": {
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Mvc.Abstractions": "1.1.0",
    "Microsoft.AspNetCore.Mvc.Core": "1.1.0",
    "Microsoft.AspNetCore.Mvc.ViewFeatures": "1.1.0",
    "Microsoft.AspNetCore.Http": "1.1.0",
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "FluentNHibernate": "2.0.3",
    "Newtonsoft.Json": "9.0.1",
    "Microsoft.AspNetCore.Http.Features": "1.1.0",
    "Microsoft.AspNet.WebApi.Client": "5.2.3",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.AspNetCore.Session": "1.0.0",
    "Swashbuckle": "6.0.0-beta901"

  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net452": {
      "dependencies": {
        "***.Utilities": {
          "target": "project"
        },
        "***.Data": {
          "target": "project"
        },
        "***.Domain": {
          "target": "project"
        }
      }
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

有人可以帮我吗?我不知道可能出现什么问题。

提前致谢

1 个答案:

答案 0 :(得分:0)

我刚刚遇到类似的问题,因为.NET Core Project引用了完整的.NET Framework 4.6.1。

首先,检查构建服务器上是否安装了正确的.NET核心版本 可以找到实际的.NET Core版本here

然后检查NuGet.exe版本,如果需要,将其升级到3.5.0。

然后,根据此SO Answer,下载并安装正确的.NET Framework目标配置文件,然后重新启动TeamCity代理和服务器服务。 (此步骤导致我的构建失败)

最后,重建您的解决方案。 TeamCity应该成功还原包并构建解决方案。

希望这有帮助。