<?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>the tar pit &#187; msbuild packaging</title>
	<atom:link href="http://blog.goneopen.com/tag/msbuild-packaging/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.goneopen.com</link>
	<description>Thrashing around in the stickiness of software</description>
	<lastBuildDate>Mon, 09 Jan 2012 23:35:25 +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>Understanding the packaging</title>
		<link>http://blog.goneopen.com/2010/01/understanding-the-packaging-4/</link>
		<comments>http://blog.goneopen.com/2010/01/understanding-the-packaging-4/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 04:42:18 +0000</pubDate>
		<dc:creator>todd</dc:creator>
				<category><![CDATA[Deployment]]></category>
		<category><![CDATA[msbuild packaging]]></category>

		<guid isPermaLink="false">http://blog.goneopen.com/2010/01/understanding-the-packaging-4/</guid>
		<description><![CDATA[Build the package So what we&#8217;ll do is actually build a package by using the command msbuild /t:PackageBeta Below is the output that I have shorted so that you can see major targets that create the package as a zip file in the location: CodeToDeploy\Releases\Sample-Beta-0.1.0.0.zip Version Clean Publish Zip C:\src\deployment&#62;msbuild /t:PackageBeta Microsoft (R) Build Engine [...]]]></description>
			<content:encoded><![CDATA[<h1>Build the package</h1>

<p>So what we&#8217;ll do is actually build a package by using the command <code>msbuild /t:PackageBeta</code></p>

<p>Below is the output that I have shorted so that you can see major targets that create the package as a zip file in the location: <code>CodeToDeploy\Releases\Sample-Beta-0.1.0.0.zip</code></p>


<ul>
<li>Version</li>
<li>Clean</li>
<li>Publish</li>
<li>Zip</li>
</ul>





<pre>
C:\src\deployment&gt;msbuild /t:PackageBeta
Microsoft (R) Build Engine Version 3.5.30729.1
[Microsoft .NET Framework, Version 2.0.50727.3053]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 1/15/2010 4:53:21 PM.
Project &quot;C:\src\deployment\build.proj&quot; on node 0 (PackageBeta target(s)).
Project &quot;C:\src\deployment\build.proj&quot; (1) is building &quot;C:\src\deployment\build
.proj&quot; (1:2) on node 0 (Package target(s)).
  Version: 0.1.0.0
  Updating File &quot;C:\src\deployment\src\Infrastructure\Properties\AssemblyInfo.c
  s&quot;.
    Replaced matches with &quot;[assembly: AssemblyVersion(&quot;0.1.0.0&quot;)]&quot;.
  Updating File &quot;C:\src\deployment\src\Test\Properties\AssemblyInfo.cs&quot;.
    Replaced matches with &quot;[assembly: AssemblyVersion(&quot;0.1.0.0&quot;)]&quot;.
  Updating File &quot;C:\src\deployment\src\UI\Properties\AssemblyInfo.cs&quot;.
    Replaced matches with &quot;[assembly: AssemblyVersion(&quot;0.1.0.0&quot;)]&quot;.

  ...

Clean:
  Removing directory &quot;C:\src\deployment\CodeToDeploy\Publish&quot;.
Publish:
  Creating directory &quot;C:\src\deployment\CodeToDeploy\Publish\site&quot;.
  Creating directory &quot;C:\src\deployment\CodeToDeploy\Publish\site\bin&quot;.
  Copying file from &quot;C:\src\deployment\Src\UI\bin\UI.dll&quot; to &quot;C:\src\deployment
  \CodeToDeploy\Publish\site\bin\UI.dll&quot;.

  ...

Zip:
  Creating ZipFile: C:\src\deployment\CodeToDeploy\Publish\..\Releases\Sample-B
  eta-0.1.0.0.zip
Done Building Project &quot;C:\src\deployment\build.proj&quot; (Package target(s)).

Done Building Project &quot;C:\src\deployment\build.proj&quot; (PackageBeta target(s)).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.70
</pre>

<p>  </p>

<h1>Sorry, where was that release package?</h1>

<p>The current scripts output the release file into a folder called <code>CodeToDeploy</code> (yes, this conventions was grabbed from CodeCampServer for asp.net mvc). In this folder, we build the raw output files to <code>Publish</code> (yes, this is a microsoft convention) and the packages to <code>Release</code>. The release file also then has the version number in the file. Here&#8217;s what it looks like below:</p>



<pre>
  CodeToDeploy/
    Publish/
      ... [all the files here]
    Releases/
      Sample-Beta-0.1.0.0.zip
</pre>



<h1>Unzip and explore</h1>

<p>Now, we can unzip the archive as below (of course, it is the same of the publish folder!)</p>



<pre>
    lib/
        extensionpack
        migratordotnet
    scripts/
        db/
            create.sql
            domainuser-for-db.sql
            drop.sql
            user-for-db.sql
        db-setup.tasks
    site/
      ... [all the application site stuff here]
    0.1.0.0
    Deploy.bat
    deploy.proj
    deploy.rsp
    directorybrowsing.xml
    Migrate.bat
    _Beta_ENVIRONMENT
</pre>



<p>Let&#8217;s work through this:</p>

<p><dl><br />
    <dt>lib</dt><br />
    <dd>This contains any libraries that are required for deployment process (rather than actually running the site). In this case we will be migrating a database and deploying to <span class="caps">IIS.</span></dd><br />
    <dt>scripts</dt><br />
    <dd>These are all the deployment scripts needed. This includes scripts for first-time install and as well subsequent deployments (reinstalls/upgrades). Here you will se that all the creation scripts for the sql database are included.</dd><br />
    <dt>site</dt><br />
    <dd>This is the actual code that gets deployed to <span class="caps">IIS</span></dd><br />
    <dt>0.1.0.0</dt><br />
    <dd>This is an empty file that simply has the version number as the name for quick identification.</dd><br />
    <dt>Deploy.bat, .proj, .rsp</dt><br />
    <dd>These are the workhorse files for each installation. The bat file is the <span class="caps">GUI </span>runner to invoke msbuild so that double click installs can be performed. The proj file has the targets (in this case there are no child tasks). The rsp file is there because it can be used to set specific environment variables that we want picked up regards of commandline or gui base bootstrapping</dd><br />
    <dt>directorybrowsing.xml</dt><br />
    <dd>Sorry, this is an odd fellow. It is copied to certain <span class="caps">IIS </span>environments to allow for directory browsing. At this stage, this approach is a path of least resistance.</dd><br />
    <dt>Migrate.bat</dt><br />
    <dd>This file is <span class="caps">GUI </span>runner just like deploy.bat except it is focussed exlusively on migrations. If you look at its contents you can see that it is <code>msbuild.exe /t:MigrateUp /v:d /fl</code> which is targetting <code>Migrate up</code> and outputting a verbose log to the default log file <code>msbuild.log</code></dd><br />
    <dt>_Beta_ENVIRONMENT</dt><br />
    <dd>This file tells us that it was build specifically for the Beta environment. I use this technique if I have create builds specific to an environment. I avoid this approach as discussed earlier.</dd><br />
</dl></p>

<h1>Understand the versioning</h1>

<p>A last comment in this packaging process. Versioning of libraries and packages is always done. There are two main files that control the versioning:</p>



<pre>
 VERSION.xml
 scripts/
    version.tasks
</pre>



<p><dl><br />
    <dt><a href="http://github.com/toddb/msbuild-deployment-sample/blob/master/VERSION.xml"><span class="caps">VERSION.</span>xml</a></dt><br />
    <dd>This has already been mentioned before and can be found . It is the major.minor.build number. You&#8217;ll update this infrequently</p>


<pre>
  &lt;PropertyGroup&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></dd><br />
    <dt><a href="http://github.com/toddb/msbuild-deployment-sample/blob/master/scripts/version.tasks">version.tasks</a></dt><br />
    <dd>It does two things. It gets the revision number from the source control &#8211; the sample uses <span class="caps">SVN </span>but it can be <span class="caps">TFS, </span>git, Peforce. It creates a version of the format: <strong>major.minor.build.revision</strong>. It updates all the AssemblyInfo.cs files based on the version. Now that I have told you that, let&#8217;s see what Help tells us!<br />
    </p>


<pre>
    &gt;msbuild /t:HelpVersion
    
    Microsoft (R) Build Engine Version 3.5.30729.1
    [Microsoft .NET Framework, Version 2.0.50727.3053]
    Copyright (C) Microsoft Corporation 2007. All rights reserved.

    Build started 1/15/2010 5:45:27 PM.
    Project &quot;C:\src\deployment\build.proj&quot; on node 0 (HelpVersion target(s)).


          Updates all the AssemblyInfo.cs files with VERSION (major, minor, build)
          and revision looked up from svn

          msbuild /t:Version

          Targets:
           - Version
           - SvnVersion

          Dependencies: svn commandline client (svnversion.exe - installed to 
                                            C:\Program Files\Subversion\bin)
</pre>


<p>        </dd><br />
</dl></p>

<p>Points to watch out for:</p>


<ul>
<li>revision with 0 means that it was probably a local build without access to source control</li>
<li>AssemblyInfo.cs files get updated but you don&#8217;t want to check this in and you don&#8217;t want these to come up as changed so I suggest that you check them into source and then put an ignore or lock on them.</li>
<li>Build server should really be the only place that creates this version number</li>
<li>release packages have version numbers in the filename for ease and archiving</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://blog.goneopen.com/2010/01/understanding-the-packaging-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

