Я использую Azure DevOps и хотел бы запустить dotnet tool restore --interactive
в моем Build Pipeline. В моем репо кода nuget.config
выглядит следующим образом. Файл имеет приватный канал, размещенный в Azure Artifact в дополнение к nuget.org.
<?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="MyTools" value="https://mytools.pkgs.visualstudio.com/MyBot/_packaging/MyTools/nuget/v3/index.json" />
</packageSources>
</configuration>
В приватной ленте в Azure Artifact существуют мои личные инструменты do tnet. Чтобы получить инструмент, который я создал, следуя файлу yml.
pool:
vmImage: "windows-latest"
demands:
- msbuild
- visualstudio
- vstest
variables:
buildPlatform: "Any CPU"
buildConfiguration: "Release"
steps:
- task: PowerShell@2
inputs:
targetType: inline
script: "Invoke-WebRequest -Uri https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.ps1 -OutFile ./installcredprovider.ps1 ;./installcredprovider.ps1;"
- task: DotNetCoreCLI@2
displayName: "Restore tools"
inputs:
command: custom
custom: tool
arguments: restore --interactive
Однако, когда я запускаю файл yml в процессе сборки, появляется следующий результат. Как видно из сообщения, требуется вход в систему, но я не хочу каждый раз выполнять вход на устройство. Так есть ли какой-нибудь хороший способ, чтобы мне не приходилось каждый раз выполнять вход на устройство?
##[section]Starting: Restore tools
==============================================================================
Task : .NET Core
Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
Version : 2.162.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
==============================================================================
[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
[command]"C:\Program Files\dotnet\dotnet.exe" tool restore --interactive
Welcome to .NET Core 3.1!
---------------------
SDK Version: 3.1.100
Telemetry
---------
The .NET Core tools collect usage data in order to help us improve your experience. The data is anonymous. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
Read more about .NET Core CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry
----------------
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Find out what's new: https://aka.ms/dotnet-whats-new
Learn about the installed HTTPS developer cert: https://aka.ms/aspnet-core-https
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs
Write your first app: https://aka.ms/first-net-core-app
--------------------------------------------------------------------------------------
[CredentialProvider]DeviceFlow: https://mytools.pkgs.visualstudio.com/MyBot/_packaging/MyTools/nuget/v3/index.json
[CredentialProvider]ATTENTION: User interaction required.
**********************************************************************
To sign in, use a web browser to open the page https://microsoft.com/devicelogin to authenticate.
**********************************************************************
C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error : [CredentialProvider]Device flow authentication failed. User was presented with device flow, but didn't react within 90 seconds. [C:\Users\VssAdministrator\AppData\Local\Temp\wk4fkuq1.hqu\restore.csproj]
C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error : Unable to load the service index for source https://mytools.pkgs.visualstudio.com/MyBot/_packaging/MyTools/nuget/v3/index.json. [C:\Users\VssAdministrator\AppData\Local\Temp\wk4fkuq1.hqu\restore.csproj]
C:\Program Files\dotnet\sdk\3.1.100\NuGet.targets(123,5): error : Response status code does not indicate success: 401 (Unauthorized). [C:\Users\VssAdministrator\AppData\Local\Temp\wk4fkuq1.hqu\restore.csproj]
Restore completed in 775.06 ms.
Tool 'dotnet-ef' (version '3.1.1') was restored. Available commands: dotnet-ef
Package "localenv" failed to restore, due to Microsoft.DotNet.ToolPackage.ToolPackageException: The tool package could not be restored.
at Microsoft.DotNet.Tools.Tool.Install.ProjectRestorer.Restore(FilePath project, PackageLocation packageLocation, String verbosity)
at Microsoft.DotNet.ToolPackage.ToolPackageInstaller.InstallPackageToExternalManagedLocation(PackageLocation packageLocation, PackageId packageId, VersionRange versionRange, String targetFramework, String verbosity)
at Microsoft.DotNet.Tools.Tool.Restore.ToolRestoreCommand.InstallPackages(ToolManifestPackage package, Nullable`1 configFile)
Restore partially failed.
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
Some commonly encountered changes are:
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. 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 :
##[section]Finishing: Restore tools! (Including efcore tools)