# IT:AD:WebDeploy:HowTo:Create a Package From The CLI # * [[../|(UP)]] {{indexmenu>.#2|nsort tsort}} * See: * [[IT/AD/WebDeploy/HowTo/Create a Publish Profile Parameters.xml/Transformation Examples]] Using Visual Studio's button to create a package is fine for simple developer scenarios. But not how one would do it from within a [[IT/AD/Continuous Integration/]] scenario. ## Process ## Use [[IT/AD/MSBuild/]] to invoke [[IT/AD/MSBuild/]] `target`s within: * %ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets * and this file in turn imports * %ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets msbuild {solution file} /p:CreatePackageOnPublish=[true|false] /p:DeployOnBuild=true /p:DeployTarget=[MsDeployPublish|Package] # define the publish scenario to use /p:PublishProfile='Test.pubxml' #leave files on server after deployment /p:SkipExtraFilesOnServer=[true|false] /p:DeployIisAppPath=/ /p:MsDeployServiceUrl=Location of MSDeploy installation you want to use # do not use the older RemoteAgent - stick with WMSVC # http://stackoverflow.com/questions/2636153/how-can-i-get-tfs2010-to-run-msdeploy-for-me-through-msbuild /p:MsDeployPublishMethod=[WMSVC|File|InProc] # used with self-signed SSL certificates: /p:AllowUntrustedCertificate=[true|false] /p:UserName /p:Password /p:DeployIisAppPath=staging.example.com /p:MsDeployServiceUrl=https://staging.example.com:8172/msdeploy.axd /p:IncludeIisSettingsOnPublish=[false|false] * Notes: * CreatePackageOnPublish: * [MSDN Ref](http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.workflow.activities.msbuild.createpackageonpublish.aspx) -- no documentation! * DeployOnBuild: * [MSDN Ref](http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.workflow.activities.msbuild.deployonbuild.aspx) -- no documentation! * if false, no Package is created * DeployIisAppPath: * [MSDN Ref](http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.workflow.activities.msbuild.deployiisapppath.aspx) ### Creating just a Package In other words -- to create a package, without deploying: msbuild {solution file} /p:CreatePackageOnPublish=true /p:DeployOnBuild=true # define the publish scenario to use /p:PublishProfile='Test.pubxml' /p:DeployTarget=MsDeployPublish >Note: >This only works if you have actually added to the Test.pubxml Publish Profile a WebDeploy Package (and not a WebDeploy) ### Creating and Deploying a Package msbuild {solution file} /p:CreatePackageOnPublish=true /p:DeployOnBuild=true /p:DeployTarget=Package # define the publish scenario to use /p:PublishProfile='Test.pubxml' >Note: >This only works if you have actually added to the Test.pubxml Publish Profile a WebDeploy Package (and not a WebDeploy) ### Creating and Deploying a Package to a new Site msbuild {solution file} /p:CreatePackageOnPublish=true /p:DeployOnBuild=true /p:DeployTarget=Package # define the publish scenario to use /p:PublishProfile='Test.pubxml' /p:PublishIISAppPath="Default Web Site/Test 6" will create a new Virtual directory (test 6) under the web site. >Note: >This only works if you have actually added to the Test.pubxml Publish Profile a WebDeploy Package (and not a WebDeploy) ## Creating it from a Project (not a Solution) If you want to build a project's package: msbuild {project file} /t:Package Ref: http://www.iis.net/learn/publish/using-web-deploy/building-a-web-deploy-package-from-visual-studio-2010 ## Resources ## * http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.workflow.activities.msbuild.aspx * http://stackoverflow.com/questions/5598668/valid-parameters-for-msdeploy-via-msbuild/5598737#5598737 * http://codersnotes.blogspot.co.nz/2012/08/valid-parameters-for-msdepoly-via.html