如何从工件提要运行nuget包(工具)



我是开发新手。我的任务是创建两个管道。一个用于构建项目并将其发布到工件提要。另一个管道是运行这个工具。第一个是我创建的(创建nuget作为工具并放在我的提要中)。我现在如何创建将从我的提要执行dotnet run的管道?

我只是需要一个指导。

我正在尝试这样做:

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'

我:

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:UsersVssAdministratorAppDataLocalTempd49e97f8-e901-42d7-8c3e-d1eca71c6055restore.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 Filesdotnetdotnet.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

在工件上,我有MigrationApp nuget包。我可以下载它并在本地运行。

由于您正在创建Nuget作为工具,并且需要在管道中使用它,因此您可以使用dotnet tool install命令来安装Nuget工具并定义提要源。

例如:添加命令行任务/Bash任务/PowerShell

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

然后你可以在接下来的任务中使用nuget工具。

另一方面,如果您需要下载Nuget包,您可以使用任务:download Package任务从提要中下载Nuget包并执行下一步操作。

最新更新