Team Build: Publish locally using MSDeploy
Asked Answered
S

3

32

I'm just getting started with the team build functionality and I'm finding the sheer amount of things required to do something pretty simple a bit overwhelming. My setup at the moment is a solution with a web app, an assembly app and a test app. The web app has a PublishProfile set up which publishes via the filesystem.

I have a TFS build definition set up which currently builds the entire solution nightly and drops it onto a network share as a backup of old builds. All I want to do now is have the PublishProfile I've already setup publish the web app for me. I'm sure this is really simple but I've been playing with MSBuild commands for a full day now with no luck. Help!

Shortcake answered 28/10, 2010 at 10:14 Comment(0)
M
61

Unfortunately sharing of the Publish Profile is not supported or implemented in MSBuild. The logic to publish from the profile is contained in VS itself. Fortunately the profile doesn't contain much information so there are ways to achieve what you are looking for. Our targets do not specifically support the exact same steps as followed by the publish dialog, but to achieve the same result from team build you have two choices, I will outline both here.

When you setup your Team Build definition in order to deploy you need to pass in some values for the MSBuild Arguments for the build process. See image below where I have highlighted this. alt text

Option 1: Pass in the following arguments:

/p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="\\sayedha-w500\BuildDrops\Publish";AutoParameterizationWebConfigConnectionStrings=false

Let me explain these parameters a bit, show you the result then explain the next option. DeployOnBuild=true:This tells the project to execute the target(s) defined in the DeployTarget property.

DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder: This specifies the DeployTarget target.

PackageTempRootDir="\\sayedha-w500\BuildDrops\Publish": This specifies the location where the package files will be written. This is the location where the files are written before they are packaged.

AutoParameterizationWebConfigConnectionStrings=false: This tells the Web Publishing Pipeline (WPP) to not parameterize the connection strings in the web.config file. If you do not specify this then your connection string values will be replaced with placeholders like $(ReplacableToken_dummyConStr-Web.config Connection String_0)

After you do this you can kick off a build then inside of the PackageTempRootDir location you will find a PackageTmp folder and this contains the content that you are looking for.

Option 2: So for the previous option you probably noticed that it creates a folder named PackageTmp and if you do not want that then you can use the following options instead.

/p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;_PackageTempDir="\\sayedha-w500\BuildDrops\Publish";AutoParameterizationWebConfigConnectionStrings=false

The difference here is that instead of PackageTempRootDir you would pass in _PackageTempDir. The reason why I don't suggest that to begin with is because MSBuild properties that start with _ signify that the property in essentially "internal" in the sense that in a future version it may mean something else or not exist at all. So use at your own risk.

Option 3

With all that said, you could just use the build to package your web. If you want to do this then use the following arguments.

/p:DeployOnBuild=true;DeployTarget=Package

When you do this in the drop folder for your build you will find the _PublishedWebsites folder as you normally would, then inside of that there will be a folder {ProjectName}_Package where {ProjectName} is the name of the project. This folder will contain the package, the .cmd file, the parameters file and a couple others. You can use these files to deploy your web.

I hope that wasn't information over load.

Mountbatten answered 28/10, 2010 at 17:13 Comment(7)
Superb! Had a play around with these and theres a few things to think about. Getting a better understanding of whats going on anyway. Either going to use this or get msdeploy installed on the IIS6 box and go that way.Shortcake
Thank you, i have been looking for this answer and i finally found you post!Climactic
The only thing missing from this is that it does not create the PrecompliedApp.config file. Are those necessary if the publish profile specifies PrecompliedApp assemblies? I don't get why TeamBuild doesn't do everything the publish profile does, such as XmlTransformations.Crosswalk
We've been using Option 2 for sometime now with success. However we just started to use SwashBuckle to generate Swagger documentation for a WebApi project and this method of publishing was not copying the .xml documentation files into the bin dir of the packaged webapp (which Swashbuckle needs). After a little digging, found that passing /p:ExcludeXmlAssemblyFiles=false was needed on the command line..Carnahan
As I was reading this answer, I thought, 'This guy should write a book.' And you have! You should come out with an updated version. I'd buy it.Nosology
@sayed Can you show the other option where we could just publish the .csproj (the same behavior as the publishing on file system using VS solution explorer). I tried: (1) <MSBuild Projects="proj.csproj" Targets="Publish" Properties="Configuration=release;OutDir=app.publish" /> (2) <MSBuild Projects="proj.csproj" Properties="Configuration=release;DeployOnBuild=true;OutDir=app.publish" /> (3)<MSBuild Projects="proj.csproj" Targets="ResolveReferences;_CopyWebApplication" Properties="Configuration=release;WebProjectOutputDir=app.publish;OutDir=app.publish\bin\" />Emanuelemanuela
@Sayed, this worked great for me. can you please let me know how to exclude .config files the argumentsFlynn
J
1

The ability to publish web sites, configure IIS and push schema changes for the DEV->QA->RELEASE cycle has required either custom configuration to imitate publish or custom code where IIS settings are involved.

As of Visual Studio 2013.2 Microsoft has added a third party product that manages deployment of web sites, configuration changes and database deployment with windows workflow and would be the recommended solution for automating deployment from TFS build.

More information can be found here:

http://www.visualstudio.com/en-us/explore/release-management-vs.aspx

Judicator answered 25/7, 2014 at 4:34 Comment(0)
M
-2

You can use the Publish/Deploy in Visual Studio 2010.

See http://www.ewaldhofman.nl/post/2010/04/12/Auto-deployment-of-my-web-application-with-Team-Build-2010-to-add-Interactive-Testing.aspx for more information

Marianamariand answered 28/10, 2010 at 11:15 Comment(1)
This won't publish via the filesystem though, its assuming a Web.Deploy.cmd has been created, which hasn't happened in my case. I already have an option when I rightclick on the web app and select Publish for Publish Method: File System, I just want to plug into that.Shortcake

© 2022 - 2024 — McMap. All rights reserved.