作为 Team Foundation Server Post 进程的 ClickOnce 部署的签名问题
Signing issues with ClickOnce deployment as a Team Foundation Server Post Process
我正在尝试使用 TFS 在 CI 中部署一堆 WPF 应用程序。到目前为止,部署步骤是手动激活的,即我从我的开发人员那里调用了一个 Powershell 脚本。通过每个项目框到 运行 并部署。如果有帮助,这里是代码片段。
$projs = Get-ChildItem -Path $pwd -Recurse -Include '*.csproj
foreach ($proj in $projs)
{
$xml = [xml](Get-Content $proj)
$assemblyName=""
$publishUrl = ""
$productName =""
$nodes = $xml.GetElementsByTagName('AssemblyName')
#Write "Trying to get AssemblyName"
foreach ($node in $nodes) {
$oldName = $node.'#text'
if($oldName.Contains("Beta")){continue}
$newName =$oldName+'_Beta'
#skip any PublishUrl that is still the default 'publish\'
# Write $newName
$node.'#text' = $newName
$assemblyName = $newName
}
#Write "Trying to get ProductName"
$nodesProduct = $xml.GetElementsByTagName('ProductName')
foreach ($node in $nodesProduct) {
if($node.'#text'.Contains(".NET"))
{
continue
}
$oldName = $node.'#text'
if($oldName.Contains("Beta")){continue}
$newName =$oldName+'_Beta'
# Write $newName
$node.'#text' = $newName
$productName = $newName
}
#Write "Trying to get PublishURL"
$nodesPublish = $xml.GetElementsByTagName('PublishUrl')
foreach ($node in $nodesPublish) {
$oldName = $node.'#text'
#skip any PublishUrl that is still the default 'publish\'
if ($node.'#text' -eq 'publish\') { break }
if($oldName.Contains("Beta")){continue}
$newName =$oldName+'Beta\'
# Write $newName
$node.'#text' = $newName
$publishUrl = $newName
}
#if all three params are not null save and deploy project
if($assemblyName -ne"" -And $publishUrl -ne "" -And $productName -ne "" )
{
$xml.Save($proj)
Write "trying to deploy $productName to $publishUrl"
msbuild /m /t:publish /p:Configuration='Debug' /p:Platform=AnyCPU /p:ApplicationVersion=$appVersion /p:ApplicationRevision=$Revision /p:MinimumRequiredVersion=$newVersion /p:PublishUrl="$publishUrl" /verbosity:m $proj
$pubDir = Join-Path $proj.Directory -ChildPath "bin\Debug\app.publish" -Resolve -ErrorAction Stop
#copy the files to the publish URL
Write "$pubDir"
Copy-Item -Path "${pubDir}\*" -Destination "$publishUrl" -Include '*.*' -Recurse -Force
Copy-Item -Path "${pubDir}\Application Files" -Destination "$publishUrl" -Recurse -Force
tf vc undo /noprompt $proj
Write "Tf undone"
}`
请忽略所有测试版内容,因为我更改了我的 Assembly-info.cs 以将开发和生产环境部署分开。我已经生成了自己的证书并将其链接到我的 .csproj 文件。这行得通并且已经过测试,是我们当前的策略。
我想将此脚本作为 Post 过程操作集成到 Team Foundation Server 中,以便我们可以获得 CD。
在服务器上,我有:
- VSTS 运行宁作为我的管理员帐户
- 我在服务器上安装的 pfx 证书
同样的脚本会生成以下错误:
\(x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(2884,5): warning MSB3327: Unable to find code signing certificate in the current user's Windows certificate store. To correct this, either disable signing of the ClickOnce manifest or install the certificate into the certificate store.
\(x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(4961,5): MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint".
我注意到 TFS 服务复制到代理上的 .csproj 没有链接到导入的证书(也在源代码管理中)
到目前为止,我已尝试在服务器本身上安装证书,并且还尝试 运行ning 作为 NTService。可以在这些线程中找到有关此错误的更多信息
1 , 2 , 3。但是,他们的解决方案似乎都不起作用。
如果有任何帮助,我将不胜感激。
这就是我最终使它起作用的方法。
将我的 pfx 作为链接文件添加到我所有的 UI 项目
使所有项目都使用来自此文件的证书 menu
已将其签入源代码管理
创建了一个新的构建定义谁唯一的工作就是 运行 我的 powershell
片段
运行我在TFS上的账号下构建
我正在尝试使用 TFS 在 CI 中部署一堆 WPF 应用程序。到目前为止,部署步骤是手动激活的,即我从我的开发人员那里调用了一个 Powershell 脚本。通过每个项目框到 运行 并部署。如果有帮助,这里是代码片段。
$projs = Get-ChildItem -Path $pwd -Recurse -Include '*.csproj
foreach ($proj in $projs)
{
$xml = [xml](Get-Content $proj)
$assemblyName=""
$publishUrl = ""
$productName =""
$nodes = $xml.GetElementsByTagName('AssemblyName')
#Write "Trying to get AssemblyName"
foreach ($node in $nodes) {
$oldName = $node.'#text'
if($oldName.Contains("Beta")){continue}
$newName =$oldName+'_Beta'
#skip any PublishUrl that is still the default 'publish\'
# Write $newName
$node.'#text' = $newName
$assemblyName = $newName
}
#Write "Trying to get ProductName"
$nodesProduct = $xml.GetElementsByTagName('ProductName')
foreach ($node in $nodesProduct) {
if($node.'#text'.Contains(".NET"))
{
continue
}
$oldName = $node.'#text'
if($oldName.Contains("Beta")){continue}
$newName =$oldName+'_Beta'
# Write $newName
$node.'#text' = $newName
$productName = $newName
}
#Write "Trying to get PublishURL"
$nodesPublish = $xml.GetElementsByTagName('PublishUrl')
foreach ($node in $nodesPublish) {
$oldName = $node.'#text'
#skip any PublishUrl that is still the default 'publish\'
if ($node.'#text' -eq 'publish\') { break }
if($oldName.Contains("Beta")){continue}
$newName =$oldName+'Beta\'
# Write $newName
$node.'#text' = $newName
$publishUrl = $newName
}
#if all three params are not null save and deploy project
if($assemblyName -ne"" -And $publishUrl -ne "" -And $productName -ne "" )
{
$xml.Save($proj)
Write "trying to deploy $productName to $publishUrl"
msbuild /m /t:publish /p:Configuration='Debug' /p:Platform=AnyCPU /p:ApplicationVersion=$appVersion /p:ApplicationRevision=$Revision /p:MinimumRequiredVersion=$newVersion /p:PublishUrl="$publishUrl" /verbosity:m $proj
$pubDir = Join-Path $proj.Directory -ChildPath "bin\Debug\app.publish" -Resolve -ErrorAction Stop
#copy the files to the publish URL
Write "$pubDir"
Copy-Item -Path "${pubDir}\*" -Destination "$publishUrl" -Include '*.*' -Recurse -Force
Copy-Item -Path "${pubDir}\Application Files" -Destination "$publishUrl" -Recurse -Force
tf vc undo /noprompt $proj
Write "Tf undone"
}`
请忽略所有测试版内容,因为我更改了我的 Assembly-info.cs 以将开发和生产环境部署分开。我已经生成了自己的证书并将其链接到我的 .csproj 文件。这行得通并且已经过测试,是我们当前的策略。 我想将此脚本作为 Post 过程操作集成到 Team Foundation Server 中,以便我们可以获得 CD。
在服务器上,我有:
- VSTS 运行宁作为我的管理员帐户
- 我在服务器上安装的 pfx 证书
同样的脚本会生成以下错误:
\(x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(2884,5): warning MSB3327: Unable to find code signing certificate in the current user's Windows certificate store. To correct this, either disable signing of the ClickOnce manifest or install the certificate into the certificate store.
\(x86)\MSBuild.0\bin\Microsoft.Common.CurrentVersion.targets(4961,5): MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint".
我注意到 TFS 服务复制到代理上的 .csproj 没有链接到导入的证书(也在源代码管理中)
到目前为止,我已尝试在服务器本身上安装证书,并且还尝试 运行ning 作为 NTService。可以在这些线程中找到有关此错误的更多信息 1 , 2 , 3。但是,他们的解决方案似乎都不起作用。 如果有任何帮助,我将不胜感激。
这就是我最终使它起作用的方法。
将我的 pfx 作为链接文件添加到我所有的 UI 项目
使所有项目都使用来自此文件的证书 menu
已将其签入源代码管理
创建了一个新的构建定义谁唯一的工作就是 运行 我的 powershell 片段
运行我在TFS上的账号下构建