我正在使用Azure DevOps,并且想在我的构建管道中运行number
。在我的代码存储库中,有dotnet tool restore --interactive
如下。该文件除了nuget.org外,还具有一个托管在Azure Artifact中的私人供稿。
nuget.config
在Azure Artifact的私有提要中,存在我的私有dotnet工具。要检索我在yml文件之后创建的工具。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="MyTools" value="https://mytools.pkgs.visualstudio.com/MyBot/_packaging/MyTools/nuget/v3/index.json" />
</packageSources>
</configuration>
但是,当我在构建过程中运行yml文件时,出现以下结果。如消息所示,它需要登录,但是我不想每次都进行设备登录。那么,有什么好方法可以让我不必每次都登录设备吗?
pool:
vmImage: "windows-latest"
demands:
- msbuild
- visualstudio
- vstest
variables:
buildPlatform: "Any CPU"
buildConfiguration: "Release"
steps:
- task: PowerShell@2
inputs:
targetType: inline
script: "Invoke-WebRequest -Uri https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1 -OutFile ./installcredprovider.ps1 ;./installcredprovider.ps1;"
- task: DotNetCoreCLI@2
displayName: "Restore tools"
inputs:
command: custom
custom: tool
arguments: restore --interactive
答案 0 :(得分:0)
您不能在构建管道中使用标志--interactive
,因为该标志只能在执行期间从用户获得输出。
您可以在.Net核心任务中使用默认的还原选项:
- task: DotNetCoreCLI@2
inputs:
command: 'restore'
projects: '$(Build.SourcesDirecotry)/path/to/csproj'
feedToUse: 'config'
nugetConfigPath: '$(Build.SourcesDirectory)/path/to/nuget.config'
答案 1 :(得分:0)
这是因为在dotnet恢复之前,您应该让代理知道带有预认证的提要URL的nuget源:
- task: NuGetCommand@2
displayName: 'Add Nuget Feed'
inputs:
command: custom
arguments: 'sources add -name <name_of_source> -source <feed_url>'
我希望这会有用。