2017-02-28 102 views
3

这个问题是关于Visual Studio团队业务的不断整合功能,特别是在自动构建。.NET核心的NuGet还原失败,私人的NuGet饲料(VSTS CI构建)

我已经成立了一个生成定义建立我的.NET的核心MVC应用程序。

它是使用.NET的核心v1和编制针对.NET框架4.5.2。

我在这里跟着指示:

https://www.visualstudio.com/en-us/docs/build/apps/aspnet/ci/build-aspnet-core

我有一个私人的NuGet饲料中VSTS 这里设置是将程序包料源的命令:

Sources Add -Name "CiiDLFeed" -UserName "<username>" -Password "<password>" -ConfigFile $(Build.SourcesDirectory)/Nuget.config -Source https://mycompany.pkgs.visualstudio.com/_packaging/DLFeed/nuget/v3/index.json 

我收到的错误:

error: Unable to load the service index for source https://mycompany.pkgs.visualstudio.com/_packaging/DLFeed/nuget/v3/index.json . error: Password decryption is not supported on .NET Core for this platform. The following feed uses an encrypted password: 'CiiDLFeed'. You can use a clear text password as a workaround.

针对这个问题,我补充说:“-StorePasswordInClearText”参数来的NuGet源添加命令:

Sources Add -Name "CiiDLFeed" -UserName "<username>" -Password "<password>" -ConfigFile $(Build.SourcesDirectory)/Nuget.config -Source https://mycompany.pkgs.visualstudio.com/_packaging/DLFeed/nuget/v3/index.json -StorePasswordInClearText 

现在,我得到一个401错误:

error: Unable to load the service index for source https://mycompany.pkgs.visualstudio.com/_packaging/DLFeed/nuget/v3/index.json . error: Response status code does not indicate success: 401 (Unauthorized).

我使用的是完全相同的凭据在一个单独的构建定义工作正常,访问相同的Nuget饲料(一个.NET Web窗体应用程序),所以它不应该给我一个401.

我也试图简单地引用库DLL而不是NuGet打包在一个私人饲料,但似乎是没有牛逼可能与.NET的核心:

.NET core projects only support referencing .NET framework assemblies in this release. To reference other assemblies, they need to be included in a NuGet package and reference that package.

+0

尝试使用V2为feed地址。我发现v3并不总是可靠的 – trailmax

+0

@trailmax我仍然遇到'v2'的401错误。感谢您的建议 –

+0

您是否使用实际密码或个人访问令牌作为密码? – trailmax

回答

1

我们所用的解决方法解决方案是建立一个本地的NuGet源是在项目的目录。然后将.nupkg文件添加到它,并在您的项目中引用它们。

这使得VSTS CI构建可以在不设置远程NuGet源的情况下访问NuGet包。

如:

project_directory/ 
    ... project files ... 
    my_nuget_repo/ 
     mypackage.nupkg 

添加本地源:

nuget sources add -Name "my_nuget_repo" -Source "<path_to_project>/my_nuget_repo" 
0

你需要自己Nuget.Config文件,而不是(可使用PAT作为密码):

  1. 添加Nuget.Config文件(包括相应的packageSource)至源控制
  2. 编辑您的构建定义
  3. 删除/禁用命令行的步骤,用来添加包源
  4. 选择对.NET核心(预览)还原步骤。

参数,如:

--configfile $(build.sourcesdirectory)/ConsoleAppCore/Nuget.Config 

注意:您可以创建或解决方案根编辑NuGet.config,旁边project.json文件,并检查到源头控制,用这种方式,你不需要为.Net Core还原步骤指定configfile参数。

+0

你会在NuGet.config中包含指定NuGet源代码的语法吗? –

+0

@JamesWierzba语法就像你说的nuget sources add ...一样,在你本地机器和相应的Nuget.config(缺省为%APPDATA%\ NuGet)中对源代码进行控制。 –

+0

@JamesWierzba使用PAT是更好的方式,它对我来说工作正常。尝试使用PAT作为密码并检查结果。 –