Deploy website to drop folder on TFS build server - deployment

I am using TFS 2012 on a build server to do continuous integration, and also builds for other environments. I am deploying a .net 4.0 webforms solution containing two websites and a console app to a build server and in the drop folder I get a _PublishedWebsites folder containing the deployment package for the custom configuration I have specified (ie not Debug or Release). I get the correct .Web_Package for each website.
I am using the MSBuildArgumments setting in the build process as follows:
/p:DeployOnBuild=true /p:PublishProfile=Development/p:VisualStudioVersion=10.0
Everything works well, but the team lead wants the actual deployment in the drop-folder and not the deployment package.
I have looked at the MS Documentation but it does not appear to help in my case.
I have tried creating a script, but I dont want to go into a huge series of powershell scripts, and I struggle with powershell anyway. I just cant get it to do what I want.
My question is: can this be done, and what is the best way of doing it? If it does mean creating a script then so be it ( perhaps one line for each object) - I am really having a hard time working out which direction I should be going in.
I thought something a script containing one line for each deployment -3 lines like this:
_PublishedWebsites/<project name>.Web_Package/<project name>.deploy.cmd /T: /M:<site> /U:<user> /P:<password>
But where to put the script and how to call?

I ended up using the solution as described in this blog post:
http://blog.degree.no/2012/03/automatic-config-transformations/
To get what I needed, I needed to change the project files of the projects to be deployed - adding this extra node at the top of each.csproj file
<Target Name="TransformConfigFiles" AfterTargets="AfterBuild" Condition="'$(TransformConfigFiles)'=='true'">
<ItemGroup>
<DeleteAfterBuild Include="$(WebProjectOutputDir)\Web.*.config" />
</ItemGroup>
<TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)\Web.config" />
<Delete Files="#(DeleteAfterBuild)" />
</Target>
and adding this switch to the MSBuildArguments in the build definition:
/p:TransformConfigFiles=true

When I run my builds using the DeployOnBuild switch, my builds output two folders, one with the Package, and one with just all the website files (both under PublishedWebsites). Is that not what you want?
I have:
BuildDrop_PublishedWebsites\Website
BuildDrop_PublishedWebsites\Website_Package

Related

TFS - Run Powershell script against package before Deployment

I currently have a CI Setup in TFS 2013 which does the following
Pulls code down from Git on every commit to a branch
Builds the Solution
Runs N-Unit Tests Against the solution
Runs Jasmine Front-end Tests against the javascript
Deploys on success via WebDeploy to chosen server.
I have now managed to install Grunt and NodeJS on the server to do some manipulation of the Javascript between steps 5-6. Does anyone have any advice on how this might be done?
I've tried post-tests scripts to minify the javascript successfully on both the src and bin/_PublishedWebsites directory but this does not seem to persist over to the deployment server. And infact, the _PublishedWebsites route puts the build folder in an undeletable state due to maxmimum character limits on Windows files (argh).
You should switch over to using Release Management for Visual Studio 2013 (works with 2012 as well). This allows you to parameterize your release and push the same output through multiple environments. Very configurable and even makes sure that the tools you need end up on the server that you are deploying to. Supports Puppet, Chef, DSC, and create your own.
http://nakedalm.com/installing-release-management-server-tfs-2013/
And for an overview: http://nakedalm.com/building-release-pipeline-release-management-visual-studio-2013/
I managed to get this working with the addition of two extra steps to the pubxml file used for the deployment.
First, i added a dependency powershell script which ran NPM install and grunt tasks.
<PipelineDependsOn>
CustomBeforePublish;
$(PipelineDependsOn);
</PipelineDependsOn>
<Target Name="CustomBeforePublish">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -file Pre_Deploy_Javascript_Build.ps1 $(ProjectDir)"/>
</Target>
Following this. I had now created additional files which did not exist in the project. I had to now ensure that these were published. To do this, i added another step.
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CopyMinJSFiles;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn >
<Target Name="CopyMinJSFiles">
<ItemGroup>
<_MinJSFiles Include="$(ProjectDir)\App\*.js" />
<FilesForPackagingFromProject Include="%(_MinJSFiles.Identity)">
<DestinationRelativePath>App\%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>

Automatic installer deploy to remote server using TeamCity and MSBuild

I'm having a .net WPF project that compiles to a bunch of dlls. I also have another project that compiles all the dlls and creates an installator exe.
I am also using TeamCity to automatically do those tasks for me with a press of a button.
The problem is that I want to have a separate TeamCity build configuration intended to automatically copy the result installator exe to a number of remote machines, each having specific credentials. But, unfortunately, I don't get how do I do this.
I have found some articles on automatic deploying (like this http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html), but, obviously, they are very specific for web projects.
So, how should I correctly deploy my installator on build?
Your best bet is to research NAnt and make a simple task that will copy the TeamCity artifact (installer) out to the specified location.
All you would need to do is have TeamCity execute the specified NAnt task after the installer has been built.
http://nant.sourceforge.net/release/0.85/help/tasks/copy.html
Update
Also, check out this question for solutions on specifying the credentials for the copy task.
OK, I've found out that it's pretty easy to do this using the FtpUpload MSBuild community task. There, one can set up the credentials and all other stuff needed for uploading a file (or a set of files) via ftp.

Cannot deploy web.testing.config to the build server

I am learning TFS 2010 from scratch and no doubt making every mistake in the book.
I have created a web.testing.config for my build to the test server.
In my build process I click the plus sign for "Items to Build" in "1. Required" and I specify "Any CPU | Testing".
The build clean compiles but ... I still seem to be using the web.config file I use in development rather than the one I want in testing.
The first line in web.testing.config is
This should ensure that any differences in this file are implemented.
So I am not sure I am configuring the build properly, or if the web.testing.config is set properly.
What you are looking for is a feature called web.config transforms, and it works slightly differently.
In Visual Studio right click on web.config and choose option Create Tranforms -- if you have not done this already.
Read samples on using tranform syntax, the link is in the web..config created for you. You will need it.
In TFS team build, create a separate step in your build template to build deployment package. The command is in this thread. This will create a deployment package -- a file with .zip extension.
To deploy the package, use WebDeploy tool. It has both UI and command line if you want to make it completely automated.

Is there a system that I can use to update my projects on my VPS?

Hey guys, So I recently got a VPS, just so I can start gaining experience. But I'm looking for a service/program where I can code on my PC, then when I'm done, I run a script or do a command or something to have it updated to my VPS.
I thought I was looking for Git, but apparently git does not do what I'm looking for.
Any suggestions?
Windows or Linux?
On Windows, there's a host of tools.
First of all you code. Visual Studio is the most common. You get a sln-file and a batch of *.*proj-files.
When talking about deploying to remote servers, often a continuous integration server is used. We are using TeamCity (http://www.jetbrains.com/teamcity/). Download it locally, install and create a new project, selecting the "SLN-runner". Point it to the sln file of yours.
When you want the deployment part working, create a small build file such as "MyProj.build", that contains something along the lines of
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="BuildProject"
InitialTargets="CheckRequiredProperties"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
ToolsVersion="4.0">
<Target Name="BuildProject">
<Message Text="Starting $(Configuration) build. Web site publish location $(OutputWebSite)" />
<MSBuild Projects="$(SolutionPath)"
Targets="Build"
Properties="BuildOutputPath=$(BuildOutputPath);
BuildOutputPathBin=$(BuildOutputPathBin);
Configuration=$(Configuration);
BuildConstants=$(BuildConstants);
MSBuildTargets=$(MSBuildTargets);
TargetFrameworkVersion=$(TargetFrameworkVersion);
TargetFrameworkProfile=$(TargetFrameworkProfile)">
...
Where SolutionPath points to your sln-file.
You will then update the TeamCity config to point to MyProj.build instead, using the MsBuild runner.
Then you need a way of having TeamCity upload everything to your server. Powershell is a nice scripting environment that can run .Net code, but you'd be invoking it through MsBuild...
Something like this
http://community.bartdesmet.net/blogs/bart/archive/2008/02/16/invoking-powershell-scripts-from-msbuild.aspx
And then you can script with MsDeploy accross to your server:
http://blogs.iis.net/jamescoo/archive/2008/08/21/using-msdeploy-in-powershell.aspx
"rsync" or "scp" tools may be useful

TFS 2010: Copy _PublishedWebsites to test server

I've seen similar questions and answers but found them not really what I want.
I have a large solution with several web projects in it. All the web projects share some common code so they are all part of the same solution (there is a common project that is referenced by all of them).
I've been running on Team Foundation Server 2008 and we are upgrading to TFS 2010 to be ready for our move to visual studio 2010 and .net 4.0.
I've got the build working with a 2010 build by creating a new build because we only had one customization I'm trying to reproduce.
Once the build is done I have the files dumped at
\\SERVER\tfsdump\devel2010 build\devel2010 build_20101008.3\_PublishedWebsites
by using the dump folder option but the build location is
C:\Builds\1\Web Applications\devel2010 build\Binaries\_PublishedWebsites
All I want to do is after the build is finished I want to copy _PublishedWebsites\SiteA to \ServerA\ShareA
and copy _PublishedWebsites\SiteB to \ServerB\ShareB
Because there is only one build agent all I need is to call a batch file to run the copy but for easy of use for my developers I need this batch file to be called after every build. Is this possible or is there a better solution?
To make things harder the site is still a 2008 project and it is requested that it stays that way until we can fully test it under VS 2010.
Use a CopyDirectory build activity, set Source property equal to BuildDetail.DropLocation + "\_PublishedWebsites\SiteA" and set Destination property to your desired location. I have put this activity as the last activity in build process and it works properly.
Taking a cue from Afshar's answer, for people directly editing XAML template file, create a new sequence after copy to the Drop location is successful:
DisplayName="Something" Source="[BuildDetail.DropLocation + "_PublishedWebsites\SiteA " ]" />
The quotes inside should be written as &quot and semicolon.