powershell WPF ClickOnce应用程序的Octopus部署脚本示例。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell WPF ClickOnce应用程序的Octopus部署脚本示例。相关的知识,希望对你有一定的参考价值。

Write-Host 'Copy the package payload over to the clickonce web application location'

$source = ".\"
$dest = "C:\Octopus\Applications\${OctopusEnvironmentName}\NextGen.ClickOnce\${OctopusPackageVersion}\Package"
$exclude = @('*.pdb','mage.exe', '*.ps1', '*Build*', '*.pfx')

$appManifestName = "${OctopusPackageName}.exe.manifest"
$appManifestPath = Join-Path $dest $appManifestName
$deployManifestPath = Join-Path $dest "${OctopusPackageName}.application"

Write-Host 'Create package folder and copy everything'

New-Item -ItemType directory -Path $dest
Get-ChildItem $source -Recurse -Exclude $exclude | Copy-Item -Destination $dest

Write-Host 'Create app manifest'

& ".\Build\Mage.exe" -New Application -Name "${OctopusPackageName} ${OctopusEnvironmentName}" -ToFile $appManifestPath -FromDirectory $dest -Version $OctopusPackageVersion | Write-Host
#& ".\Build\Mage.exe" -Sign $appManifestPath -CertFile .\ClickOnce.pfx -Password password

Write-Host 'Create deploy manifest'

& ".\Build\Mage.exe" -New Deployment -AppManifest $appManifestPath -Install true -Publisher "Andrew Best" -ProviderUrl "http://ci/AppName.${OctopusEnvironmentName}/Package/${OctopusPackageName}.application" -Version $OctopusPackageVersion -Name "${OctopusPackageName} ${OctopusEnvironmentName}" -ToFile $deployManifestPath | Write-Host

Write-Host 'Add deploy extension to files'

$ex = @('*.application', '*.manifest')
$packageFiles = Get-ChildItem $dest -Recurse -Exclude $ex

foreach ($file in $packageFiles) {
    $newname = $file.name + ".deploy"
    Rename-Item -Path $file -NewName $newname
}

Write-Host 'Add mapFileExtensions to deploy manifest so that it works with the *.deploy extension'

$xml = [xml](Get-Content "$deployManifestPath")
$deployment_node = $xml.SelectSingleNode("//*[local-name() = 'deployment']")
$deployment_node.SetAttribute("mapFileExtensions", "true")
$xml.Save("$deployManifestPath")

#Write-Host 'Sign deploy manifest'
#& ".\Build\Mage.exe" -Sign $deployManifestPath -CertFile .\ClickOnceSpike_TemporaryKey.pfx -Password centium

#Run Database with the configured connection string to migrate our testDb

#$connectionString = $OctopusParameters["DbContext"]
#$zeroDb = $OctopusParameters["ZeroDb"]
#& "bin\Database.exe" $connectionString $zeroDb | Write-Host

以上是关于powershell WPF ClickOnce应用程序的Octopus部署脚本示例。的主要内容,如果未能解决你的问题,请参考以下文章

如何在卸载时取消注册 wpf clickonce 应用程序?

使用 CEFSharp Web 浏览器的 WPF 应用程序在 clickonce 版本中崩溃

ClickOnce管理员启动并且支持ClickOnce更新

WPF ClickOnce应用程序IIS部署发布攻略

ClickOnce 和 .NET 5:用户设置未更新

TFS 持续集成 clickonce 应用程序