c# - CI 构建定义中的新 .net Core Visual Studio 2017 项目 nuget 恢复

标签 c# azure-devops .net-core visual-studio-2017 nuget-package-restore

目前,我正在 Visual Studio 2017 中开发一个 .net core 项目。我还需要在 VSTS 中设置 CI(持续集成)。

这是我在构建定义中的 nuget 恢复步骤

enter image description here

但是我的构建失败了,因为它无法恢复任何包。这是它的日志。它说“此解决方案中的项目均未指定任何包”。我知道在 VS2017 中他们改变了处理 nuget 包的方式。 有人对此有想法或经验吗?

2017-03-22T20:25:11.9517911Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2017-03-22T20:25:11.9674167Z Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
2017-03-22T20:25:11.9830425Z ##[section]Finishing: NuGet restore **/*.sln

我不想使用 dotnet restore 因为 Microsoft 这么说了

.NET Core's dotnet restore command doesn't currently support encrypted credentials. To use VSTS NuGet feeds with dotnet restore, you'll need to specify a Personal Access Token in plain text.

所以我不想存储我的个人访问 token 。 https://www.visualstudio.com/en-us/docs/package/nuget/auth#net-core

最佳答案

您需要使用 NuGet 4.0。

从官方 NuGet 站点下载它。 https://dist.nuget.org/index.html

把它放在你有构建代理的机器上的一个文件夹里。

在 NuGet 恢复步骤的高级设置中,将 NuGet 版本设置为自定义。

在 NuGet.exe 的路径中指定放置 NuGet.exe 文件的路径。这是运行构建代理的机器上的路径。我尝试使用相对路径但无法使其正常工作,所以最后我设置了绝对路径。如果您有多个具有不同路径的代理,这对您来说可能是个问题,因此您可能需要弄清楚如何正确指定相对路径。

关于c# - CI 构建定义中的新 .net Core Visual Studio 2017 项目 nuget 恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42962436/

相关文章:

c# - 是否可以从成员中生成通用返回类型

c# - JSON.NET TypeNameHandling.Auto 除了顶级

powershell - 如何在 DevOps 管道上运行的 Powershell 上使用 key 保管库 secret

asp.net - DevOps 管道中的发布任务因导入项目未找到错误而失败

asp.net-core - .NET Core 中 AssemblyBuilder.DefineDynamicAssembly 的替换

c# - 如何正确使用代码契约?

c# - LINQ.Any 到字符串的结果

xamarin.android - 为面向 API 28 的 Xamarin.Android 项目构建管道

c# - 确定 ASP.Net Core webapp 是否在本地主机上运行

azure - 如何通过 Entity Framework 核心代码优先方法从 cosmosdb 集合中设置分区键?