<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ORTHOcoders &#187; Deployment</title>
	<atom:link href="http://orthocoders.com/tag/deployment/feed/" rel="self" type="application/rss+xml" />
	<link>http://orthocoders.com</link>
	<description>U can code it, we can help</description>
	<lastBuildDate>Fri, 13 Jan 2012 07:16:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Nuget gotcha: Avoid storing packages in the repository</title>
		<link>http://orthocoders.com/2011/03/13/nuget-gotcha-avoid-storing-packages-in-the-repository/</link>
		<comments>http://orthocoders.com/2011/03/13/nuget-gotcha-avoid-storing-packages-in-the-repository/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 18:26:10 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Build Tools]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Management]]></category>
		<category><![CDATA[Rake]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Albacore]]></category>
		<category><![CDATA[Automation]]></category>
		<category><![CDATA[Dependencies]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[MSbuild]]></category>
		<category><![CDATA[Nuget]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=322</guid>
		<description><![CDATA[Usually when working a .NET project we store the dependencies (assemblies) in a folder that gets added to the version control system of choice (TFS, SVN, Git, HG, etc).
This practice brings quite a few headaches: version updates, repository size, sharing, etc....
For the Ruby world using gems and bundler show how to solve this issue. I've been using rake + gems + bundler for my .NET project waiting for Nuget project to provide more functionality for command line usage, now the wait is over..... ]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since <a title="Nuget project to manage packages" href="http://nuget.org/" target="_blank">Nuget</a> project was released. Since the project birth I&#8217;ve been watching closely to see when would be a good opportunity to start using it for my projects and recommend using it for my clients.</p>
<p>Basically, the Nuget project solves dependency management for all your .NET projects. That means that you don&#8217;t need to search any more for libraries that you need to use like NHibernate or nUnit and just install them from a centralized server.</p>
<h2>The path to Nuget</h2>
<p>So far I&#8217;ve been using <a title="Rake - ruby make" href="http://rake.rubyforge.org/" target="_blank">Rake</a> for all my builds and I&#8217;m super happy with it. Using a DSL specifically designed for building projects is a great advantage, Ruby gives you lots of flexibility and the <a title="Albacore gem for building .net projects" href="https://github.com/derickbailey/Albacore" target="_blank">Albacore</a> gem is the cherry on top.</p>
<p>One of the many things that I like about the <a title="Ruby installer for windows" href="http://rubyinstaller.org/" target="_blank">Ruby</a> world is <a title="Rubygems project" href="http://rubygems.org/" target="_blank">gem</a> + <a title="Bundler dependency management" href="http://gembundler.com/" target="_blank">bundler</a> combination. For .NET projects I&#8217;ve been using also <a title="Noodle uses bundler to pull dependencies" href="https://github.com/spraints/noodle" target="_blank">noodle</a> to copy the dependencies to my local folder (usually called <em>lib</em>).</p>
<p>However not everything is ponies and rainbows:</p>
<ul>
<li>Ruby based solutions are not always well received in .NET project (no matter how good they are)</li>
<li>Not many developers publish their libraries / frameworks</li>
<li>Creating gems with .NET assemblies is discouraged since Nuget was born</li>
</ul>
<p>All this reasons plus the fact that the .NET community was embracing the idea of package management using Nuget make me consider it as a great option.</p>
<p>However one thing was keeping me from doing the change, and that is the <strong>ability of reading a configuration file and use it to download all dependencies</strong> (very similar to what <a title="Manage dependencies" href="http://gembundler.com/" target="_blank">Bundler</a> does).</p>
<p>And that was it&#8230;. Until a couple of days ago&#8230;.</p>
<h2><strong>Nuget Adoption</strong></h2>
<p>Last week I say a tweet by <a title="David Ebbo Twitter" href="http://twitter.com/davidebbo/status/46031701809430529" target="_blank">@davidebbo</a> saying that Nuget supports now reading from a config file!</p>
<p>Why is that so important? Because I don&#8217;t want to store my dependencies in the repository any more!</p>
<p>The assemblies that we use in a project usually don&#8217;t change until we update a newer version. What&#8217;s the point of storing them with our code if we can use just a reference to them and download them at our leisure?</p>
<p>It takes way less space to store our repositories and updating the packages quite easier because you just change the references and the configuration file, and that&#8217;s it, everyone gets them.</p>
<p>Also imagine sharing in your company all the internal assemblies by publishing them to a local Nuget server instead of having a share drive or similar.  Update the version whenever you want! No more versioning dependencies nightmares! And everything is treated the same way, they are all packages!</p>
<p>So I installed latest version of Nuget (following the <a title="Using Nuget with configuration files" href="http://bit.ly/g2ploU" target="_blank">link</a> above) and started the conversion:</p>
<h3>Step 1: Changing the References</h3>
<p>Open your .sln file, remove all your references and add them again by doing <em>right click + Add Package Reference</em>. That would accomplish the following:</p>
<ul>
<li>Find the reference in the package server</li>
<li>Install it to a local package folder (usually called Packages)</li>
<li>Write a config file with the dependency installed (in the same folder as the project)</li>
</ul>
<h3>Step 2: Modify the Rakefile</h3>
<p>I need dependencies in order to build, so I need to make sure that before building all my dependencies are satisfied, to do so I modified the task <em>setup:dep</em> to do the following:</p>
<pre class="brush: ruby; title: ; notranslate">
namespace :setup do
	desc &quot;Setup dependencies for nuget packages&quot;
	task :dep do
		FileList[&quot;**/packages.config&quot;].each do |file|
			sh &quot;nuget install #{file} /OutputDirectory Packages&quot;
		end
	end
end
</pre>
<p>And I need to make sure this happens every time before building, so I need a dependency in the build task (remember that I&#8217;m using <a title="Albacore gem for .NET projects" href="http://albacorebuild.net/" target="_blank">Albacore</a> for the msbuild tasks).</p>
<pre class="brush: ruby; title: ; notranslate">
	desc &quot;Build the project&quot;
	msbuild :all, [:config] =&gt; [:setup] do |msb, args|
		msb.properties :configuration =&gt; args[:config] || : Debug
		msb.targets :Build
		msb.solution = solution_file
	end
</pre>
<h3>Step 3: Enjoy!</h3>
<p>That&#8217;s it! Super easy! If you want to check the code please go to <a title="Source for MT Testing" href="https://github.com/amirci/mt_testing" target="_blank">github</a> and download it.</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2011/03/13/nuget-gotcha-avoid-storing-packages-in-the-repository/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>.NET Dependency Management</title>
		<link>http://orthocoders.com/2010/05/08/net-dependency-management/</link>
		<comments>http://orthocoders.com/2010/05/08/net-dependency-management/#comments</comments>
		<pubDate>Sat, 08 May 2010 23:29:13 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Build Tools]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[MSbuild]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=150</guid>
		<description><![CDATA[The problem One of the features that I miss when I work in .net is a tool to retrieve my dependencies (i.e. assemblies, tools) from a centralized server to avoid copying them again and again from project to project. In the java world Maven does that (and much more) for you, and in the Rails [...]]]></description>
			<content:encoded><![CDATA[<h3>The problem</h3>
<p>One of the features that I miss when I work in .net is a tool to retrieve my dependencies (i.e. assemblies, tools) from a centralized server to avoid copying them again and again from project to project.</p>
<p>In the java world <a href="http://maven.apache.org/" target="_blank">Maven</a> does that (and much more) for you, and in the Rails world a utility called <a href="http://rubygems.org/" target="_blank">Gems</a> (a gem is a ruby library) exists that will download and install the dependencies of your project for you.</p>
<p>To illustrate the point, let’s look at the <a href="http://nmedia.codeplex.com/" target="_blank">.NET Media Library</a> project. The project file structure looks something like this:</p>
<p>+—Media Library</p>
<p style="padding-left: 30px;">+—Main: main source, all the projects are in here.</p>
<p style="padding-left: 30px;">+—Test: Testing source, all the testing projects are in here.</p>
<p style="padding-left: 30px;">+—Lib: Dependencies for the projects.</p>
<p style="padding-left: 30px;">+—Tools: Tools to be used to build, test, deploy, etc.</p>
<p>I have to potential candidates to store external resources (actually I’m using SVN externals, but is giving me lots of grief), <em>lib </em>and<em> tools.</em></p>
<p>Under <em>lib</em> I have the libraries like:</p>
<ul>
<li><a href="http://www.castleproject.org/castle/download.html" target="_blank">Castle Core</a></li>
<li><a href="http://www.castleproject.org/castle/download.html" target="_blank">Castle Windsor</a></li>
<li><a href="http://trac.caffeine-it.com/openrasta/wiki/Doc" target="_blank">Open Rasta</a></li>
<li><a href="http://maventcommons.codeplex.com/" target="_blank">MavenThought Commons</a></li>
<li><a href="http://maventcommons.codeplex.com/" target="_blank">MavenThought Testing</a></li>
<li><a href="http://sharptestex.codeplex.com/" target="_blank">SharpTestEx</a></li>
<li><a href="http://sourceforge.net/projects/nhibernate/" target="_blank">NHibernate</a></li>
<li><a href="http://www.sqlite.org/" target="_blank">SQLite</a></li>
</ul>
<p>And under <em>tools</em> I have</p>
<ul>
<li><a href="http://svn.collab.net/" target="_blank">SVN</a></li>
<li><a href="msbuildtasks.tigris.org" target="_blank">MsBuild Community Tasks</a></li>
<li><a href="http://gallio.org/" target="_blank">Gallio</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx" target="_blank">FxCop</a></li>
<li><a href="http://code.msdn.microsoft.com/sourceanalysis" target="_blank">StyleCop</a></li>
</ul>
<p>Every library and every tool has a particular version, even some of them have dependencies on their own that I have to compile, store and copy every single time I start a project or I want to upgrade.</p>
<p>What to do? What to do indeed….</p>
<h3>A new project is born</h3>
<p>What to do? Create my own, of course.</p>
<p>Disclaimer: I don’t want to reinvent the wheel, so, if you know of a similar project, please let me know ASAP!</p>
<p>My goal is to build a tool that will use a configuration file in which I can declare my dependencies and will download them from a known host.</p>
<p>Similar to Gems I’d like to use a DSL (Domain Specific Language) to be declarative and have a clear syntax to describe, versions, sources, targets, aliases, etc.</p>
<p>However, I’d like to take advantage of another language that I can build on top, to have lots of features out of the box that otherwise I need to implement on my own.</p>
<h3>Don’t be scared, BOO is here!</h3>
<p>What better candidate than Boo? Quoting the site:</p>
<blockquote><p><a href="http://boo.codehaus.org/" target="_blank">Boo</a> Boo is a new object oriented statically typed programming language for the <a href="http://boo.codehaus.org/Common+Language+Infrastructure">Common Language Infrastructure</a> with a <a href="http://www.python.org">python</a> inspired syntax and a special focus on language and compiler extensibility.</p></blockquote>
<p>After using <a href="http://ayende.com/Blog/archive/2006/09/16/IntroductingBinsorTheBooDSLForWindsor.aspx" target="_blank">Binsor</a> in a few projects I was convinced that Boo is an excellent choice to build the tool. So my first step was to buy the book <a href="http://www.manning.com/rahien/" target="_blank">DSLs in Boo: Domain-Specific Languages in .NET</a>, and start reading.</p>
<h3>First Draft DSL Syntax</h3>
<p>Let’s imagine that we want to declare dependencies for the .NET Media Library, here is my idea so far:</p>
<div id="scid:f32c3428-b7e9-4f15-a8ea-c502c7ff2e88:9fd4abe9-586d-48c9-bab7-3af215e37063" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<pre class="brush: ruby;">lib_folder lib
source http://MavenThought.com/nass

# Testing libraries
lib MavenThought.Commons, 0.2
lib MavenThought.Testing, 0.2
lib nunit, 2.5
lib SharpTestEx, 1.0
lib SpecFlow, 1.2

# Castle Stack
lib Castle.Core, 1.1
lib Castle.Windsor, 2.0

# ORM
lib NHibernate, 2.1
lib SQLite, 2.1

# Web framework
lib OpenRasta, 2.0.3
lib JSon.NET, 3.5</pre>
</div>
<p>The <em>lib keyword </em>declares the dependency and the version and we can see at the top the configuration for the destination folder and the source to get the dependencies. Because we are using Boo we can use the comments, etc…</p>
<p>Any feedback?</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2010/05/08/net-dependency-management/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>MSBuild scripting part II, Versioning and Deployment</title>
		<link>http://orthocoders.com/2008/12/31/msbuild-scripting-part-ii-versioning-and-deploy/</link>
		<comments>http://orthocoders.com/2008/12/31/msbuild-scripting-part-ii-versioning-and-deploy/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 23:46:36 +0000</pubDate>
		<dc:creator>Amir Barylko</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[MSbuild]]></category>
		<category><![CDATA[Versioning]]></category>

		<guid isPermaLink="false">http://orthocoders.com/?p=8</guid>
		<description><![CDATA[MsBuild Introduction MsBuild is a language to create build scripts using predefined tasks. Please check my previous blog for a full description Versioning Before talking about deployment we have to consider how to version our assemblies before copying them to any environment. Having the correct version number is very important once you start a development [...]]]></description>
			<content:encoded><![CDATA[<h2>MsBuild Introduction</h2>
<p style="text-align: justify;">MsBuild is a language to create build scripts using predefined tasks. Please check my <a title="MSBuild Part I" href="http://orthocoders.com/?p=7" target="_blank">previous blog</a> for a full description</p>
<h2>Versioning</h2>
<p>Before talking about deployment we have to consider how to version our assemblies before copying them to any environment. Having the correct version number is very important once you start a development iteration. The QA team needs to know which version to test and report, the user needs to know which version they are seeing, you need to know which version is causing problems, etc&#8230;</p>
<p>.NET uses the <i>Properties/AssemblyInfo.cs</i> file to store the version info. Inside each file you will find the following code:</p>
<pre class="csharp" name="code">
// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
</pre>
<p>Here is a brief description of the recommended usage of each number:</p>
<ul>
<li>Major: This number indicates a big difference between versions. When it changes the user will expect &#8220;Major&#8221; changes in functionality.</li>
<li>Minor: This number indicates fixes, bugs, etc. Still same functionality but with some modifications.</li>
<li>Build: This number indicates the amount of times you built the app so far. (not always used)</li>
<li>Revision: This number indicates the revision number from your source control. This number is very important because it would give you the information needed in order to check the revision you need and be able to reproduce bugs, errors, etc.</li>
</ul>
<p>So far, so good. We just need to change all the files in each project and put the same version&#8230; and when it changes&#8230; again&#8230; easy, right?</p>
<h3>MsBuild to the rescue</h3>
<p>Not to fret my friend, luckily we have <i>msbuild</i> on our side. First of all we will define the version we want in or <i>msbuild</i> file, using a property group.</p>
<pre class="xml" name="code">
	&lt;Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/&gt;

	&lt;PropertyGroup&gt;
		&lt;ProjectName&gt;MediaLibrary&lt;/ProjectName&gt;
		&lt;ExportFolder&gt;\temp\Export\$(ProjectName)&lt;/ExportFolder&gt;
		&lt;BuildFolder&gt;\temp\Builds\$(ProjectName)\Latest&lt;/BuildFolder&gt;
		&lt;Major&gt;0&lt;/Major&gt;
		&lt;Minor&gt;1&lt;/Minor&gt;
		&lt;Build&gt;0&lt;/Build&gt;
	&lt;/PropertyGroup&gt;
</pre>
<p>As you can see the revision number is not included because we would like to use the source control tool to get the revision number every time we run the script to make sure we always have the right version.</p>
<p><a title="Tigris.org" href="http://msbuildtasks.tigris.org/" target="_blank">Tigris</a> has a set of tasks that will help us to achieve our goal. You can download it for free and install it.</p>
<p>Now that we have the version we want (<em>Major.Minor.Build</em>) we need to get the revision number from the repository and store it into a property. Because I use SVN I&#8217;ll use the <em>SvnVersion</em> task from Tigris to get the version number and store it into the property <em>Revision</em>.</p>
<p>If you also use SVN you will need a command line tool in order to run <i>svnversion</i>. <a title="SVN client Collabnet" href="http://www.collab.net/downloads/subversion/" target="_blank">Collabnet</a> has a free SVN client you can download and use.</p>
<p>After finding the version number we need to find all the files that we would like to change. For that purpose we will define another <em>ItemGroup</em> including all the <em>AssemblyInfo.cs</em> files in our hierarchy and store them into the variable <em>AssemblyFiles</em>.</p>
<p>The final step is to replace each declaration with the version in the <em>AssemblyInfo.cs </em>file with the version we defined in our build file using the <em>FileUpdate</em> task for each <em>cs</em> file.</p>
<pre name="code" class="xml">
&lt;Target Name=&quot;UpdateAssemblyVersion&quot;&gt;
		&lt;SvnVersion LocalPath=&quot;$(MSBuildProjectDirectory)&quot;&gt;
	      &lt;Output TaskParameter=&quot;Revision&quot; PropertyName=&quot;Revision&quot; /&gt;
		&lt;/SvnVersion&gt;

		&lt;ItemGroup&gt;
			&lt;AssemblyFiles Include=&quot;**\AssemblyInfo.cs&quot;/&gt;
		&lt;/ItemGroup&gt;

 	    &lt;Message Text=&quot;Version: $(Major).$(Minor).$(Build).$(Revision)&quot;/&gt;

		&lt;FileUpdate Files=&quot;@(AssemblyFiles)&quot;
                Regex=&quot;(\d+)\.(\d+)\.(\d+)\.(\d+)&quot;
                ReplacementText=&quot;$(Major).$(Minor).$(Build).$(Revision)&quot; /&gt;

&lt;/Target&gt;
</pre>
<p>The <em>FileUpdate</em> task uses a regular expression to find the version number. In this case we are looking for four digits separated by dots and as replacement we use the variables we defined previously.</p>
<h2>Deployment</h2>
<p>Alright. We have all our assemblies (executable, etc) with the right version and we are ready to roll.<br />
Now, we need to build again to include the right version in release mode and then copy the files to the destination of our preference. </p>
<p>A common practice is to copy the files to a folder where all the team knows the latest version will reside. Using a continuous integration tool like <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET" target="_blank">Cruise Control .NET</a> or <a href="http://www.jetbrains.com/teamcity/download/" target="_blank">TeamCity</a> makes easier to have always the latest version available as soon a new change is committed to the repository.</p>
<p>I&#8217;ll call this task <em>DeployBin</em> and will do the following:</p>
<ul>
<li>Delete the destination folder</li>
<li>Call the <em>UpdateAssemblyVersion</em> task to update to the latest version of all the <em>Assembly.cs</em> files.</li>
<li>Build again (Release mode) to have the latest binaries with the version updated.</li>
<li>Create the destination folder.</li>
<li>Define a variable called <em>SourceFiles</em> using an <em>ItemGroup</em> to include all the assemblies I would like to copy and excluding the ones I don&#8217;t need (testing assemblies).</li>
<li>Copy all the files listed in the <em>SourceFiles</em> variable to the chosen destination.</li>
</ul>
<p>Ready? Here is the magic:</p>
<pre name="code" class="xml">
	&lt;Target Name=&quot;DeployBin&quot;&gt;
		&lt;RemoveDir Directories=&quot;$(BuildFolder);$(ExportFolder)&quot; ContinueOnError=&quot;true&quot; /&gt;
		&lt;CallTarget Targets=&quot;UpdateAssemblyVersion&quot;/&gt;
		&lt;CallTarget Targets=&quot;Build&quot;/&gt;
		&lt;MakeDir Directories =&quot;$(BuildFolder)&quot;/&gt;
		&lt;ItemGroup&gt;
			&lt;SourceFiles Include=&quot;**\bin\Release\*.dll&quot; Exclude=&quot;**\*.Tests\bin\release\*.dll&quot;/&gt;
		&lt;/ItemGroup&gt;
		&lt;Copy SourceFiles=&quot;@(SourceFiles)&quot;
				DestinationFolder=&quot;$(BuildFolder)&quot;&gt;
			&lt;Output TaskParameter=&quot;CopiedFiles&quot; PropertyName=&quot;Copied&quot;/&gt;
		&lt;/Copy&gt;
	&lt;/Target&gt;
</pre>
<p>Voila! That&#8217;s it! You can make the deployment as complicated as you want. You can separate the folders, rename the previous version, etc, etc.</p>
<p>Here is the <a href='http://orthocoders.com/wp-content/uploads/2009/01/medialibrary.msbuild'>complete file</a> in case you would like to look at it. I hope you will find it useful.</p>
<p>In my next blog about <em>MSBuild</em> we will talk about creating custom tasks.</p>
<p>Any feedback is most welcome.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://orthocoders.com/2008/12/31/msbuild-scripting-part-ii-versioning-and-deploy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

