My solution uses packages from both the official NuGet server as well as a private NuGet server. I am trying to configure my build pipeline to restore packages from both locations, but keep getting NuGet restore build errors where it looks like it is trying to restore my private package from the public NuGet server and understandably failing because of that.
I am at a bit of a loss as to what else I should do. It appears that there are no settings within Azure DevOps that can be made for the NuGet restore step as it looks like that is all configured within the YAML file now. Any suggestions on what I could be doing wrong or what else I could try would be appreciated.
My NuGet.config in my solution:
<?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>
My YAML file that Pipelines is using:
# 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)'
My error I get on the NuGetCommand step of the build:
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