Multiple ClickOnce installations with different Deployment Identity, but same Application Identity

后端 未结 5 1283
萌比男神i
萌比男神i 2021-02-01 17:14

We have several deployments of the same assemblies with different configuration files for different environments. We package these up in to separate ClickOnce deployments with d

5条回答
  •  無奈伤痛
    2021-02-01 17:50

    I ended up using -u -Update option to create a new Deployment for QA based on Production.

    Here are the steps I did to test a verify

    1. create a simple WPF application
    2. copied mage.exe to the project since Visual Studio can't resolve it at build time
    3. Added the below text to the project's post build

    cd "$(TargetDir)"

    "$(ProjectDir)mage.exe" -New Application -Name $(ProjectName) -p msil -TrustLevel FullTrust -Version 1.0.0.0 -FromDirectory . -ToFile ".\$(TargetFileName).manifest"

    "$(ProjectDir)mage.exe" -New Deployment -Install false -Name $(ProjectName) -p msil -Version 1.0.0.0 -AppManifest ".\$(TargetFileName).manifest" -ToFile ".\$(TargetName).application"

    "$(ProjectDir)mage.exe" -Update ".\$(TargetName).application" -Install false -Name $(ProjectName).QA -p msil -Version 1.0.0.0 -AppManifest ".\$(TargetFileName).manifest" -ToFile ".\$(TargetName).QA.application"

    I needed to change to the "$(TargetDir)" via cd "$(TargetDir)" because mage wouln't process directories and filepaths correctly when I gave it paths with spaces that are enclosed in double quotes. To get around that, I set the current directory to the location of where the files are built to.

    The 2nd line creates the manifest file

    The 3rd line creates the Production deployment file.

    The 4th line creates the QA deployment file from the Production deployment file. (NOTE: I'm adding QA to the deployment file and the Application Name.)

    The 4th line causes a 2nd application file to get created. When both applications are ran, they will have the same binaries but the ApplicationDeployment.UpdateLocation will be different for each. One will have the filename $(TargetName).application and the other will have the filename $(TargetName).QA.application. In my code I can use this to determine which 'Version' of the Application was ran (QA or Production)

提交回复
热议问题