MSDeploy and "site under maintenance" page - asp.net

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

Related

automate app_offline.htm file in asp.net web application

I want to delete the app_offline page(app_offline.htm) from the root of the IIS application when the work completed.How to automate this deploy and delete the app offline page in iis directory.
I tried read some artciles about MSdeploy but could not get that .
Can we do it by running some commands to auto deploy and delete the app_offline page from the server root directory ?
Please help me on this. I found below two commands to run
msdeploy.exe –verb:sync
-source:contentPath="[Project folder]\App_offline.template.htm"
-dest:contentPath="[IIS application path]/App_offline.htm",
computerName="[Destination web server]"
for delete
msdeploy.exe –verb:delete
-dest:contentPath="[IIS application path]/App_offline.htm",
computerName="[Destination web server]"
But not get how to run the above commands
You can also try use cmd.exe, It is located at C:\Windows\System32\cmd.exe, more information you can refer to this link: Web Deploy (MSDeploy).

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.

How to deploy package (zip) into specific site under IIS using 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.

Precompilation for Deployment

After exploring Precompilation for Deployment topic I want to enhance my build process. Now, what I do is:
prepare web site using Web One Click Publish, for instance to c:\www\app directory, and that directory is available in IIS via app (localhost/app)
I launch aspnet_compiler.exe -v app c:\www\appprecompiled -f
Now I have ready precompiled application in c:\www\appprecompiled and everything is fine. However my application is quite big, and Publishing it (step 1) take about 5 minutes from scratch. So I wonder if it is possible to avoid step one , and perform step 2 (precompilation) with source folder pointing to solution folder. I tried something like this:
aspnet_compiler.exe -v codeapp c:\code\app -f
Where c:\code\app is the folder with web.config etc files, basically it's a project with web site and that folder is avaliable via http://localhost/codeapp.
But when launching that command, I get errors about missing global.asax or web.config errors:
C:\code\app\obj\debug\package\packagetmp\web.config(18):
error ASPCONFIG: It is an error to use
a section registered as
allowDefinition='MachineToApplication'
beyond application level. This error
can be caused by a virtual directory
not being configured as an
application in IIS.
And for the record, I use Application, not Virtual Directory.
So is there a way to perform precompilation on a plain web site folder?
I used
aspnet_compiler -p
physicalOrRelativePath -v / targetPath
from http://msdn.microsoft.com/en-us/library/ms227976(v=VS.80).aspx and removed obj folder prior to executing it, and precompilation works :)

iis 7 deploying a new build of an existing site

I would like to automate the process of deploying a new build of an existing site and allow for me to go back to the previous version of the site easily. Up until this point I have been copying my new build to the production server and placing it into a folder with a build number associated with it. Through the IIS user interface I would stop the site and then change the physical path on the site pointing it to my new build. If for some reason I would need to back the changes out I would simply go back into IIS and stop the site and point it back to the previous build.
I see where I can use appcmd to stop and start the site. I just can't find any way to change the physical path property on the site.
Thanks for you help.
you could probably use powershell Intro to Power Shell for IIS7
EDIT: This Page has examples for creating websites and applications in IIS with powershell.
Based on the samples it should be something like this:
Set-ItemProperty IIS:\sites\DemoSite\DemoApp -physicalPath C:\DemoSite\DemoApp -type Application

Resources