First, you should use WebDeployment projects, as this will do a lot more compiling and validating your code and markup. See here for more details.
I have 4 installation environments DV [Development], PY [Prototype], PP [Pre-Production], PD [Production] all the corresponding branches in TFS. Each of them also has an entry in the sln configuration manager, where you can configure which projects are needed for the assembly and the assembly flags.
After properly configured, you can begin to configure deployment scripts. I prefer to use MSbuild for deployment, as this will give you a much more subtle approach to deployment. MSbuild is a little strange to start with, that as soon as you receive it, it is powerful enough.
My deployment script, which is added to the TeamBuild configuration, is shown below. Basically, as you can see, I do a bit of cleanup after the build before copying to the servers. I also use 2 MSbuild frameworks (imported at the top).
<Import Project="$(MSBuildExtensionsPath)\Microsoft\SDC Tasks - Release 2.1.3155.0\Microsoft.Sdc.Common.tasks"/> <Import Project="$(MSBuildExtensionsPath)\FreeToDev\MSBuild Tasks Suite 3.5\FreeToDev.MSBuild.tasks"/> <PropertyGroup> <InetpubFolder>\\PathToInetPub</InetpubFolder> <AppFolder>AppFolder</AppFolder> <AppFolderPath>$(InetpubFolder)$(AppFolder)</AppFolderPath> <WebDeployName>WebDeployProjectName</WebDeployName> <Debug>0</Debug> <AppConfiguration>DV</AppConfiguration> </PropertyGroup> <Target Name="AfterDropBuild"> <Message Text="Begin Release to $(AppConfiguration) Webserver" /> <Message Text="DropLocation = $(DropLocation)" /> <CallTarget Targets="PostBuildCleanUp" /> <CallTarget Targets="DeployApp" /> </Target> <Target Name="DeployApp"> <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)"> <Output TaskParameter="DropLocation" PropertyName="DropLocation"></Output> </GetBuildProperties> <PropertyGroup> <CodeDropLocation>$(DropLocation)\$(AppConfiguration) Release</CodeDropLocation> </PropertyGroup> <ItemGroup> <AppFilesToDelete Include="$(AppFolderPath)\**\*.*" Exclude="$(AppFolderPath)\Library\*.*;$(AppFolderPath)\App_Offline.htm;$(AppFolderPath)\jobs\**\*.*" /> </ItemGroup> <ItemGroup> <FilesToDeploy Include="$(CodeDropLocation)\$(AppFolder)\**\*.*" Exclude="" /> </ItemGroup> <Copy SourceFiles="$(CodeDropLocation)\$(AppFolder)\App_Offline[RemoveToActivate].htm" DestinationFiles="$(AppFolderPath)\App_Offline.htm" OverwriteReadOnlyFiles="true"/> <Message Text="Deleting files in $(AppFolderPath)" /> <Microsoft.Sdc.Tasks.File.DeleteFiles Files="@(AppFilesToDelete)" Force="true" Condition="$(Debug)==0" /> <Message Text="Copy $(CodeDropLocation)\$(AppFolder) to $(AppFolderPath)" /> <Copy Condition="$(Debug)==0" SourceFiles="@(FilesToDeploy)" DestinationFiles="@(FilesToDeploy->'$(AppFolderPath)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true"/> <Message Text="Deploy to $(AppConfiguration) Completed" /> <Microsoft.Sdc.Tasks.File.DeleteFiles Files="$(AppFolderPath)\App_Offline.htm" Force="true" /> <OnError ExecuteTargets="ErrorHandler" /> </Target> <Target Name="ErrorHandler"> <Message Text="Error encountered!!" /> </Target> <Target Name="PostBuildCleanUp"> <GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)"> <Output TaskParameter="DropLocation" PropertyName="DropLocation"></Output> </GetBuildProperties> <PropertyGroup> <CodeDropLocation>$(DropLocation)\$(AppConfiguration) Release</CodeDropLocation> </PropertyGroup> <ItemGroup> <PostBuildCleanUpFilesToDelete Include="$(CodeDropLocation)\*.*;$(CodeDropLocation)\bin\*.xml;$(CodeDropLocation)\bin\*.pdb"/> </ItemGroup> <RemoveDir Directories="$(CodeDropLocation)\_PublishedWebsites\Web" /> <Microsoft.Sdc.Tasks.File.DeleteFiles Files="@(PostBuildCleanUpFilesToDelete)" Force="true"> <Output TaskParameter="DeletedFiles" ItemName="FilesThatWereDeleted" /> </Microsoft.Sdc.Tasks.File.DeleteFiles> <Message Text="The files that were removed were @(FilesThatWereDeleted)" /> <FTDFolder TaskAction="Move" Path="$(CodeDropLocation)\_PublishedWebsites\$(WebDeployName)" TargetPath="$(CodeDropLocation)\$(AppFolder)"/> <RemoveDir Directories="$(CodeDropLocation)\_PublishedWebsites" /> <RemoveDir Directories="$(CodeDropLocation)\$(AppFolder)\WebDeploy" /> <OnError ExecuteTargets="ErrorHandler" /> </Target>
Obviously, you will need to change the system settings. It also cleans the target folder before it starts to copy the new assembly. This is to ensure that they are clean, but obviously you will need to add everything you need to the ExcludedFiles list.
I also have a folder for each environment in the main application project. This contains replacements for web.config (another feature of WebDeployment projects) and any other special environement files.
It will be a long process to get it working correctly, but hopefully it helps you get started! (Obviously, if you choose this apporach!)