How to deploy package (zip) into specific site under IIS using msdeploy - msdeploy

Requirement:
I have zip package which i need to deploy into specific site (say dev.sitename.org) under IIS.
Earlier , we had site under Default Web Site (under IIS) and we used below command to deploy it.
>>msdeploy -verb:sync -source:package="D:\package.zip" -dest:auto
I have tried different provider for -dest , but nothing worked.
Does anyone has idea on this. Please share if any.

Try setting a ProviderPath parameter:
msdeploy -verb:sync -source:package="d:\package.zip" ^
-dest:auto -setParam:kind=ProviderPath,scope=iisApp,value=dev.sitename.org
Your provider might be a contentPath, rather than an iisApp, depending on how you created it. Open the manifest file in the root of the zip to double check.

Related

Bamboo Deployments using MSDeploy

I have created a CI with bamboo for a MVC Project. Build works fine but the problem is with the deployment using msdeploy. Below is the configuration of the deployment in Bamboo
Problem is with the arguments send to msdeploy which looks like this:
-source:package='${bamboo.build.working.directory}\Artifacts\WebDeploy\webdeploy.zip' -dest:auto,computerName="https://my_web_app.cloudapp.net:8172/msdeploy.axd?site=web_app_name",userName="deploy_user_name",password="passowrd",authtype="Basic",includeAcls="False" -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -allowUntrusted -enableRule:DoNotDeleteRule -setParam:name="IIS Web Application Name",value="web_app_name"
When this code is run in bamboo, i am getting the following error:
Error: Unrecognized argument '"-setParam:name="IIS'. All arguments must begin with "-".
if -setParam:name="IIS Web Application Name",value="web_app_name" is removed from the script deployent is done with success but in a wrong website (virtual directory under Default Web Site)
Any ideas on how this can be fixed without using a separate .bat file?
Thanks
I dealt with a similar issue about a month ago. From everything I've seen, MSDeploy struggles to deal with arguments that have spaces in them. As a result, "IIS Web Application Name" will give you trouble. To overcome this, I excluded this argument and was able to achieve the same goal by including /p:Configuration=DeployIISAppPath="Default Web Site/web_app_name" in the MSBuild command line used to build the deployment package.

How to tell msbuild, that it needs to publish to new directory and adjust IIS to it?

Currently we have following structure:
web
build0001
build0002
build0003
So, each time we deploy new version of web application, we create folder with build number and then change path in IIS to use that directory.
Now question is, can I do same thing with msbuild:
1) publish to web\buildxxxx
2) and update IIS setting to use web\buildxxxx for that site.
While currently I doing all this in same server, in the future I'll need to do this on remote servers also, meaning that I'll running msbuild from different server than IIS is.
So far I've came to this:
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe"^
-verb:sync^
-source:contentPath="c:\stageDir"^
-dest:contentPath="c:\web\build0004",computername="https://remoteServer:8172/MsDeploy.axd?site=MySite",UserName="DeployUser",Password="xxx",authType=Basic^
-enableRule:DoNotDeleteRule^
-allowUntrusted^
-postSync:runCommand="C:\windows\system32\inetsrv\appcmd.exe set vdir MySite/ -physicalPath:c:\web\build0004"
Problem with this approach is, that is requires a lot of permissions, because of these things:
build0004 at the moment of syncing is out of current website's folder (say build0003), so it requires DeployUser to have administrative rights.
I need ability to use runCommand, which requires even more - allow WMSVC to run commands.

Configuring MSDeploy 3.5 WS2008 R2

I try to configure msdeploy configuration between two WS2008 R2 servers.
I don't have any domain controller
I Installed MSDeploy 3.5 using Web PI on both servers.
I created a user on both servers, and added them to the "Administrators" group
I use this user for syncrhonization :
SET USERNAME=WebDeploy
SET PASSWORD=blah
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy" -verb:sync -source:webServer -dest:auto,computername=x.x.x;X,username=%USERNAME%,password=%PASSWORD% -skip:objectName=contentPath,absolutePath="\\temp"
I get ERROR_USER_NOT_ADMIN error.
I went to http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_NOT_ADMIN
I created the group, added my user to it, stil the samme error.
I saw that MSDeploy created users WDeployAdmin and WDeployConfigWriter, I also tried with those.
I launch my synchronization script with elevated privileges.
Any clue ?
Thanks !
I solved it by adding the following registry key : https://serverfault.com/questions/38999/cant-connect-to-default-admin-share-on-windows-2008
It solved my administrative share problem as well as my WSDeploy problem.

How do I copy a file from a deployed web site to a local directory using MS Web Deploy (msdeploy.exe)?

I already came up with a command that deploys the site to the target server and it works great. In case it is important in this context, here it is:
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-source:package='HelloWorld.Mvc3UI\obj\Debug\Package\HelloWorld.Mvc3UI.zip'
-dest:auto,ComputerName='https://10.225.0.30:8172/MsDeploy.axd?site=HelloWorld',username='<MyUserName>',password='<MyPassword>',authType='basic',includeAcls='false'
-allowUntrusted
-verb:sync
-disableLink:AppPoolExtension
-disableLink:ContentExtension
-disableLink:CertificateExtension
-setParamFile:"HelloWorld.Mvc3UI\obj\Debug\Package\HelloWorld.Mvc3UI.SetParameters.xml"
-setParam:name='IIS Web Application Name',value='HelloWorld'
-setParam:name='HelloWorld-Web.config Connection String',value='SERVER=10.225.0.25;DATABASE=HelloWorld;UID=sa;PWD=<MyPassword>;'
Now that the site is on the server, I want to be able to retrieve the \bin\HelloWorld.Database.dll file and copy it to a local directory using msdeploy.exe.
I am guessing that I have to use the package provider on the remote server (since it is what was used to deploy the site) and use the dirPath or filePath provider on the local machine. However, I am having trouble working out the exact syntax to make it work.
Background
I need the HelloWorld.Database.dll file that is already in production so it can be used to downgrade the database in an application rollback scenario. This file uses the Fluent Migrator Framework to migrate the database changes.
I discovered a solution.
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe"
-source:filePath='C:\inetpub\sites\HelloWorld\bin\HelloWorld.Database.dll',ComputerName='https://10.225.0.30:8172/MsDeploy.axd?site=HelloWorld',username='<MyUserName>',password='<MyPassword>',authType='basic',includeAcls='false'
-dest:filePath='F:\HelloWorldProject\HelloWorld.Database.dll'
-allowUntrusted
-verb:sync
However I would much prefer if there were a way to do this without having to specify the entire remote path because it might vary from one environment to the next. I tried and apparently it isn't supported.

MSDeploy and "site under maintenance" page

I am new to MSDeploy as well as IIS admin.
In order to show a "site under maintenance" page we are looking at two alternatives.
1) Have an app_Offline.htm page and sync it to the server when maintenance starts.
2) Create a separate folder with a totally different site (which can show a lot more dynamic information than what we can with the app_offline page). During maintenance, it is being suggested that we change the virtual folder mapping of the site to point to this other folder while we work on updating the site.
Is there a way to change the virtual folder to point to another folder using MSDeploy? Is there any other way to do this via a script rather than having to go to each server and manually change the folder ?
Set app_offline using MSDeploy
What we've done in the past is to script our deployments using Msdeploy.exe. We execute 3 commands.
The first command deploys the app_offline.htm page.
msdeploy -verb:sync -source:filePath=c:\location\app_Offline.htm -dest:filePath=c:\site\app_Offline.htm
Second we actually deploy the site using that same "sync" verb but using a package.
Third we'll remove the app_offline.htm using MSdeploy.
msdeploy -verb:delete -dest:filePath=c:\site\app_Offline.htm
You can execute msdeploy across multiple servers using the "computername" destination switch. Like:
msdeploy -verb:sync -source:filePath=c:\location\app_Offline.htm,computername=sourcemachine -dest:filePath=c:\site\app_Offline.htm,computername=destmachine
You can find more information about all the different parameters for using msdeploy via command line here: http://technet.microsoft.com/en-us/library/dd568991%28WS.10%29.aspx
Creating a virtual directory using MSDeploy
If you still want to create the virtual directory what I'd suggest is creating a powershell script on each destination sever that would do this for each server. Your powershell script would have something like this in it:
New-Item 'IIS:\Sites\Default Web Site\VirtualDirName' -type VirtualDirectory -physicalPath c:\test\virtualDirectory1
You can find more info about using powershell for this here:
http://learn.iis.net/page.aspx/433/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools/
Then execute using msdeploy utalizing the "runcommand" provider. You would execute this line per server.
msdeploy -verb:sync -source:runCommand="net start createvirtualdir.ps" -dest:computername=destmachine

Resources