C# 将CLICKONE部署作为Team Foundation服务器后处理的签名问题

C# 将CLICKONE部署作为Team Foundation服务器后处理的签名问题,c#,wpf,tfs,msbuild,clickonce,C#,Wpf,Tfs,Msbuild,Clickonce,我正在尝试使用TFS在CI中部署一组WPF应用程序。到目前为止,部署步骤是手动激活的,也就是说,我从dev.box调用了一个Powershell脚本来运行每个项目并进行部署。如果有帮助,下面是代码片段 $projs = Get-ChildItem -Path $pwd -Recurse -Include '*.csproj foreach ($proj in $projs) { $xml = [xml](Get-Content $proj) $assemblyName=""

我正在尝试使用TFS在CI中部署一组WPF应用程序。到目前为止,部署步骤是手动激活的,也就是说,我从dev.box调用了一个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文件。这是行之有效的,并且已经过测试,这是我们当前的战略。 我想把这个脚本集成到Team Foundation Server中的后处理操作中,这样我们就可以得到CD。p> 在服务器上,我有:

  • 作为我的管理员帐户运行的VSTS
  • 服务器上安装的我的pfx证书
  • 此脚本会生成以下错误:

    \(x86)\MSBuild\14.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\14.0\bin\Microsoft.Common.CurrentVersion.targets(4961,5):  MSB4044: The "SignFile" task was not given a value for the required parameter "CertificateThumbprint". 
    
    我注意到TFS服务复制到代理上的.csproj没有与导入的证书(也在源代码管理中)的链接

    到目前为止,我已尝试在服务器本身上安装证书,并尝试作为NTService运行。可以在这些线程中找到有关此错误的更多信息 , , . 然而,他们的两种解决方案似乎都不起作用。
    如果有任何帮助,我将不胜感激。

    这就是我最后为使它工作所做的

  • 将我的pfx作为链接文件添加到我的所有UI项目

  • 使所有项目都使用此文件中的证书

  • 将其签入源代码管理

  • 创建了一个新的构建定义谁的唯一工作就是运行我的powershell 片段

  • 在TFS上以我的帐户运行生成


  • 这就是我最终要做的,让它发挥作用

  • 将我的pfx作为链接文件添加到我的所有UI项目

  • 使所有项目都使用此文件中的证书

  • 将其签入源代码管理

  • 创建了一个新的构建定义谁的唯一工作就是运行我的powershell 片段

  • 在TFS上以我的帐户运行生成


  • 您是否已尝试通过tfs生成源代码(用于所有项目),然后使用自己的证书对此生成进行签名,请使用
    mage.exe
    单击一个清单?当然,这是获得您想要的资源的唯一替代方法。如果我这样做,我可以保留当前系统,它在tfs中构建源代码,并使用PS脚本进行部署。我的目标是完全自动化交付,因此它可以在没有任何开发人员干预的情况下运行,无论是使用门控签入还是基于时间的触发器。除非我遗漏了什么。对于上面的示例,您还可以使用
    mage.exe
    编写PSScript来签署清单和证书。所以这个解决方案是完全自动化的交付。我明白了。我对法师的经验有限,所以请原谅我对你的解决方案的无知。感谢您的输入,我在没有大量代码更改的情况下解决了这个问题!您是否已尝试通过tfs生成源代码(用于所有项目),然后使用自己的证书对此生成进行签名,请使用
    mage.exe
    单击一个清单?当然,这是获得您想要的资源的唯一替代方法。如果我这样做,我可以保留当前系统,它在tfs中构建源代码,并使用PS脚本进行部署。我的目标是完全自动化交付,因此它可以在没有任何开发人员干预的情况下运行,无论是使用门控签入还是基于时间的触发器。除非我遗漏了什么。对于上面的示例,您还可以使用
    mage.exe
    编写PSScript来签署清单和证书。所以这个解决方案是完全自动化的交付。我明白了。我对法师的经验有限,所以请原谅我对你的解决方案的无知。感谢您的输入,我在没有大量代码更改的情况下解决了这个问题!谢谢,我马上就做了,但是SO不允许我在24小时内做。谢谢,我马上做了,但是SO不允许我在24小时内做。