Can';t获取管道以将自定义NuGet服务器与Azure DevOps构建一起使用
我的解决方案使用来自官方NuGet服务器和私有NuGet服务器的包。我正试图将构建管道配置为从这两个位置还原包,但不断出现NuGet restore构建错误,因为它似乎试图从公共NuGet服务器还原我的私有包,因此失败是可以理解的 我有点不知道我还应该做些什么。Azure DevOps中似乎没有可用于NuGet还原步骤的设置,因为看起来所有这些都是在YAML文件中配置的。任何关于我可能做错什么或我可以尝试什么的建议都将不胜感激 我的解决方案中的My numget.config:Can';t获取管道以将自定义NuGet服务器与Azure DevOps构建一起使用,nuget,azure-devops,nuget-package-restore,Nuget,Azure Devops,Nuget Package Restore,我的解决方案使用来自官方NuGet服务器和私有NuGet服务器的包。我正试图将构建管道配置为从这两个位置还原包,但不断出现NuGet restore构建错误,因为它似乎试图从公共NuGet服务器还原我的私有包,因此失败是可以理解的 我有点不知道我还应该做些什么。Azure DevOps中似乎没有可用于NuGet还原步骤的设置,因为看起来所有这些都是在YAML文件中配置的。任何关于我可能做错什么或我可以尝试什么的建议都将不胜感激 我的解决方案中的My numget.config: <?xml
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="Private" value="http://privatenuget.net:8080/nuget" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: 'MyProject.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@0
- task: NuGetCommand@2
inputs:
nugetConfigPath: 'MyProject\NuGet.config'
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
The nuget command failed with exit code(1) and error(Errors in packages.config projects
NU1000: Unable to find version '1.1.5' of package 'MyPackage'.
https://api.nuget.org/v3/index.json: Package 'MyPackage' is not found on source 'https://api.nuget.org/v3/index.json'.)
Packages failed to restore
我在构建的NuGetCommand步骤中遇到的错误:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageRestore>
<!-- Allow NuGet to download missing packages -->
<add key="enabled" value="True" />
<!-- Automatically check for missing packages during build in Visual Studio -->
<add key="automatic" value="True" />
</packageRestore>
<packageSources>
<add key="NuGet official package source" value="https://api.nuget.org/v3/index.json" />
<add key="Private" value="http://privatenuget.net:8080/nuget" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
pool:
vmImage: 'VS2017-Win2016'
variables:
solution: 'MyProject.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@0
- task: NuGetCommand@2
inputs:
nugetConfigPath: 'MyProject\NuGet.config'
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: VSTest@2
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
The nuget command failed with exit code(1) and error(Errors in packages.config projects
NU1000: Unable to find version '1.1.5' of package 'MyPackage'.
https://api.nuget.org/v3/index.json: Package 'MyPackage' is not found on source 'https://api.nuget.org/v3/index.json'.)
Packages failed to restore
您可以从一个空作业开始,而不使用现有的YAML。然后您可以设置代理/任务(nuget restore等)来构建应用程序
我刚刚遇到了这个问题,但我的项目中没有要使用的NuGet.config文件,也不想添加一个。使用NuGet.config要求您以明文形式存储个人访问令牌(PAT),至少可以说,这不太理想,尤其是当它与您的项目一起提交给您的回购协议时 经过大量研究,我找到了一个近乎完美的解决方案。使用Azure DevOps中的变量组,您可以添加可用于所有管道的变量(和机密)。我突然想到,我可以将整个NuGet.config放入一个秘密中(与PAT一起),然后将其作为管道的一部分导入到实际的NuGet.config文件中 您已经有了一个NuGet.config文件,但如果其他人登录此文件并从头开始,您需要以下内容:
<?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="MyPrivateFeed" value="*** PRIVATE FEED URL HERE ***" />
</packageSources>
<packageSourceCredentials>
<MyPrivateFeed>
<add key="Username" value="anything" />
<add key="ClearTextPassword" value="*** PAT HERE ***" />
</MyPrivateFeed>
</packageSourceCredentials>
</configuration>
并在将使用私有提要的任何其他步骤(如dotnet build
)之前,将以下内容添加到管道yaml中
您的YML文件不正确,必须添加feedsToUse:config
- task: NuGetCommand@2
displayName: 'Nuget Restore'
inputs:
restoreSolution: '$(solution)'
feedsToUse: config
nugetConfigPath: nuget.config
谢谢,在使用旧界面后,我查看了它生成的YAML文件。我原来的YAML的问题似乎是我的斜杠在nugetConfigPath设置中走错了方向。