Setting Team Foundation Server For Deployment

From Logic Wiki
Revision as of 14:27, 9 May 2016 by Dt1nh6 (Talk | contribs) (1 revision imported)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


First way of deployment is in Visual Studio we can publish the site as package (which creates a zip file)

and in IIS if web deployment package is installed we can deploy this zip file by clicking deploy under web site

IMPORTANT NOTE

If it's a newly setup Windows

Control Panel -> Programs and Features -> "Turn Windows features on or off" (sidebar) In the Features dialog, go to Internet Information Services -> World Wide Web Services -> Application Development Features ->Check in everything relevant (especially ASP.NET) and click OK. Launch a command prompt in admin mode and run "iisreset"



Second Way Download and launch Web Platform Installer: http://go.microsoft.com/?linkid=9805118

Open Web Platform Installer, select "Products" at the top, and search for "Management Service". Click the "Add" button from the "IIS: Management Service" result , then click "Install". Once the Web Management Service has installed, find it in the Services console. Set its startup type to Automatic and start it.


Open Web Platform Installer, select "Products" at the top, and search for "Deployment". Click the "Add" button from the "Web Deploy 3.6" and "Web Deployment Tool" results , then click "Install". Once the Web Deployment Agent Service has installed, find it in the Services console. Set its startup type to Automatic and start it.

If you don't install them in this order you'll have authentication problems

If you install Web Deploy 3.5 BEFORE Web Management Tools are installed, you'll have to re-install it. 
I beat my head against the wall for hours on this. 
Install the Web Management Services (Roles -> Web Server > Management Tools > Management Services). 
Then uninstall Web Deploy (repair didn't work), and then install it again. Fixed.  

Also install URL rewrite module for CRM web sites http://www.iis.net/downloads/microsoft/url-rewrite

In Build Definition (in VS / Team Explorer) under MSBbuild Arguments field write these

/p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=InProc 
/p:MsDeployServiceUrl=localhost /p:DeployIisAppPath="Default Web Site/TFSTest" /p:VisualStudioVersion=11.0 /p:UserName=

Explanation of the Arguements

DeployOnBuild – True = deploy after successful build

DeployTarget – MSDeployPublish = publishing with Web Deploy (we installed it as prerequisite)

CreatePackageOnPublish – True = create a package before publishing (zip file that contains all files necessary for correct web application running). Packages can serve as deployment history (archive of what you published). You can find them in your drop folder we specified in step 6 while creating build definition.

MSDeployPublishMethod – tells what method to use for deployment, InProc = deploy localy – to an IIS running on the same machine as build service

MsDeployServiceUrl – tells which server the application should be deployed to, localhost = same machine as build service is running

DeployIisAppPath – tells where to publish in IIS (IIS Site Name/Application Name), Default Web Site/TFSTest = will be published in Default Web Site (it is IIS Site Name) and Application Name will be TFSTest

VisualStudioVersion – tells the version of Visual Studio I use, 11.0 = tells I’m using Visual Studio 2012, so the MSBuild will look for .targets files in %Program Files (x86)%\MSBuild\Microsoft\VisualStudio\v11.0, instead of ...\v10.0 (Visual Studio 2010) what is the default as I use Team Foundation Server 2010.

UserName – is the domain\user that has access to web server where we are going to publish the application. If you don’t provide user name (our case) you will use Windows authentification.

Password – is the password of the user above. In our case we used windows authentification, so we don’t have to provide this argument at all.

Deploying on a remote server

If you want to deploy your application to a remote IIS (running on other machine than build service is running), your MSBuild arguments should look like this:

/p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=RemoteAgent 
/p:MsDeployServiceUrl=ServerName /p:DeployIisAppPath="Default Web Site/TFSTest" /p:VisualStudioVersion=11.0 /p:UserName=

OR

/p:DeployOnBuild=True /p:DeployTarget=MSDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=WMSVC 
/p:MsDeployServiceUrl=https://ServerName:8172/MsDeploy.axd /p:DeployIisAppPath="Default Web Site/TFSTest" /p:VisualStudioVersion=11.0 /p:UserName=

Please note, in this scenarios you have to install Web Deploy tool on the remote server as well.


ContDelivery.png



Here is the important Parts

File:PublishSetting.png


If you get this error

The target “MSDeployPublish” does not exist in the project

Add these lines below to csproj file

<PropertyGroup>
   <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ">10.0</VisualStudioVersion>
   <VSToolsPath Condition="'$(VSToolsPath)' == ">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
 </PropertyGroup>

Alternativeley Try this

  • If .NET Framework 4 isn't installed, install it
  • Install the Web Deployment tool from http://www.iis.net/download/webdeploy
  • From the C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.0 folder on your dev machine copy the "Web" and "Web Applications" folders to the equivalent directory on your build server.
  • If you cannot copy files over there in server, go to the folder you want to paste files in and open the settings/security and go to your user and add full permissions.




http://continuousdelivery.com/