简体   繁体   English

Artifactory通过PowerShell的身份验证还原nuget软件包

[英]Artifactory restore nuget packages with authentication from powershell

Our team started using Artifactory a few weeks ago and one of the challenges we are currently trying to work through is authentication. 我们的团队几周前开始使用Artifactory,我们目前正在努力解决的挑战之一就是身份验证。 Currently we have every developer setup in Artifactory with an account login, we have a build.ps1 file that we use to restore our nuget packages but we're trying to automate this process. 当前,我们在Artifactory中具有使用帐户登录名进行的每个开发人员设置,我们具有一个build.ps1文件,该文件用于还原nuget程序包,但我们正在尝试使该过程自动化。

Here is what our powershell script looks like. 这是我们的powershell脚本的样子。 But it is not prompting the user to enter their username and password, unless they add it as parameters to the .\\build.ps1 command line but the issue there is that the password is being entered in plain text. 但是,它不会提示用户输入用户名和密码,除非他们将其作为参数添加到。\\ build.ps1命令行中,但是存在的问题是密码是以纯文本形式输入的。

"Updating NuGet Dependencies"
$nuget = "$rootDir\.nuget\NuGet.exe"
if ($nuser)
{
    Invoke-Expression "$nuget Sources Update -Name 'Artifactory' -UserName $user -Password $pass"
}
Invoke-Expression "$nuget install -NonInteractive -DisableParallel"
if ($lastexitcode -ne 0) {
    Write-Host -foreground red "Error occurred downloading dependencies."
    exit 1
}
dir . | where { $_.psiscontainer } | where { (test-path (join-path $_.fullname "packages.config")) } | foreach {
    Invoke-Expression "$nuget install '$($_.fullname)\packages.config' -NonInteractive -DisableParallel"
    if ($lastexitcode -ne 0) {
        Write-Host -foreground red "Error occurred downloading project dependencies."
        exit 1
    }
}

This article on handling passwords and credentials might prove useful to you: 这篇关于处理密码和凭据的文章可能对您有用:

Working with Passwords, Secure Strings and Credentials in Windows PowerShell 在Windows PowerShell中使用密码,安全字符串和凭据

I had some problems with setting the credentials. 我在设置凭据时遇到了一些问题。

My solutions was to upgrade nuget.exe (v4.3.0 from v3.xx) and using the Add Sources with the username/ password, with the ApiKey from the Artifactory as the password. 我的解决方案是升级nuget.exe(从v3.xx升级到v4.3.0),并使用带有用户名/密码的添加源,并使用来自Artifactory的ApiKey作为密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 PowerShell 脚本中,如何还原包以解决错误:此项目引用此计算机上缺少的 NuGet 包 - In PowerShell script, how can I restore packages to resolve error: This project references NuGet package(s) that are missing on this computer 如何从 PowerShell 下载项目引用的 Nuget 包? - How to download Nuget packages referenced by project from PowerShell? PowerShell 脚本安装 nuget 包 - PowerShell scripts to install nuget packages 如何使用 Powershell 强制 Nuget 还原? - How to force Nuget Restore using Powershell? Nuget包使用PowerShell进行版本差异分析 - Nuget Packages Version difference analysis using powershell Visual Studio多项目模板还原所有nuget包 - Visual studio multi project template restore all nuget packages 从 NuGet 包加载程序集 - Loading Assemblies from NuGet Packages Nuget 恢复命令行响应 Package is not found on source - Artifactory 云服务器 - Nuget restore command line responds Package is not found on source - Artifactory cloud server 通过PowershellGet和Azure AD SAML身份验证使用本地Artifactory PowerShell画廊 - Using a local Artifactory PowerShell gallery with PowershellGet and Azure AD SAML authentication 从 Windows Powershell 脚本上传到 Artifactory - Uploading to Artifactory from a Windows Powershell script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM