Search code examples
azure-devopsazure-pipelinesnuget-package-restoredotnet-cli

DotNetCLI@2 pack seems to be ignoring configuration inputs


The below YAML snippet does not seem to work as expected.

I configured it in a pipeline that runs using the windows-latest image and it attempts to restore all of the projects that are in the repo, instead of looking just to the solution file.

Also, it seems to completely ignore the --no-restore flag

- task: DotNetCoreCLI@2
  displayName: Package to Staging directory
  inputs:
    command: pack
    configuration: $(BUILD_CONFIGURATION)
    projects: 'support-libs.sln'
    packDirectory: $(Build.ArtifactStagingDirectory)
    nugetConfigPath: 'sf-solution/nuget.config'
    arguments: '--no-restore'
    verbosityRestore: Minimal

The command that appears on the step logs is:

"C:\Program Files\dotnet\dotnet.exe" pack d:\a\1\s\sf-solution\SampleProject\SampleProject.csproj --output d:\a\1\a /p:Configuration=Debug --verbosity Detailed

The above project is not even included in the support-libs SLN file the snippet has configured.


Solution

  • I was finally able to do what I wanted and to pack all the libraries inside the solution, however I had to use a custom command instead of the pack one:

    - task: DotNetCoreCLI@2
      displayName: Package to Staging directory
      inputs:
        command: custom
        custom: 'pack'
        arguments: 'support-libs.sln -c=$(BUILD_CONFIGURATION) -o $(Build.ArtifactStagingDirectory)'
        verbosityRestore: Minimal
        verbosityPack: Minimal
        feedsToUse: select
        vstsFeed: personalnugetfeed
        nuGetFeedType: internal
        includeNuGetOrg: true
    

    I was also having authorization issues with the internal feed that was in the Nuget configuration and linking to that file, even from a custom command, had the same issues. Explicitly stating from which feed the restore should be made worked perfectly and I was able to retrieve all the dependencies removing the need to use the --no-restore flag.