Octopus Deploy - Part I - Visual Studio setup

We recently added Octopus Deploy to our continuous deployment pipeline. It helped us automate and streamline our deployment process in a big way plus it's become an essential part of any new application we bring on board. It makes our development and testing much easier with almost no IT intervention even for live environments. Best of all, we have much less friction and better communication between developers and system administrators, which as you probably already know is not always the case ;-)

We decided to share our experience working with Octopus through a series of articles listed below:
1. Visual Studio setup
2. Team Foundation Server setup
3. Octopus Dashboard setup
4. Project Features
5. Extras

Configuring your existing .NET Web Application includes the following tasks:



In this article, we'll discuss the "Prep Solution" task via Visual Studio.


Visual Studio Setup

According to the Octopus documentation, adding the Octopack Nuget package should be sufficient BUT in our case that didn't work out as expected most probably due to our Build Server configuration. We therefore had to add a few more steps in the process to get it working.


Step 1 - Add Octopack

In Visual Studio, right-click your Web project and click on Manage NuGet packages and look for Octopack then install it. 

Alternatively use the Package Manager console and run the following command

Install-Package Octopack


Step 2 - Add Nuget.exe

Within your Web project, include the Nuget.exe so it gets packaged with your solution e.g. /tools/nuget.exe


Step 3 - Add build.proj

Within your Web project's root folder, add a new build.proj file. A build.proj file is an MSBuild configuration file that your build server will use to generate the solution package.


Step 4 - Edit build.proj

You can use the sample build.proj file below, don't forget to set your paths appropriately (in bold).
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0"
         DefaultTargets="Build"
         xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <OutDir Condition=" '$(OutDir)'=='' ">$(MSBuildThisFileDirectory)bin\</OutDir>
    <Configuration Condition=" '$(Configuration)'=='' ">Release</Configuration>
    <SourceHome Condition=" '$(SourceHome)'=='' ">$(MSBuildThisFileDirectory)..\</SourceHome>
    <ToolsHome Condition=" '$(ToolsHome)'=='' ">$(MSBuildThisFileDirectory)tools\</ToolsHome>
  </PropertyGroup>

  <ItemGroup>
    <Solution Include="$(SourceHome)YourProject.sln">
      <AdditionalProperties>OutDir=$(OutDir);Configuration=$(Configuration)</AdditionalProperties>
    </Solution>
  </ItemGroup>

  <Target Name="RestorePackages">
    <Exec Command=""$(ToolsHome)NuGet.exe" restore "%(Solution.Identity)"" />
  </Target>

  <Target Name="Clean">
    <MSBuild Targets="Clean"
             Projects="@(Solution)" />
  </Target>

  <Target Name="Build" DependsOnTargets="RestorePackages">
    <MSBuild Targets="Build"
             Projects="@(Solution)" />
  </Target>

  <Target Name="Rebuild" DependsOnTargets="RestorePackages">
    <MSBuild Targets="Rebuild"
             Projects="@(Solution)" />
  </Target>
</Project>

IMPORTANT: Getting the paths wrong can cause several MSBuild errors that we'll discuss in a future post.

We're done with Visual Studio setup! In the next article, we discuss the Team foundation Server setup.

[original publish date: 02/09/15]

Comments

Popular posts from this blog

ASP.NET Identity Remember Me

IIS Express Client Certificates

ASP.NET MVC - How to enable/disable CaC/Client Certificate authentication per area or route.