ClickOnceRe-Sign

Octopus.Script exported 2015-10-20 by mani0070 belongs to ‘ClickOnce’ category.

This Template will help to re-sign the .application and manifest files. Finally add .deploy extenstion to the files

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Signing Certificate Path

signcertpath

null

Signing Certificate Password

signCertPass

null

Deployment Path

baseDeployPath

null

Application Name

AppName

null

Script body

Steps based on this template will execute the following PowerShell script.

$xml = [xml](Get-Content "$baseDeployPath\$AppName.application")
$manifestpath = $xml.assembly.dependency.dependentAssembly.codebase
$ApplicationWithVersion = $manifestpath.Split('\\')[1]

#Manifest Resign
& "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\mage.exe" -Update "$baseDeployPath\$manifestpath" -FromDirectory "$baseDeployPath\Application Files\$ApplicationWithVersion"
& "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\mage.exe" -Sign "$baseDeployPath\$manifestpath" -CertFile $signcertpath -Password $signCertPass

#Application Resign
& "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\mage.exe" -Update "$baseDeployPath\$AppName.application" -AppManifest "$baseDeployPath\$manifestpath"
& "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\mage.exe" -Sign "$baseDeployPath\$AppName.application" -CertFile $signcertpath -Password $signCertPass

#Rename files back to the .deploy extension, skipping the files that shouldn't be renamed
Get-ChildItem -Path "$baseDeployPath\Application Files\*"  -Recurse | Where-Object {!$_.PSIsContainer -and $_.Name -notlike "*.manifest" -and $_.Name -notlike "*.vsto"} | Rename-Item -NewName {$_.Name + ".deploy"} 

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "a9e5843e-d382-44fd-84dd-d999dab54993",
  "Name": "ClickOnceRe-Sign",
  "Description": "This Template will help to re-sign the .application and manifest files. Finally add .deploy extenstion to the files",
  "Version": 6,
  "ExportedAt": "2015-10-20T20:26:27.693+00:00",
  "ActionType": "Octopus.Script",
  "Author": "mani0070",
  "Parameters": [
    {
      "Name": "signcertpath",
      "Label": "Signing Certificate Path",
      "HelpText": null,
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "signCertPass",
      "Label": "Signing Certificate Password",
      "HelpText": null,
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "baseDeployPath",
      "Label": "Deployment Path",
      "HelpText": null,
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "AppName",
      "Label": "Application Name",
      "HelpText": null,
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "$xml = [xml](Get-Content \"$baseDeployPath\\$AppName.application\")\n$manifestpath = $xml.assembly.dependency.dependentAssembly.codebase\n$ApplicationWithVersion = $manifestpath.Split('\\\\')[1]\n\n#Manifest Resign\n& \"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.0A\\bin\\NETFX 4.0 Tools\\mage.exe\" -Update \"$baseDeployPath\\$manifestpath\" -FromDirectory \"$baseDeployPath\\Application Files\\$ApplicationWithVersion\"\n& \"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.0A\\bin\\NETFX 4.0 Tools\\mage.exe\" -Sign \"$baseDeployPath\\$manifestpath\" -CertFile $signcertpath -Password $signCertPass\n\n#Application Resign\n& \"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\mage.exe\" -Update \"$baseDeployPath\\$AppName.application\" -AppManifest \"$baseDeployPath\\$manifestpath\"\n& \"C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\mage.exe\" -Sign \"$baseDeployPath\\$AppName.application\" -CertFile $signcertpath -Password $signCertPass\n\n#Rename files back to the .deploy extension, skipping the files that shouldn't be renamed\nGet-ChildItem -Path \"$baseDeployPath\\Application Files\\*\"  -Recurse | Where-Object {!$_.PSIsContainer -and $_.Name -notlike \"*.manifest\" -and $_.Name -notlike \"*.vsto\"} | Rename-Item -NewName {$_.Name + \".deploy\"} "
  },
  "Category": "ClickOnce",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/clickonce-re-sign.json",
  "Website": "/step-templates/a9e5843e-d382-44fd-84dd-d999dab54993",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAFdRJREFUeNrsnWtwW/WZxiVZlmRJtiVZlmzXdnwjiQmJM0kmCWQxQ8OaDFPCLi39sCSwHyB8KN3d9EPLLJRh6GamdHeSzix0GujObLnsdAiwEKZA0oQEQzaXkkBs4kviux3ZkmVZsi6WZMnex/onJ8qRLNtHV0vvMxrNsaxzdDm/877P+79JPDc3JyKREi0JfQUkAotEYJEILBKJwCIRWCQCi0QisEgEFonAIpEILBKBRSKwSCQCi0RgkQgsEonAIhFYJAKLRCKwSAQWicAikeKUNMc//7jbZ3V5PTPBwUl37Gc2Gopwr1crSlVy4obA4mM0NOkGQ51mxzxSbp+w41RrVcBrlVYF2nCvlEmJJJ7EWT9h1eMPfD1i67RMASbBJC3KGQi701iMe4Isy8FCQLo4bGvttwwtluMSq82VOty2VOpynLAsBKvNNNnaN35uyJretwG8musMuCewslDIgEiFg8xXhbZT/Ab0Kjnw2rWmPNcCmDinFgWBx7o4YuswO3Cf4pe+t87w6Pqq3Kkoxbm52sz0zMzXw5Mw9SBMKTNrlN1W1wZ/QEN4EViJkS/gaTd/8efOiWuWupS9KNjK+uS4IsHqd/aavWN9uJ8ew80dcP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ZBEqXAlanjgOg1NJrAST9WpY2cE737/gzuILUqFUaQqVAmev4UdsTvxQRErWjor0fzgRy0up5C5GOpClZrAIrCID0qFJAKLRKJUmGxNOM0S8Yq5Dv0BH4G1Qk7VjJe+BEqFJAKLRGCRSAQWicAiEVgkEoFFIrBIBBaJRGCRCCwSgUUiEVgkAouULVphi9uGKxCcSfvawCta0rx83AgsEqVCEoFFXwGJwCIRWCQCi0QisEgEFonAIpEILBKBRSKwSCQCi0RgkQgsEonAIhFYJAKLRCKwSAQWicAikQgsEoFFyiX9vwADAIlBLCac7vqAAAAAAElFTkSuQmCC",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Tuesday, October 20, 2015