开发者

Set application pool with MSDeploy and TFS 2010

开发者 https://www.devze.com 2023-01-30 17:56 出处:网络
I\'m trying to deploy website with MSDeploy and开发者_JS百科 team build using some of this ... /p:DeployOnBuild

I'm trying to deploy website with MSDeploy and开发者_JS百科 team build using some of this ...

/p:DeployOnBuild
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=InProc
/p:MSDeployServiceURL=localhost
/p:DeployIISAppPath="Default Web Site"

Is there a way to set this website in custom application pool?


If you're using IIS 7, you can use the appPoolProvider to sync application pools to a remote server. See:

http://technet.microsoft.com/en-us/library/dd569070(WS.10).aspx

and

http://blog.torresdal.net/2010/08/16/NoClickWebDeploymentPart2WebDeployAkaMsdeploy.aspx

However, I wasn't able to really get that to work well, and if you're using IIS 6 this won't work anyway. What you can do though is leverage MSDeploy to run a couple commands on the remote server to set the application pool (and register the .NET version on the website).

First, create a batch file that contains something similar to the following:

cscript //nologo C:\Inetpub\AdminScripts\adsutil.vbs 
  SET w3svc/<IIS number>/Root/<virtual directory>/AppPoolid "<app pool name>"

So, if the IIS number is 1, your virtual directory is "MyDirectory" and the App Pool is named ".NET4.0", the command would be.

cscript //nologo C:\Inetpub\AdminScripts\adsutil.vbs 
  SET w3svc/1/Root/MyDirectory/AppPoolid ".NET4.0"

You can then run MSDeploy, passing this batch file in as an argument and running it on the remote machine:

MSDeploy 
  -verb:sync 
  -source:runCommand="<path to batch file>",waitinterval=5000 
  -dest:auto,computername=<computer name>

where <path to batch file> is the full path to the batch file you just created above, and is the computer against which you want to run this. Here is a link describing the runCommand argument: http://technet.microsoft.com/en-us/library/ee619740(WS.10).aspx

I'm sure you can set this up as a build step in TFS. We made a little .NET utility that we call as part of our deployment process that creates these batch files and runs the MSDeploy command.

There are also other things you can do in this same method that might prove useful to you:
Register an IIS version:

%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe 
  -s w3svc/1/root/MyDirectory  

Create an App Pool:

CSCRIPT //nologo %dir%\adsutil.vbs 
  CREATE w3svc/AppPools/AppPoolName IISApplicationPool  

Thanks to http://justsamson.com/2010/06/14/create-virtual-directory-in-iis-6-0-via-command-line/ for the command-line scripts to do the various functionality.


Part of the trick is with /p:IncludeAppPool=true. That changes the deploy script to enable AppPoolExtension. But I haven't figured out how best to actually set the app pool yet. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消