Home > OS >  .net Core Pipeline in azure devops
.net Core Pipeline in azure devops

Time:09-28

I am new to working with Azure DevOps. I am trying to create a pipeline in order to compile a Visual Studio 2022 solution. In order to do this, I have to install NuGet packages from a remote server (https://api.nuget.org/v3/index.json) and also from a local directory (packages stored on my repository). Here my Yaml file

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1


- task: NuGetCommand@2
  inputs:
    command: 'restore'
    packagesToPush: ' $(Build.SourcesDirectory)/NuPackages/*.nupkg'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    allowPackageConflicts: true
    includeNuGetOrg: true

When I launch my pipline, the remote package are installed but not the local ones.

> Installed:
>     158 package(s) to D:\a\1\s\****.csproj
>     212 package(s) to D:\a\1\s\****.csproj
>     158 package(s) to D:\a\1\s\****.csproj
> ##[error]The nuget command failed with exit code(1) and error(NU1101: Unable to find package UnifiedAutomation.UaBase.BouncyCastle. No
> packages exist with this id in source(s): NuGetOrg NU1101:

I've also tried to do this in two steps, but I had the same problem If anybody have an idea, it will be great.

Thanks in advance

CodePudding user response:

try adding this task :

- task: NuGetAuthenticate@0

to make sure you have the pipelines has access to your nuget repos. Following this official documentation

Also make sure the nuget repos are within the sources of nugets in your code (project/.nuget/nuget.config) :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <solution>
    <add key="disableSourceControlIntegration" value="true" />
  </solution>
  <packageSources>
    <add key="Nuget v2" value="https://www.nuget.org/api/v2" />
    <add key="Nuget v3" value="https://api.nuget.org/v3/index.json" />
    <add key="your nuget repos" value="https://nugetreposlink/nuget/v3/index.json" />
  </packageSources>
</configuration>

CodePudding user response:

You must have your nuget.config. Yml file become

- task: NuGetToolInstaller@1
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'config'
    nugetConfigPath: 'NuGet.Config'

and in the same location of your yml file add a Nuget.config with all your value:

<?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="DevExpress" value="https://nuget.devexpress.com/xxx/api" />
  </packageSources>
</configuration>
  • Related