How to make Web Deploy (msdeploy) deploy in a different folder?

泪湿孤枕 提交于 2019-12-25 01:49:40

问题


I'm trying to make a simple proof-of-concept Web Deployment scenario. My goal is to:

  1. Take a folder with a few files and package them in a .zip file
  2. Unpackage the .zip file in a different folder
  3. Run a .exe from the unpacked folder (also letting the .exe know where it was unpacked).

I'm doing this on a virtual machine without an IIS installed, otherwise it wants to read IIS config for some reason, even if it doesn't need to do anything with it (and fails because it lacks administrative rights).

I have the following files:

C:\Temp\TheFolder\readme.txt
C:\Temp\TheFolder\MagicScript\CSTest.exe

The .zip package is created via a manifest:

<sitemanifest>
  <contentPath path="C:\Temp\TheFolder"/>
  <runCommand path="C:\Temp\TheFolder\MagicScript\CSTest.exe"/>
</sitemanifest>

For packaging I use the following command:

msdeploy -verb:sync -source:manifest=manifest.xml -dest:package=ready.zip

For unpackaging I use the following command:

msdeploy -verb:sync -source:package=ready.zip -dest:auto -replace:match=TheFolder,replace=OtherFolder

However MSDeploy stubbornly unpackages everything in the same TheFolder. The .exe file is also run not from the unpackaged folder. Rather it's copied to a temp folder and then run from there, with the current directory set to wherever I ran the deployment script from.

I also tried using a parameter instead of replace, but that still didn't have any effect.

What am I doing wrong?


回答1:


"msdeploy -verb:sync" - performs syncronization between source and destination. If you use "auto" provider - it synchronizes source with destination, so in your case at the same PC it is the same folder. "replace" parameter works only for files.

You can try the following way:

msdeploy -verb:sync -source:package=ready.zip -dest:contentPath="C:\Temp\OtherFolder"

Or, if it won't work, try to use destination manifest:

msdeploy -verb:sync -source:package=ready.zip -dest:-source:manifest=manifestDestination.xml

Where manifestDestination.xml is:

<sitemanifest>
  <contentPath path="C:\Temp\OtherFolder"/>
  <runCommand />
</sitemanifest>


来源:https://stackoverflow.com/questions/23330841/how-to-make-web-deploy-msdeploy-deploy-in-a-different-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!