我为UWP项目创建了CICD样条线。具有以下提到的代码的管道的Powershell任务失败,错误消息为 APPX0108:指定的证书已过期。有关续订证书的更多信息,请参见https://regex101.com/r/dxF4sT/1
因此,我在Visual Studio 2017中创建了明年到期的新测试证书,并将新证书(.pfx)文件推送到了仓库中。我还更新了.csproj文件,以使用新证书的名称对其进行更新。
现在我在管道中的构建解决方案任务中遇到了相同的错误。我想知道我在想什么。我也必须将该证书添加到构建服务器中吗?
PowerShell脚本代码:
Param(
[String]$pfxpath,
[String]$password
)
if (-Not $pfxpath) {
Write-Host "Certificate path not set"
exit 1
}
if (-Not $password) {
Write-Host "Password not set"
exit 1
}
Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxpath, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($cert)
$store.Close()