Visual studio 如何将下载的.pfx证书仅分配给azure devops中的一个项目

Visual studio 如何将下载的.pfx证书仅分配给azure devops中的一个项目,visual-studio,powershell,azure-devops,Visual Studio,Powershell,Azure Devops,我有.pfx证书,该证书已使用“下载安全文件”任务下载到我的build.sourceDirectory。现在我只想将该证书分配给一个项目,而不是所有项目 尝试了PowerShell脚本,但出现以下错误。请建议其他备选方案,如果有错误,请更正脚本 找不到“导入”和参数计数的重载:“2”。在 D:\a_temp\88829cbf-115f-4b06-aa8a-c072600792f7.ps1:10字符:1 +$cert.Import($pfxpath,$password) + ~~~~~~~~~~~

我有.pfx证书,该证书已使用“下载安全文件”任务下载到我的
build.sourceDirectory
。现在我只想将该证书分配给一个项目,而不是所有项目

尝试了PowerShell脚本,但出现以下错误。请建议其他备选方案,如果有错误,请更正脚本

找不到“导入”和参数计数的重载:“2”。在 D:\a_temp\88829cbf-115f-4b06-aa8a-c072600792f7.ps1:10字符:1 +$cert.Import($pfxpath,$password) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:NotSpecified:(:)[],ParentContainerRorRecordException +FullyQualifiedErrorId:MethodCountNotFindBest


您可能会错过方法
import
的参数。官方文档显示需要为导入方法指定存储标志。有关的详细信息


有关导入的更多用法,请检查方法
导入的参数可能会丢失。官方文档显示需要为导入方法指定存储标志。有关的详细信息

有关导入的更多用法,请查看

$pfxpath = '$(Build.SourceDirectory)\cert.pf'

 $password = '{password}'

 Add-Type -AssemblyName System.Security

 $cert = New-Object   
 System.Security.Cryptography.X509Certificates.X509Certificate2

 $cert.Import($pfxpath, $password )

 $store = new-object system.security.cryptography.X509Certificates.X509Store 
 -argumentlist "MY", CurrentUser

 `$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")`

 $store.Add($cert)

 $store.Close()
Import(String, String, X509KeyStorageFlags)