Search code examples
azure-devopsazure-pipelinesazure-artifacts

How to run nuget package (tool) from artifact feed


I'm begginer to devops. And I got a task to create 2 pipelines. One for building project and publishing it to artifact feed. And another pipeline is to run that tool. First one I have created (created nuget as a tool and placed in my feed). How can I now create pipeline that will do dotnet run but from my feed?

I just need guidance a big picture.

I'm trying something like this:

 pool:
  vmImage: windows-latest

   jobs:
- job: RunTool
  displayName: Run Tool
  steps:
      - task: DotNetCoreCLI@2
        inputs:
          command: 'custom'
          custom: 'tool'
          arguments: 'install -g --add-source=https://pkgs.dev.azure.com/EPMC-STC/ab5c31ad-1d77-4369-80f4-ff2f14a12667/_packaging/MilanDjukicFeed/nuget/v3/index.json MigrationApp --version 8.0.18'

I'm getting:

Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
C:\Users\VssAdministrator\AppData\Local\Temp\d49e97f8-e901-42d7-8c3e-d1eca71c6055\restore.csproj : error NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/EPMC-STC/ab5c31ad-1d77-4369-80f4-ff2f14a12667/_packaging/MilanDjukicFeed/nuget/v3/index.json.
The tool package could not be restored.
Tool 'migrationapp' failed to install. This failure may have been caused by:

* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.

For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : 
Finishing: DotNetCoreCLI

On Artifacts I have MigrationApp nuget package. I can download it and run it localy.


Solution

  • Since you are creating Nuget as tool and need to use it in pipeline, you can use dotnet tool install command to install the Nuget tool and define the feed source.

    For example: Add a command line task/ Bash task/ PowerShell

    dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/<projectname>/_packaging/<feedname>/nuget/v3/index.json toolname
    

    Then you can use the nuget tool in next tasks.

    On the other hand, if you need to download the Nuget Package, you can use the task: Download package task to download the nuget package from feed and do next actions.