<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Jay Harris is Cpt. LoadTest - Continuous Integration</title>
    <link>http://www.cptloadtest.com/</link>
    <description>a .net developers blog on improving user experience of humans and coders</description>
    <language>en-us</language>
    <copyright>Jason Harris</copyright>
    <lastBuildDate>Tue, 03 Dec 2013 05:34:25 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.12105.0</generator>
    <managingEditor>jharris@harrisdesigns.com</managingEditor>
    <webMaster>jharris@harrisdesigns.com</webMaster>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Azure Websites are a fantastic method of hosting your own web site. At Arana Software,
we use them often, particularly as test environments for our client projects. We can
quickly spin up a free site that is constantly up-to-date with the latest code using
continuous deployment from the project’s Git repository. Clients are able to see progress
on our development efforts without us having to worry about synchronizing codebases
or managing infrastructure. Since Windows Azure is a Microsoft offering, it is a natural
for handling .NET projects, but JavaScript-based nodejs is also a natural fit and
a first-class citizen on the Azure ecosystem.
</p>
        <h3>Incorporating Grunt
</h3>
        <p>
          <a href="http://gruntjs.com/">Grunt</a> is a JavaScript-based task runner for your
development projects to help you with those repetitive, menial, and mundane tasks
that are necessary for production readiness. This could be running unit tests, compiling
code, image processing, bundling and minification, and more. For our production deployments,
we commonly use Grunt to compile LESS into CSS, CoffeeScript into JavaScript, and
Jade into HTML, taking the code we write and preparing it for browser consumption.
We also use Grunt to optimize these various files for speed through bundling and minification.
The output of this work is done at deployment rather than development, with only the
source code committed into Git and never its optimized output.
</p>
        <h3>Git Deploy and Kudu
</h3>
        <p>
Continuous deployment will automatically update your site with the latest source code
whenever modifications are made to the source repository. This will also work with
Mercurial. There is plenty of existing documentation on <a href="http://www.windowsazure.com/en-us/develop/nodejs/common-tasks/publishing-with-git/">setting
up Git Deploy in Azure</a>, so consider that a prerequisite for this article. However,
Git Deploy, alone, will only take the files as they are in source, and directly deploy
them to the site. If you need to run additional tasks, such as compiling your .NET
source or running Grunt, that is where Kudu comes in.
</p>
        <p>
Kudu is the engine that drives Git deployments in Windows Azure. Untouched, it will
simply synchronize files from Git to your /wwwroot, but it can be easily reconfigured
to execute a deployment command, such as a Windows Command file, a Shell Script, or
a nodejs script. This is enabled through a standardized file named ".deployment".
For Grunt deployment, we are going to execute a Shell Script that will perform npm,
Bower, and Grunt commands in an effort to make our code production-ready. For other
options on .deployment, check out the <a href="https://github.com/projectkudu/kudu/wiki">Kudu
project wiki</a>.
</p>
        <p>
Kudu is also available locally for testing, and to help build out your deployment
scripts. The engine is available as a part of the cross-platform Windows Azure Command
Line Tools, available through npm.
</p>
        <h4>Installing the Azure CLI
</h4>
        <pre class="plain:nocontrols" name="code">npm install azure-cli –-global</pre>
        <p>
We can also use the Azure CLI to generate default Kudu scripts for our nodejs project.
Though we will need to make a few modifications to make the scripts work with Grunt,
it will give us a good start.
</p>
        <pre class="plain:nocontrols" name="code">azure site deploymentscript –-node</pre>
        <p>
This command will generate both our &lt;code&gt;.deployment&lt;/code&gt; and the default
&lt;code&gt;deploy.sh&lt;/code&gt;.
</p>
        <h4>Our .deployment file
</h4>
        <pre class="plain" name="code">[config]
command = bash ./deploy.sh</pre>
        <h3>Customizing deploy.sh for Grunt Deployment
</h3>
        <p>
From <code>.deployment</code>, Kudu will automatically execute our <code>deploy.sh</code> script.
Kudu’s default <code>deploy.sh</code> for a nodejs project will establish the environment
for node and npm as well as some supporting environment variables. It will also include
a "# Deployment" section containing all of the deployment steps. By default,
this will copy your repository contents to your /wwwroot, and then execute <code>npm
install --production</code> against wwwroot, as if installing the application's operating
dependencies. However, under Grunt, we want to execute tasks prior to <code>/wwwroot</code> deployment,
such as executing our Grunt tasks to compile LESS into CSS and CoffeeScript into JavaScript.
By replacing the entire Deployment section with the code below, we instruct Kudu to
perform the following tasks:
</p>
        <ol>
          <li>
Get the latest changes from Git (or Hg). This is done automatically before running
deploy.sh. 
</li>
          <li>
Run <code>npm install</code>, installing all dependencies, including those necessary
for development. 
</li>
          <li>
Optionally run <code>bower install</code>, if bower.json exists. This will update
our client-side JavaScript libraries. 
</li>
          <li>
Optionally run <code>grunt</code>, if Gruntfile.js exists. Below, I have grunt configured
to run the Clean, Common, and Dist tasks, which are LinemanJS's default tasks for
constructing a production-ready build. You can update the script to run whichever
tasks you need, or modify your Gruntfile to set these as the default tasks. 
</li>
          <li>
Finally, sync the contents of the prepared <code>/dist</code> directory to <code>/wwwroot</code>.
It is important to note that this is a KuduSync (similar to RSync), and not just a
copy. We only need to update the files that changed, which includes removing any obsolete
files. 
</li>
        </ol>
        <h4>Our deploy.sh file's Deployment Section
</h4>
        <pre class="plain:firstline[98]" name="code"># Deployment
# ----------

echo Handling node.js grunt deployment.

# 1. Select node version
selectNodeVersion

# 2. Install npm packages
if [ -e "$DEPLOYMENT_SOURCE/package.json" ]; then
  eval $NPM_CMD install
  exitWithMessageOnError "npm failed"
fi

# 3. Install bower packages
if [ -e "$DEPLOYMENT_SOURCE/bower.json" ]; then
  eval $NPM_CMD install bower
  exitWithMessageOnError "installing bower failed"
  ./node_modules/.bin/bower install
  exitWithMessageOnError "bower failed"
fi

# 4. Run grunt
if [ -e "$DEPLOYMENT_SOURCE/Gruntfile.js" ]; then
  eval $NPM_CMD install grunt-cli
  exitWithMessageOnError "installing grunt failed"
  ./node_modules/.bin/grunt --no-color clean common dist
  exitWithMessageOnError "grunt failed"
fi

# 5. KuduSync to Target
"$KUDU_SYNC_CMD" -v 500 -f "$DEPLOYMENT_SOURCE/dist" -t "$DEPLOYMENT_TARGET" -n "$NEXT_MANIFEST_PATH" -p "$PREVIOUS_MANIFEST_PATH" -i ".git;.hg;.deployment;deploy.sh"
exitWithMessageOnError "Kudu Sync to Target failed"</pre>
        <p>
These commands will execute bower and Grunt from local npm installations, rather than
the global space, as Windows Azure does not allow easy access to global installations.
Because bower and Grunt are manually installed based on the existence of bower.json
or Gruntfile.js, they also are not required to be referenced in your own package.json.
Finally, be sure to leave the –no-color flag enabled for Grunt execution, as the Azure
Deployment Logs will stumble when processing the ANSI color codes that are common
on Grunt output.
</p>
        <p>
Assuming that Git Deployment has already been configured, committing these files in
to Git will complete the process. Because the latest changes from Git are pulled before
executing the deployment steps, these two new files (<code>.deployment</code> and <code>deploy.sh</code>)
will be available when Kudu is ready for them.
</p>
        <h3>Troubleshooting
</h3>
        <h4>Long Directory Paths and the 260-Character Path Limit
</h4>
        <p>
Though Azure does a fantastic job of hosting nodejs projects, at the end of the day
Azure is still hosted on the Windows platform, and brings with it Windows limitations.
One of the issues that you will quickly run into under node is the <a href="http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath">260-Character
Path Limitation</a>. Under nodejs, the dependency tree for a node modules can get
rather deep. And because each dependency module loads up its own dependency modules
under its child folder structure, the folder structure can get rather deep, too. For
example, Lineman requires Testem, which requires Winston, which requires Request;
in the end, the directory tree can lead to ~/node_modules/lineman/node_modules/testem/node_modules/winston/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream,
which combined with the root path structure, can far exceed the 260 limit.
</p>
        <p>
          <i>The Workaround</i>
        </p>
        <p>
To reduce this nesting, make some of these dependencies into first-level dependencies.
With the nodejs dependency model, if a module has already been brought in at a higher
level, it is not repeated in the chain. Thus, if Request is made as a direct dependency
and listed in your project's project.json, it will no longer be nested under Winston,
splitting this single dependency branch in two:
</p>
        <ol>
          <li>
~/node_modules/lineman/node_modules/testem/node_modules/winston 
</li>
          <li>
~/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream 
</li>
        </ol>
        <p>
This is not ideal, but it will solve is a workaround for the Windows file structure
limitations. The element that you must be careful of is with dependency versioning,
as you will need to make sure your <code>package.json</code> references the appropriate
version of your pseudo-dependency; in this case, make sure your <code>package.json</code> references
the same version of Request as is referenced by Winston.
</p>
        <p>
To help find those deep dependencies, use <code>npm list</code>. It will show you
the full graph on the command line, supplying a handy visual indicator.
</p>
        <h4>__dirname vs Process.cwd()
</h4>
        <p>
In the node ecosystem, <code>Process.cwd()</code> is the current working directory
for the node process. There is also a common variable named <code>__dirname</code> that
is created by node; its value is the directory that contained your node script. If
you executed node against a script in the current working directory, then these values
should be the same. Except when they aren't, like in Windows Azure.
</p>
        <p>
In Windows Azure, everything is executed on the system drive, C:. Node and npm live
here, and it appears as though your deployment space does as well. However, this deployment
space is really a mapped directory, coming in from a network share where your files
are persisted. In Azure's node ecosystem, this means that your <code>Process.cwd()</code> is
the C-rooted path, while <code>__dirname</code> is the \\10.whatever-rooted UNC path
to your persisted files. Some Grunt-based tools and plugins (including Lineman) will
fail because that it will reference <code>__dirname</code> files while Grunt's core
is attempting to run tasks with the scope of <code>Process.cwd()</code>; Grunt recognizes
that it's trying to take action on \\10.whatever-rooted files in a C-rooted scope,
and fails because the files are not in a child directory.
</p>
        <p>
          <i>The Workaround</i>
        </p>
        <p>
If you are encountering this issue, reconfigure Grunt to work in the \\10.whatever-rooted
scope. You can do this by setting it's base path to <code>__dirname</code>, overriding
the default <code>Process.cwd()</code>. Within your Gruntfile.js, set the base path
immediately within your module export:
</p>
        <pre class="jscript" name="code">module.exports = function (grunt) {
  grunt.file.setBase(__dirname);
  // Code omitted
}</pre>
        <h4>Unable to find environment variable LINEMAN_MAIN
</h4>
        <p>
If like me, you are using Lineman to build your applications, you will encounter this
issue. Lineman manages Grunt and its configuration, so it prefers that all Grunt tasks
are executed via the Lineman CLI rather than directly executed via the Grunt CLI.
Lineman's Gruntfile.js includes a reference to an environment variable LINEMAN_MAIN,
set by the Lineman CLI, so that Grunt will run under the context of the proper Lineman
installation, which is what causes the failure if Grunt is executed directly.
</p>
        <p>
          <i>The Fix (Because this isn't a hack)</i>
        </p>
        <p>
Your development cycle has been configured to use lineman, so your deployment cycle
should use it, too! Update your <code>deploy.sh</code> Grunt execution to run Lineman
instead of Grunt. Also, since Lineman is referenced in your package.json, we don't
need to install it; it is already there.
</p>
        <p>
Option 1: deploy.sh
</p>
        <pre class="plain:firstline[120]" name="code"># 4. Run grunt
if [ -e "$DEPLOYMENT_SOURCE/Gruntfile.js" ]; then
  ./node_modules/.bin/lineman --no-color grunt clean common dist
  exitWithMessageOnError "lineman failed"
fi</pre>
        <p>
Recommendation: Since Lineman is wrapping Grunt for all of its tasks, consider simplifying <code>lineman
grunt clean common dist</code> into <code>lineman clean build</code>. You will still
need the <code>--no-color</code> flag, so that Grunt will not use ANSI color codes. 
</p>
        <p>
          <i>The Alternate Workaround</i>
        </p>
        <p>
If you don't want to change your <code>deploy.sh</code>—perhaps because you want to
maintain the generic file to handle all things Grunt—then as an alternative you can
update your <code>Gruntfile.js</code> to specify a default value for the missing <code>LINEMAN_MAIN</code> environment
variable. This environment variable is just a string value passed in to node's require
function, so that the right Lineman module can be loaded. Since Lineman is already
included in your <code>package.json</code>, it will already be available in the local <code>/node_modules</code> folder
because of the earlier <code>npm install</code> (deploy.sh, Step #2), and we can pass
'lineman' into <code>require( )</code> to have Grunt load the local Lineman installation.
Lineman will then supply its configuration into Grunt, and the system will proceed
as if you executed Lineman directly.
</p>
        <p>
Option 2: Gruntfile.js
</p>
        <pre class="jscript" name="code">module.exports = function(grunt) {
  grunt.file.setBase(__dirname);
  if (process.env['LINEMAN_MAIN'] === null || process.env['LINEMAN_MAIN'] === undefined) {
    process.env['LINEMAN_MAIN'] = 'lineman';
  }
  require(process.env['LINEMAN_MAIN']).config.grunt.run(grunt);
};</pre>
        <h3>Credits
</h3>
        <p>
Thank you to <a href="http://www.twitter.com/davidebbo">@davidebbo</a>, <a href="http://www.twitter.com/guayan">@guayan</a>, <a href="http://www.twitter.com/amitapl">@amitapl</a>,
and <a href="http://www.twitter.com/dburton">@dburton</a> for helping troubleshoot
Kudu and Grunt Deploy, making this all possible.
</p>
        <h3>Changelog
</h3>
        <p>
2013-12-03: Updated LINEMAN_MAIN Troubleshooting to improve resolution. Rather than
editing deploy.sh to set the environment variable, edit the file to execute Lineman.
This is the proper (and more elegant) solution. [Credit: <a href="http://www.twitter.com/searls">@searls</a>]
</p>
        <div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9b0ba700-7d7e-41fe-8c1b-8c35f6d0d010" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px">Technorati
Tags: <a href="http://technorati.com/tags/Grunt" rel="tag">Grunt</a>,<a href="http://technorati.com/tags/Lineman" rel="tag">Lineman</a>,<a href="http://technorati.com/tags/Node" rel="tag">Node</a>,<a href="http://technorati.com/tags/Azure" rel="tag">Azure</a>,<a href="http://technorati.com/tags/Git" rel="tag">Git</a></div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d" />
      </body>
      <title>Git and Grunt Deploy to Windows Azure</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</guid>
      <link>http://www.cptloadtest.com/2013/12/03/Git-And-Grunt-Deploy-To-Windows-Azure.aspx</link>
      <pubDate>Tue, 03 Dec 2013 05:34:25 GMT</pubDate>
      <description>&lt;p&gt;
Azure Websites are a fantastic method of hosting your own web site. At Arana Software,
we use them often, particularly as test environments for our client projects. We can
quickly spin up a free site that is constantly up-to-date with the latest code using
continuous deployment from the project’s Git repository. Clients are able to see progress
on our development efforts without us having to worry about synchronizing codebases
or managing infrastructure. Since Windows Azure is a Microsoft offering, it is a natural
for handling .NET projects, but JavaScript-based nodejs is also a natural fit and
a first-class citizen on the Azure ecosystem.
&lt;/p&gt;
&lt;h3&gt;Incorporating Grunt
&lt;/h3&gt;
&lt;p&gt;
&lt;a href="http://gruntjs.com/"&gt;Grunt&lt;/a&gt; is a JavaScript-based task runner for your
development projects to help you with those repetitive, menial, and mundane tasks
that are necessary for production readiness. This could be running unit tests, compiling
code, image processing, bundling and minification, and more. For our production deployments,
we commonly use Grunt to compile LESS into CSS, CoffeeScript into JavaScript, and
Jade into HTML, taking the code we write and preparing it for browser consumption.
We also use Grunt to optimize these various files for speed through bundling and minification.
The output of this work is done at deployment rather than development, with only the
source code committed into Git and never its optimized output.
&lt;/p&gt;
&lt;h3&gt;Git Deploy and Kudu
&lt;/h3&gt;
&lt;p&gt;
Continuous deployment will automatically update your site with the latest source code
whenever modifications are made to the source repository. This will also work with
Mercurial. There is plenty of existing documentation on &lt;a href="http://www.windowsazure.com/en-us/develop/nodejs/common-tasks/publishing-with-git/"&gt;setting
up Git Deploy in Azure&lt;/a&gt;, so consider that a prerequisite for this article. However,
Git Deploy, alone, will only take the files as they are in source, and directly deploy
them to the site. If you need to run additional tasks, such as compiling your .NET
source or running Grunt, that is where Kudu comes in.
&lt;/p&gt;
&lt;p&gt;
Kudu is the engine that drives Git deployments in Windows Azure. Untouched, it will
simply synchronize files from Git to your /wwwroot, but it can be easily reconfigured
to execute a deployment command, such as a Windows Command file, a Shell Script, or
a nodejs script. This is enabled through a standardized file named &amp;quot;.deployment&amp;quot;.
For Grunt deployment, we are going to execute a Shell Script that will perform npm,
Bower, and Grunt commands in an effort to make our code production-ready. For other
options on .deployment, check out the &lt;a href="https://github.com/projectkudu/kudu/wiki"&gt;Kudu
project wiki&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Kudu is also available locally for testing, and to help build out your deployment
scripts. The engine is available as a part of the cross-platform Windows Azure Command
Line Tools, available through npm.
&lt;/p&gt;
&lt;h4&gt;Installing the Azure CLI
&lt;/h4&gt;
&lt;pre class="plain:nocontrols" name="code"&gt;npm install azure-cli –-global&lt;/pre&gt;
&lt;p&gt;
We can also use the Azure CLI to generate default Kudu scripts for our nodejs project.
Though we will need to make a few modifications to make the scripts work with Grunt,
it will give us a good start.
&lt;/p&gt;
&lt;pre class="plain:nocontrols" name="code"&gt;azure site deploymentscript –-node&lt;/pre&gt;
&lt;p&gt;
This command will generate both our &amp;lt;code&amp;gt;.deployment&amp;lt;/code&amp;gt; and the default
&amp;lt;code&amp;gt;deploy.sh&amp;lt;/code&amp;gt;.
&lt;/p&gt;
&lt;h4&gt;Our .deployment file
&lt;/h4&gt;
&lt;pre class="plain" name="code"&gt;[config]
command = bash ./deploy.sh&lt;/pre&gt;
&lt;h3&gt;Customizing deploy.sh for Grunt Deployment
&lt;/h3&gt;
&lt;p&gt;
From &lt;code&gt;.deployment&lt;/code&gt;, Kudu will automatically execute our &lt;code&gt;deploy.sh&lt;/code&gt; script.
Kudu’s default &lt;code&gt;deploy.sh&lt;/code&gt; for a nodejs project will establish the environment
for node and npm as well as some supporting environment variables. It will also include
a &amp;quot;# Deployment&amp;quot; section containing all of the deployment steps. By default,
this will copy your repository contents to your /wwwroot, and then execute &lt;code&gt;npm
install --production&lt;/code&gt; against wwwroot, as if installing the application's operating
dependencies. However, under Grunt, we want to execute tasks prior to &lt;code&gt;/wwwroot&lt;/code&gt; deployment,
such as executing our Grunt tasks to compile LESS into CSS and CoffeeScript into JavaScript.
By replacing the entire Deployment section with the code below, we instruct Kudu to
perform the following tasks:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Get the latest changes from Git (or Hg). This is done automatically before running
deploy.sh. 
&lt;/li&gt;
&lt;li&gt;
Run &lt;code&gt;npm install&lt;/code&gt;, installing all dependencies, including those necessary
for development. 
&lt;/li&gt;
&lt;li&gt;
Optionally run &lt;code&gt;bower install&lt;/code&gt;, if bower.json exists. This will update
our client-side JavaScript libraries. 
&lt;/li&gt;
&lt;li&gt;
Optionally run &lt;code&gt;grunt&lt;/code&gt;, if Gruntfile.js exists. Below, I have grunt configured
to run the Clean, Common, and Dist tasks, which are LinemanJS's default tasks for
constructing a production-ready build. You can update the script to run whichever
tasks you need, or modify your Gruntfile to set these as the default tasks. 
&lt;/li&gt;
&lt;li&gt;
Finally, sync the contents of the prepared &lt;code&gt;/dist&lt;/code&gt; directory to &lt;code&gt;/wwwroot&lt;/code&gt;.
It is important to note that this is a KuduSync (similar to RSync), and not just a
copy. We only need to update the files that changed, which includes removing any obsolete
files. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;Our deploy.sh file's Deployment Section
&lt;/h4&gt;
&lt;pre class="plain:firstline[98]" name="code"&gt;# Deployment
# ----------

echo Handling node.js grunt deployment.

# 1. Select node version
selectNodeVersion

# 2. Install npm packages
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/package.json&amp;quot; ]; then
  eval $NPM_CMD install
  exitWithMessageOnError &amp;quot;npm failed&amp;quot;
fi

# 3. Install bower packages
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/bower.json&amp;quot; ]; then
  eval $NPM_CMD install bower
  exitWithMessageOnError &amp;quot;installing bower failed&amp;quot;
  ./node_modules/.bin/bower install
  exitWithMessageOnError &amp;quot;bower failed&amp;quot;
fi

# 4. Run grunt
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/Gruntfile.js&amp;quot; ]; then
  eval $NPM_CMD install grunt-cli
  exitWithMessageOnError &amp;quot;installing grunt failed&amp;quot;
  ./node_modules/.bin/grunt --no-color clean common dist
  exitWithMessageOnError &amp;quot;grunt failed&amp;quot;
fi

# 5. KuduSync to Target
&amp;quot;$KUDU_SYNC_CMD&amp;quot; -v 500 -f &amp;quot;$DEPLOYMENT_SOURCE/dist&amp;quot; -t &amp;quot;$DEPLOYMENT_TARGET&amp;quot; -n &amp;quot;$NEXT_MANIFEST_PATH&amp;quot; -p &amp;quot;$PREVIOUS_MANIFEST_PATH&amp;quot; -i &amp;quot;.git;.hg;.deployment;deploy.sh&amp;quot;
exitWithMessageOnError &amp;quot;Kudu Sync to Target failed&amp;quot;&lt;/pre&gt;
&lt;p&gt;
These commands will execute bower and Grunt from local npm installations, rather than
the global space, as Windows Azure does not allow easy access to global installations.
Because bower and Grunt are manually installed based on the existence of bower.json
or Gruntfile.js, they also are not required to be referenced in your own package.json.
Finally, be sure to leave the –no-color flag enabled for Grunt execution, as the Azure
Deployment Logs will stumble when processing the ANSI color codes that are common
on Grunt output.
&lt;/p&gt;
&lt;p&gt;
Assuming that Git Deployment has already been configured, committing these files in
to Git will complete the process. Because the latest changes from Git are pulled before
executing the deployment steps, these two new files (&lt;code&gt;.deployment&lt;/code&gt; and &lt;code&gt;deploy.sh&lt;/code&gt;)
will be available when Kudu is ready for them.
&lt;/p&gt;
&lt;h3&gt;Troubleshooting
&lt;/h3&gt;
&lt;h4&gt;Long Directory Paths and the 260-Character Path Limit
&lt;/h4&gt;
&lt;p&gt;
Though Azure does a fantastic job of hosting nodejs projects, at the end of the day
Azure is still hosted on the Windows platform, and brings with it Windows limitations.
One of the issues that you will quickly run into under node is the &lt;a href="http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx#maxpath"&gt;260-Character
Path Limitation&lt;/a&gt;. Under nodejs, the dependency tree for a node modules can get
rather deep. And because each dependency module loads up its own dependency modules
under its child folder structure, the folder structure can get rather deep, too. For
example, Lineman requires Testem, which requires Winston, which requires Request;
in the end, the directory tree can lead to ~/node_modules/lineman/node_modules/testem/node_modules/winston/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream,
which combined with the root path structure, can far exceed the 260 limit.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Workaround&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
To reduce this nesting, make some of these dependencies into first-level dependencies.
With the nodejs dependency model, if a module has already been brought in at a higher
level, it is not repeated in the chain. Thus, if Request is made as a direct dependency
and listed in your project's project.json, it will no longer be nested under Winston,
splitting this single dependency branch in two:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
~/node_modules/lineman/node_modules/testem/node_modules/winston 
&lt;/li&gt;
&lt;li&gt;
~/node_modules/request/node_modules/form-data/node_modules/combined-stream/node_modules/delayed-stream 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
This is not ideal, but it will solve is a workaround for the Windows file structure
limitations. The element that you must be careful of is with dependency versioning,
as you will need to make sure your &lt;code&gt;package.json&lt;/code&gt; references the appropriate
version of your pseudo-dependency; in this case, make sure your &lt;code&gt;package.json&lt;/code&gt; references
the same version of Request as is referenced by Winston.
&lt;/p&gt;
&lt;p&gt;
To help find those deep dependencies, use &lt;code&gt;npm list&lt;/code&gt;. It will show you
the full graph on the command line, supplying a handy visual indicator.
&lt;/p&gt;
&lt;h4&gt;__dirname vs Process.cwd()
&lt;/h4&gt;
&lt;p&gt;
In the node ecosystem, &lt;code&gt;Process.cwd()&lt;/code&gt; is the current working directory
for the node process. There is also a common variable named &lt;code&gt;__dirname&lt;/code&gt; that
is created by node; its value is the directory that contained your node script. If
you executed node against a script in the current working directory, then these values
should be the same. Except when they aren't, like in Windows Azure.
&lt;/p&gt;
&lt;p&gt;
In Windows Azure, everything is executed on the system drive, C:. Node and npm live
here, and it appears as though your deployment space does as well. However, this deployment
space is really a mapped directory, coming in from a network share where your files
are persisted. In Azure's node ecosystem, this means that your &lt;code&gt;Process.cwd()&lt;/code&gt; is
the C-rooted path, while &lt;code&gt;__dirname&lt;/code&gt; is the \\10.whatever-rooted UNC path
to your persisted files. Some Grunt-based tools and plugins (including Lineman) will
fail because that it will reference &lt;code&gt;__dirname&lt;/code&gt; files while Grunt's core
is attempting to run tasks with the scope of &lt;code&gt;Process.cwd()&lt;/code&gt;; Grunt recognizes
that it's trying to take action on \\10.whatever-rooted files in a C-rooted scope,
and fails because the files are not in a child directory.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Workaround&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
If you are encountering this issue, reconfigure Grunt to work in the \\10.whatever-rooted
scope. You can do this by setting it's base path to &lt;code&gt;__dirname&lt;/code&gt;, overriding
the default &lt;code&gt;Process.cwd()&lt;/code&gt;. Within your Gruntfile.js, set the base path
immediately within your module export:
&lt;/p&gt;
&lt;pre class="jscript" name="code"&gt;module.exports = function (grunt) {
  grunt.file.setBase(__dirname);
  // Code omitted
}&lt;/pre&gt;
&lt;h4&gt;Unable to find environment variable LINEMAN_MAIN
&lt;/h4&gt;
&lt;p&gt;
If like me, you are using Lineman to build your applications, you will encounter this
issue. Lineman manages Grunt and its configuration, so it prefers that all Grunt tasks
are executed via the Lineman CLI rather than directly executed via the Grunt CLI.
Lineman's Gruntfile.js includes a reference to an environment variable LINEMAN_MAIN,
set by the Lineman CLI, so that Grunt will run under the context of the proper Lineman
installation, which is what causes the failure if Grunt is executed directly.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Fix (Because this isn't a hack)&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
Your development cycle has been configured to use lineman, so your deployment cycle
should use it, too! Update your &lt;code&gt;deploy.sh&lt;/code&gt; Grunt execution to run Lineman
instead of Grunt. Also, since Lineman is referenced in your package.json, we don't
need to install it; it is already there.
&lt;/p&gt;
&lt;p&gt;
Option 1: deploy.sh
&lt;/p&gt;
&lt;pre class="plain:firstline[120]" name="code"&gt;# 4. Run grunt
if [ -e &amp;quot;$DEPLOYMENT_SOURCE/Gruntfile.js&amp;quot; ]; then
  ./node_modules/.bin/lineman --no-color grunt clean common dist
  exitWithMessageOnError &amp;quot;lineman failed&amp;quot;
fi&lt;/pre&gt;
&lt;p&gt;
Recommendation: Since Lineman is wrapping Grunt for all of its tasks, consider simplifying &lt;code&gt;lineman
grunt clean common dist&lt;/code&gt; into &lt;code&gt;lineman clean build&lt;/code&gt;. You will still
need the &lt;code&gt;--no-color&lt;/code&gt; flag, so that Grunt will not use ANSI color codes. 
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;The Alternate Workaround&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
If you don't want to change your &lt;code&gt;deploy.sh&lt;/code&gt;—perhaps because you want to
maintain the generic file to handle all things Grunt—then as an alternative you can
update your &lt;code&gt;Gruntfile.js&lt;/code&gt; to specify a default value for the missing &lt;code&gt;LINEMAN_MAIN&lt;/code&gt; environment
variable. This environment variable is just a string value passed in to node's require
function, so that the right Lineman module can be loaded. Since Lineman is already
included in your &lt;code&gt;package.json&lt;/code&gt;, it will already be available in the local &lt;code&gt;/node_modules&lt;/code&gt; folder
because of the earlier &lt;code&gt;npm install&lt;/code&gt; (deploy.sh, Step #2), and we can pass
'lineman' into &lt;code&gt;require( )&lt;/code&gt; to have Grunt load the local Lineman installation.
Lineman will then supply its configuration into Grunt, and the system will proceed
as if you executed Lineman directly.
&lt;/p&gt;
&lt;p&gt;
Option 2: Gruntfile.js
&lt;/p&gt;
&lt;pre class="jscript" name="code"&gt;module.exports = function(grunt) {
  grunt.file.setBase(__dirname);
  if (process.env['LINEMAN_MAIN'] === null || process.env['LINEMAN_MAIN'] === undefined) {
    process.env['LINEMAN_MAIN'] = 'lineman';
  }
  require(process.env['LINEMAN_MAIN']).config.grunt.run(grunt);
};&lt;/pre&gt;
&lt;h3&gt;Credits
&lt;/h3&gt;
&lt;p&gt;
Thank you to &lt;a href="http://www.twitter.com/davidebbo"&gt;@davidebbo&lt;/a&gt;, &lt;a href="http://www.twitter.com/guayan"&gt;@guayan&lt;/a&gt;, &lt;a href="http://www.twitter.com/amitapl"&gt;@amitapl&lt;/a&gt;,
and &lt;a href="http://www.twitter.com/dburton"&gt;@dburton&lt;/a&gt; for helping troubleshoot
Kudu and Grunt Deploy, making this all possible.
&lt;/p&gt;
&lt;h3&gt;Changelog
&lt;/h3&gt;
&lt;p&gt;
2013-12-03: Updated LINEMAN_MAIN Troubleshooting to improve resolution. Rather than
editing deploy.sh to set the environment variable, edit the file to execute Lineman.
This is the proper (and more elegant) solution. [Credit: &lt;a href="http://www.twitter.com/searls"&gt;@searls&lt;/a&gt;]
&lt;/p&gt;
&lt;div id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9b0ba700-7d7e-41fe-8c1b-8c35f6d0d010" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/Grunt" rel="tag"&gt;Grunt&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Lineman" rel="tag"&gt;Lineman&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Node" rel="tag"&gt;Node&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Azure" rel="tag"&gt;Azure&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Git" rel="tag"&gt;Git&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,1a39fd38-1ee4-4c7d-85fd-4b10cb7ea54d.aspx</comments>
      <category>Azure</category>
      <category>Continuous Integration</category>
      <category>JavaScript</category>
      <category>Programming</category>
      <category>Task Automation</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=e1276750-40c4-46ca-9045-c0e3d7573fb5</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,e1276750-40c4-46ca-9045-c0e3d7573fb5.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,e1276750-40c4-46ca-9045-c0e3d7573fb5.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e1276750-40c4-46ca-9045-c0e3d7573fb5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Scheduled Integration is hard. I remember being involved in projects where developers
would get a copy of the latest source code and a task, and race off like horses at
the track while they spent a few weeks implementing their assigned feature. At the
end of these many weeks was a scheduled integration, where all developers in the team
would reconvene with their code modifications, and try to get their respective code
to play well in a single sandbox. Project managers always seemed to expect that this
would be a quick and painless process, but, of course, it never was. Reintegration
of the code sometimes took just as long as the implementation, itself. Even if developers
are all working in one big room throughout the project, the code remains isolated,
never shared or reintegrated. Fortunately, Continuous Integration specifically focuses
on this problem by reducing (and often eliminating) the end-of-project reintegration
cycle through a continuous constant integration process.
</p>
        <h3>Continuously Integrating your Mind
</h3>
        <p>
For a moment, compare  the process of software development with the process of
learning new technologies in your field. In the past few years of Microsoft's .NET
platform, we've seen .NET 2.0, Windows Communication Foundation, Windows Presentation
Foundation, Workflow Foundation, Extension Methods, Generics, Linq, Dynamic Data,
ASP.NET MVC, and more. For a developer that has not kept up with the latest trends,
to suddenly and quickly catch up with the bleeding edge would be a major undertaking,
and psychologically intimidating. This Scheduled Integration approach to learning
can be overwhelming; the learning process is isolated, and only occasionally reconnects
to the latest technologies. However, a developer that has kept up with the trends,
learning through a continuous integration process, has been constantly updating, constantly
learning the Next Big Thing over these past few years; this developer is already long
familiar with .NET 2.0, WF, WCF, WPF, Generics, and Linq, and is now working on only
Dynamic Data and MVC. The Continuous Integration process ensures that those involved
are current with the latest developments in their project, and that the overwhelming
burden of integration at the end of a project is instead simplified by distributing
it throughout the course of the timeline.
</p>
        <h3>Core Continuous Integration
</h3>
        <p>
At its core, Continuous Integration, or CI, is a development model where developers
regularly commit and update against their source control repository. By committing
(giving everyone else access to your code changes) and updating (getting code changes
from everyone else), the scheduled, tedious integration process at the end of the
project is eliminated. Added on top of this single fundamental, is ensuring the code
works: Automating the build through scripting frameworks like Make, MSBuild, or NAnt
helps developers validate their status quickly, by invoking a validation step that
not only compiles, but executes a suite of unit tests against the code base. Validation
results, along with the latest valid code, are then made easily accessible to anyone
on the team.
</p>
        <p>
The ten tenets of Continuous Integration are:
</p>
        <ol>
          <li>
            <strong>Maintain a Source Code Repository</strong>
            <br />
Use a code repository, such as Subversion, Bazaar, or even Visual Source Safe. This
allows a central point-of-truth for the development team, against which code can be
committed or updated. This even applies to a development team consisting of only one
person, as a local hard drive alone cannot provide change logs, revision differences,
rollback capability, and other benefits of source management. 
</li>
          <li>
            <strong>Commit Frequently</strong>
            <br />
As other developers commit code changes, your local version of the code will get further
and further from the revision head, thus increasing the likelihood of a conflicting
change that will need manual resolution. By committing often (and by association,
updating even more often), everyone can stay very close to the revision head, reducing
the likelihood of conflicts, and reducing time to integrate code and functionality. 
</li>
          <li>
            <strong>Self-Testing Code<br /></strong>"It compiles" is not sufficient criteria for determining if a project is
ready for delivery or deployment to the client. Some level of testing must be conducted
against each compile to measure application quality. Using unit tests, functional
tests, or some other form of automated acceptance tests, the code can evaluate itself
against expected outcome, providing a much more accurate and granular metric for readiness. 
</li>
          <li>
            <strong>Automate the Build</strong>
            <br />
Using Make, NAnt, MSBuild, or similar frameworks, consolidate execution of your full
build into a single command, or a single icon on your desktop. These scripts should
execute a full compile, and run your full suite of testing and evaluation tools against
the compile. 
</li>
          <li>
            <strong>Build Fast, Fail Fast<br /></strong>Even if your build is automated, no one wants to wait 30 minutes for the
build to complete. Building your code should not just be a lunch-break activity. Keep
the build fast to enable developers to do so as often as possible. And if there is
a problem, fail immediately. 
</li>
          <li>
            <strong>Build Every Mainline Commit on an Integration Machine<br /></strong>We all have applications on our local desktops that will not be present in
Production. Instant Messenger, iTunes, Visual Studio, and Office are all common for
us, but rare in Production. However, these applications can conflict or distort build
results, such as a reference to an Office assembly that is not included in your deployment
package. By executing the automated build on an integration machine (iTunes free,
and using a CI suite like Hudson or CruiseControl), you can increase confidence in
your application and eliminate "it works on my box!" 
</li>
          <li>
            <strong>Automate the Deployment<br /></strong>Manual code deployment is a mundane, highly repetitive, error-prone, and
time-consuming process that is ripe for automation. The time commitment adds to the
stress when QA requests yet another deployment to the testing environment, particularly
when all of the developers are in 80-hour-week crunch mode. In turn, this stress reduces
deployment quality; environments often have configuration differences, such as different
database connection strings, credentials, or web service URLs, and often only one
configuration change needs to be overlooked to cause the entire system to malfunction.
Automate this task, so that it can be executed easily, dependably, and often. 
</li>
          <li>
            <strong>Test in a Clone of the Production Environment<br /></strong>In addition to Office and iTunes not being a part of the production server
build, there are aspects of the production environment that are not a part of the
desktop environment. Server farms, federated databases, and load balancing are examples
of things that <em>do not</em> exist on the developer desktop, but <em>do</em> exist
in production, and can cause surprises if they are not considered during development
and testing. Consider the <em>haves</em> and the <em>have-nots</em> in your test environment,
and eliminate these surprises. And if the cost of another production environment is
out of reach, consider Virtual Machines. VMs have significantly reduced the cost of
creating a <a href="http://www.cptloadtest.com/2005/05/25/AWateredDownTestEnvironment.aspx">watered
down test environment</a> that still has things like server farms or database clusters;
even if you cannot exactly replicate your production configuration, mitigate your
risk by reducing the differences between your test and production environments. 
</li>
          <li>
            <strong>Everyone Can View the Latest Build Results<br /></strong>The underlying driver behind Continuous Integration is transparency and visibility.
Communication enables both transparency and visibility by allowing everyone on the
team to know the full status of the build. Did it compile? Did the unit tests pass?
Which unit tests failed? Did the deployment work? How many seconds did it take to
compile the application? Who broke the build? Continuous Integration suites, such
as Hudson or CruiseControl, provide reporting mechanisms on build status. Make this
status available to anyone, including project managers, and even the sales guy. 
</li>
          <li>
            <strong>Everyone Can Get the Latest Executable<br /></strong>On a software development project, communication is more than just green
icons (successful builds) and red icons (failed builds). Communicate the ones and
zeros, in the form of your compiled application, to your team. By allowing other developers,
testers, and even the sales guy (perhaps for a demo) to get the latest bits for themselves,
developers can focus on writing code.</li>
        </ol>
        <h3>Benefits of Continuous Integration
</h3>
        <p>
By continuously integrating all new code and feature sets, development teams can eliminate
that long and tedious scheduled integration effort, which reduces overall effort,
time line, and budget. Through self-testing code and building every mainline commit,
code is continuously tested against a full suite of tests, allowing quick analysis
and identification of breaking changes. Through the easy accessibility of the latest
bits, the team can test early and often, allowing quick identification of broken functionality,
and for early identification of features that don't quite align with what the client
had in mind. And finally, the immediate and public feedback on the success or failure
of the build provides incentives for developers to write code in smaller increments
and perform more pre-commit testing, resulting in higher quality code.
</p>
        <p>
I consider Continuous Integration to be an essential, required part of any development
effort, every time. I started using CI in 2004, and I have since become dependent
on it. I even have a Continuous Integration box at home, validating home projects
for my development-team-of-one, and I am comforted by having a Continuous Integration
server analyzing and validating every code change that I make. I break unit tests
as often as anyone else does, and there still continues to be plenty of times that
I even break the compile. At least once, every developer among us has checked in the
project file while forgetting to add <em>myNewClass.cs</em> to Source Control. It
will break the compile every time. Fortunately, Continuous Integration is always watching
my code commits; it will let me know that it could not find <em>myNewClass.cs</em>,
every time. And my application's quality is remarkably better for it. Every time.
</p>
        <div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f66bf28d-3c0c-4374-a537-abb6c7571de2" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px">Technorati
Tags: <a href="http://technorati.com/tags/CI" rel="tag">CI</a>,<a href="http://technorati.com/tags/Continuous%20Integration" rel="tag">Continuous
Integration</a>,<a href="http://technorati.com/tags/Developer%20Basics" rel="tag">Developer
Basics</a></div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=e1276750-40c4-46ca-9045-c0e3d7573fb5" />
      </body>
      <title>Dev Basics: What is Continuous Integration?</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,e1276750-40c4-46ca-9045-c0e3d7573fb5.aspx</guid>
      <link>http://www.cptloadtest.com/2009/04/02/Dev-Basics-What-Is-Continuous-Integration.aspx</link>
      <pubDate>Thu, 02 Apr 2009 00:25:01 GMT</pubDate>
      <description>&lt;p&gt;
Scheduled Integration is hard. I remember being involved in projects where developers
would get a copy of the latest source code and a task, and race off like horses at
the track while they spent a few weeks implementing their assigned feature. At the
end of these many weeks was a scheduled integration, where all developers in the team
would reconvene with their code modifications, and try to get their respective code
to play well in a single sandbox. Project managers always seemed to expect that this
would be a quick and painless process, but, of course, it never was. Reintegration
of the code sometimes took just as long as the implementation, itself. Even if developers
are all working in one big room throughout the project, the code remains isolated,
never shared or reintegrated. Fortunately, Continuous Integration specifically focuses
on this problem by reducing (and often eliminating) the end-of-project reintegration
cycle through a continuous constant integration process.
&lt;/p&gt;
&lt;h3&gt;Continuously Integrating your Mind
&lt;/h3&gt;
&lt;p&gt;
For a moment, compare&amp;nbsp; the process of software development with the process of
learning new technologies in your field. In the past few years of Microsoft's .NET
platform, we've seen .NET 2.0, Windows Communication Foundation, Windows Presentation
Foundation, Workflow Foundation, Extension Methods, Generics, Linq, Dynamic Data,
ASP.NET MVC, and more. For a developer that has not kept up with the latest trends,
to suddenly and quickly catch up with the bleeding edge would be a major undertaking,
and psychologically intimidating. This Scheduled Integration approach to learning
can be overwhelming; the learning process is isolated, and only occasionally reconnects
to the latest technologies. However, a developer that has kept up with the trends,
learning through a continuous integration process, has been constantly updating, constantly
learning the Next Big Thing over these past few years; this developer is already long
familiar with .NET 2.0, WF, WCF, WPF, Generics, and Linq, and is now working on only
Dynamic Data and MVC. The Continuous Integration process ensures that those involved
are current with the latest developments in their project, and that the overwhelming
burden of integration at the end of a project is instead simplified by distributing
it throughout the course of the timeline.
&lt;/p&gt;
&lt;h3&gt;Core Continuous Integration
&lt;/h3&gt;
&lt;p&gt;
At its core, Continuous Integration, or CI, is a development model where developers
regularly commit and update against their source control repository. By committing
(giving everyone else access to your code changes) and updating (getting code changes
from everyone else), the scheduled, tedious integration process at the end of the
project is eliminated. Added on top of this single fundamental, is ensuring the code
works: Automating the build through scripting frameworks like Make, MSBuild, or NAnt
helps developers validate their status quickly, by invoking a validation step that
not only compiles, but executes a suite of unit tests against the code base. Validation
results, along with the latest valid code, are then made easily accessible to anyone
on the team.
&lt;/p&gt;
&lt;p&gt;
The ten tenets of Continuous Integration are:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Maintain a Source Code Repository&lt;/strong&gt;
&lt;br&gt;
Use a code repository, such as Subversion, Bazaar, or even Visual Source Safe. This
allows a central point-of-truth for the development team, against which code can be
committed or updated. This even applies to a development team consisting of only one
person, as a local hard drive alone cannot provide change logs, revision differences,
rollback capability, and other benefits of source management. 
&lt;li&gt;
&lt;strong&gt;Commit Frequently&lt;/strong&gt;
&lt;br&gt;
As other developers commit code changes, your local version of the code will get further
and further from the revision head, thus increasing the likelihood of a conflicting
change that will need manual resolution. By committing often (and by association,
updating even more often), everyone can stay very close to the revision head, reducing
the likelihood of conflicts, and reducing time to integrate code and functionality. 
&lt;li&gt;
&lt;strong&gt;Self-Testing Code&lt;br&gt;
&lt;/strong&gt;"It compiles" is not sufficient criteria for determining if a project is
ready for delivery or deployment to the client. Some level of testing must be conducted
against each compile to measure application quality. Using unit tests, functional
tests, or some other form of automated acceptance tests, the code can evaluate itself
against expected outcome, providing a much more accurate and granular metric for readiness. 
&lt;li&gt;
&lt;strong&gt;Automate the Build&lt;/strong&gt;
&lt;br&gt;
Using Make, NAnt, MSBuild, or similar frameworks, consolidate execution of your full
build into a single command, or a single icon on your desktop. These scripts should
execute a full compile, and run your full suite of testing and evaluation tools against
the compile. 
&lt;li&gt;
&lt;strong&gt;Build Fast, Fail Fast&lt;br&gt;
&lt;/strong&gt;Even if your build is automated, no one wants to wait 30 minutes for the
build to complete. Building your code should not just be a lunch-break activity. Keep
the build fast to enable developers to do so as often as possible. And if there is
a problem, fail immediately. 
&lt;li&gt;
&lt;strong&gt;Build Every Mainline Commit on an Integration Machine&lt;br&gt;
&lt;/strong&gt;We all have applications on our local desktops that will not be present in
Production. Instant Messenger, iTunes, Visual Studio, and Office are all common for
us, but rare in Production. However, these applications can conflict or distort build
results, such as a reference to an Office assembly that is not included in your deployment
package. By executing the automated build on an integration machine (iTunes free,
and using a CI suite like Hudson or CruiseControl), you can increase confidence in
your application and eliminate "it works on my box!" 
&lt;li&gt;
&lt;strong&gt;Automate the Deployment&lt;br&gt;
&lt;/strong&gt;Manual code deployment is a mundane, highly repetitive, error-prone, and
time-consuming process that is ripe for automation. The time commitment adds to the
stress when QA requests yet another deployment to the testing environment, particularly
when all of the developers are in 80-hour-week crunch mode. In turn, this stress reduces
deployment quality; environments often have configuration differences, such as different
database connection strings, credentials, or web service URLs, and often only one
configuration change needs to be overlooked to cause the entire system to malfunction.
Automate this task, so that it can be executed easily, dependably, and often. 
&lt;li&gt;
&lt;strong&gt;Test in a Clone of the Production Environment&lt;br&gt;
&lt;/strong&gt;In addition to Office and iTunes not being a part of the production server
build, there are aspects of the production environment that are not a part of the
desktop environment. Server farms, federated databases, and load balancing are examples
of things that &lt;em&gt;do not&lt;/em&gt; exist on the developer desktop, but &lt;em&gt;do&lt;/em&gt; exist
in production, and can cause surprises if they are not considered during development
and testing. Consider the &lt;em&gt;haves&lt;/em&gt; and the &lt;em&gt;have-nots&lt;/em&gt; in your test environment,
and eliminate these surprises. And if the cost of another production environment is
out of reach, consider Virtual Machines. VMs have significantly reduced the cost of
creating a &lt;a href="http://www.cptloadtest.com/2005/05/25/AWateredDownTestEnvironment.aspx"&gt;watered
down test environment&lt;/a&gt; that still has things like server farms or database clusters;
even if you cannot exactly replicate your production configuration, mitigate your
risk by reducing the differences between your test and production environments. 
&lt;li&gt;
&lt;strong&gt;Everyone Can View the Latest Build Results&lt;br&gt;
&lt;/strong&gt;The underlying driver behind Continuous Integration is transparency and visibility.
Communication enables both transparency and visibility by allowing everyone on the
team to know the full status of the build. Did it compile? Did the unit tests pass?
Which unit tests failed? Did the deployment work? How many seconds did it take to
compile the application? Who broke the build? Continuous Integration suites, such
as Hudson or CruiseControl, provide reporting mechanisms on build status. Make this
status available to anyone, including project managers, and even the sales guy. 
&lt;li&gt;
&lt;strong&gt;Everyone Can Get the Latest Executable&lt;br&gt;
&lt;/strong&gt;On a software development project, communication is more than just green
icons (successful builds) and red icons (failed builds). Communicate the ones and
zeros, in the form of your compiled application, to your team. By allowing other developers,
testers, and even the sales guy (perhaps for a demo) to get the latest bits for themselves,
developers can focus on writing code.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Benefits of Continuous Integration
&lt;/h3&gt;
&lt;p&gt;
By continuously integrating all new code and feature sets, development teams can eliminate
that long and tedious scheduled integration effort, which reduces overall effort,
time line, and budget. Through self-testing code and building every mainline commit,
code is continuously tested against a full suite of tests, allowing quick analysis
and identification of breaking changes. Through the easy accessibility of the latest
bits, the team can test early and often, allowing quick identification of broken functionality,
and for early identification of features that don't quite align with what the client
had in mind. And finally, the immediate and public feedback on the success or failure
of the build provides incentives for developers to write code in smaller increments
and perform more pre-commit testing, resulting in higher quality code.
&lt;/p&gt;
&lt;p&gt;
I consider Continuous Integration to be an essential, required part of any development
effort, every time. I started using CI in 2004, and I have since become dependent
on it. I even have a Continuous Integration box at home, validating home projects
for my development-team-of-one, and I am comforted by having a Continuous Integration
server analyzing and validating every code change that I make. I break unit tests
as often as anyone else does, and there still continues to be plenty of times that
I even break the compile. At least once, every developer among us has checked in the
project file while forgetting to add &lt;em&gt;myNewClass.cs&lt;/em&gt; to Source Control. It
will break the compile every time. Fortunately, Continuous Integration is always watching
my code commits; it will let me know that it could not find &lt;em&gt;myNewClass.cs&lt;/em&gt;,
every time. And my application's quality is remarkably better for it. Every time.
&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:f66bf28d-3c0c-4374-a537-abb6c7571de2" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati
Tags: &lt;a href="http://technorati.com/tags/CI" rel="tag"&gt;CI&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Continuous%20Integration" rel="tag"&gt;Continuous
Integration&lt;/a&gt;,&lt;a href="http://technorati.com/tags/Developer%20Basics" rel="tag"&gt;Developer
Basics&lt;/a&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=e1276750-40c4-46ca-9045-c0e3d7573fb5" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,e1276750-40c4-46ca-9045-c0e3d7573fb5.aspx</comments>
      <category>Continuous Integration</category>
      <category>Dev Basics</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=4b3788f6-ca50-4247-bf7d-d843b01c72f4</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,4b3788f6-ca50-4247-bf7d-d843b01c72f4.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,4b3788f6-ca50-4247-bf7d-d843b01c72f4.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=4b3788f6-ca50-4247-bf7d-d843b01c72f4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div>Tomorrow night, Wednesday, 08 October, I will be speaking at the <a href="http://www.aadnd.org/">Ann
Arbor Dot Net Developers</a> meeting. We will be discussing Continuous Integration,
focusing on CI as a process, not just a toolset. Come out to Ann Arbor, enjoy some
pizza, and hear about what Continuous Integration can do for your development cycle.
</div>
        <blockquote>
          <b>Continuous Integration: It's more than just a toolset<br /></b>Wednesday, 08 October, 2008 @ 6:00pm<br />
SRT Solutions<br />
206 South Fifth Ave, Suite 200<br />
Ann Arbor, MI 48104</blockquote>
        <h3>Session Abstract:
</h3>
        <div>Does your team spend days integrating code at the end of a project? Continuous
Integration can help. Using Continuous Integration will eliminate that end-of-project
integration stress, and at the same time will make your development process easier.
But Continuous Integration is more than just a tool like CruiseControl.Net; it is
a full development process designed to bring you closer to your mainline, increase
visibility of project status throughout your team, and to streamline deployments to
QA or to your client. Find out what Continuous Integration is all about, and what
it can do for you.
</div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=4b3788f6-ca50-4247-bf7d-d843b01c72f4" />
      </body>
      <title>Speaking at AADND on CI, 08-Oct-08</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,4b3788f6-ca50-4247-bf7d-d843b01c72f4.aspx</guid>
      <link>http://www.cptloadtest.com/2008/10/07/Speaking-At-AADND-On-CI-08Oct08.aspx</link>
      <pubDate>Tue, 07 Oct 2008 17:45:27 GMT</pubDate>
      <description>&lt;div&gt;Tomorrow night, Wednesday, 08 October, I will be speaking at the &lt;a href="http://www.aadnd.org/"&gt;Ann
Arbor Dot Net Developers&lt;/a&gt; meeting. We will be discussing Continuous Integration,
focusing on CI as a process, not just a toolset. Come out to Ann Arbor, enjoy some
pizza, and hear about what Continuous Integration can do for your development cycle.
&lt;/div&gt;
&lt;blockquote&gt;&lt;b&gt;Continuous Integration: It's more than just a toolset&lt;br&gt;
&lt;/b&gt;Wednesday, 08 October, 2008 @ 6:00pm&lt;br&gt;
SRT Solutions&lt;br&gt;
206 South Fifth Ave, Suite 200&lt;br&gt;
Ann Arbor, MI 48104&lt;/blockquote&gt; 
&lt;h3&gt;Session Abstract:
&lt;/h3&gt;
&lt;div&gt;Does your team spend days integrating code at the end of a project? Continuous
Integration can help. Using Continuous Integration will eliminate that end-of-project
integration stress, and at the same time will make your development process easier.
But Continuous Integration is more than just a tool like CruiseControl.Net; it is
a full development process designed to bring you closer to your mainline, increase
visibility of project status throughout your team, and to streamline deployments to
QA or to your client. Find out what Continuous Integration is all about, and what
it can do for you.
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=4b3788f6-ca50-4247-bf7d-d843b01c72f4" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,4b3788f6-ca50-4247-bf7d-d843b01c72f4.aspx</comments>
      <category>Continuous Integration</category>
      <category>Events</category>
      <category>Speaking</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=1aac1a2a-ed95-4fe9-94fe-cfba2a997809</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,1aac1a2a-ed95-4fe9-94fe-cfba2a997809.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,1aac1a2a-ed95-4fe9-94fe-cfba2a997809.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1aac1a2a-ed95-4fe9-94fe-cfba2a997809</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div>Tomorrow night, Thursday, 11 September, I will be speaking at the <a href="http://www.glugnet.org">GLUGnet</a> Flint
meeting. We will be discussing Continuous Integration, focusing on CI as a process,
not just a toolset. Come out to Flint, enjoy some pizza, and hear about what Continuous
Integration can do for your development cycle.
</div>
        <blockquote>
          <b>Continuous Integration: It's more than just a toolset<br /></b>Thursday, 11 September, 2008 @ 6:00pm<br />
New Horizons<br />
4488 West Bristol Road<br />
Flint, MI 48507</blockquote>
        <h3>Session Abstract:
</h3>
        <div>Does your team spend days integrating code at the end of a project? Continuous
Integration can help. Using Continuous Integration will eliminate that end-of-project
integration stress, and at the same time will make your development process easier.
But Continuous Integration is more than just a tool like CruiseControl.Net; it is
a full development process designed to bring you closer to your mainline, increase
visibility of project status throughout your team, and to streamline deployments to
QA or to your client. Find out what Continuous Integration is all about, and what
it can do for you.
</div>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=1aac1a2a-ed95-4fe9-94fe-cfba2a997809" />
      </body>
      <title>Speaking at GLUGnet Flint on CI, 11-Sep-08</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,1aac1a2a-ed95-4fe9-94fe-cfba2a997809.aspx</guid>
      <link>http://www.cptloadtest.com/2008/09/10/Speaking-At-GLUGnet-Flint-On-CI-11Sep08.aspx</link>
      <pubDate>Wed, 10 Sep 2008 19:07:26 GMT</pubDate>
      <description>&lt;div&gt;Tomorrow night, Thursday, 11 September, I will be speaking at the &lt;a href="http://www.glugnet.org"&gt;GLUGnet&lt;/a&gt; Flint
meeting. We will be discussing Continuous Integration, focusing on CI as a process,
not just a toolset. Come out to Flint, enjoy some pizza, and hear about what Continuous
Integration can do for your development cycle.
&lt;/div&gt;
&lt;blockquote&gt;&lt;b&gt;Continuous Integration: It's more than just a toolset&lt;br&gt;
&lt;/b&gt;Thursday, 11 September, 2008 @ 6:00pm&lt;br&gt;
New Horizons&lt;br&gt;
4488 West Bristol Road&lt;br&gt;
Flint, MI 48507&lt;/blockquote&gt; 
&lt;h3&gt;Session Abstract:
&lt;/h3&gt;
&lt;div&gt;Does your team spend days integrating code at the end of a project? Continuous
Integration can help. Using Continuous Integration will eliminate that end-of-project
integration stress, and at the same time will make your development process easier.
But Continuous Integration is more than just a tool like CruiseControl.Net; it is
a full development process designed to bring you closer to your mainline, increase
visibility of project status throughout your team, and to streamline deployments to
QA or to your client. Find out what Continuous Integration is all about, and what
it can do for you.
&lt;/div&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=1aac1a2a-ed95-4fe9-94fe-cfba2a997809" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,1aac1a2a-ed95-4fe9-94fe-cfba2a997809.aspx</comments>
      <category>Continuous Integration</category>
      <category>Events</category>
      <category>Speaking</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
CruiseControl.Net 1.3 was <a href="http://confluence.public.thoughtworks.org/display/CCNET/2007/06/21/CruiseControl.NET+1.3+Released">released</a> this
morning. To me, most important was the new Build Queue functionality, stopping multiple
projects from building at the same time. If ProjectB depends on ProjectA, and they
both get code changes committed at the same time, they will fail from contention.
Either ProjectA will fail because it can’t delete its old assemblies (because ProjectB
has a lock on them) or ProjectB will fail because it can’t find the ProjectA assemblies
(because ProjectA deleted them in its rebuild).
</p>
        <p>
No more.
</p>
        <p>
I’m so excited that I am already upgrading our servers!
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a" />
      </body>
      <title>CruiseControl.Net 1.3 Released</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a.aspx</guid>
      <link>http://www.cptloadtest.com/2007/06/23/CruiseControlNet-13-Released.aspx</link>
      <pubDate>Sat, 23 Jun 2007 02:19:30 GMT</pubDate>
      <description>&lt;p&gt;
CruiseControl.Net 1.3 was &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/2007/06/21/CruiseControl.NET+1.3+Released"&gt;released&lt;/a&gt; this
morning. To me, most important was the new Build Queue functionality, stopping multiple
projects from building at the same time. If ProjectB depends on ProjectA, and they
both get code changes committed at the same time, they will fail from contention.
Either ProjectA will fail because it can’t delete its old assemblies (because ProjectB
has a lock on them) or ProjectB will fail because it can’t find the ProjectA assemblies
(because ProjectA deleted them in its rebuild).
&lt;/p&gt;
&lt;p&gt;
No more.
&lt;/p&gt;
&lt;p&gt;
I’m so excited that I am already upgrading our servers!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,cb1c56a9-80c4-422a-9ce1-3edf3fe40c8a.aspx</comments>
      <category>Continuous Integration</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=b2373965-3820-4cfe-9faf-7b725eccf7a0</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,b2373965-3820-4cfe-9faf-7b725eccf7a0.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,b2373965-3820-4cfe-9faf-7b725eccf7a0.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=b2373965-3820-4cfe-9faf-7b725eccf7a0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For those that missed the <a href="http://confluence.public.thoughtworks.org/display/CCNET/2006/10/01/CruiseControl.NET+1.1+is+released.">announcement</a> last
week (like I did), the latest version of <a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET">CruiseControl.Net</a> has
been released. 
</p>
        <p>
I plan on checking it out this week, then possibly upgrading our Build environment
on Saturday. There are some modifications that I am really excited about:
</p>
        <ul>
          <li>
            <strong>Log4Net is used.</strong> (Default: Rolling file appender for logging server
output.) If the traditional Log4Net configuration block is included in the application
configuration file, I will probably change that to the ADONet appender, instead.</li>
          <li>
            <strong>Users can volunteer to fix a broken build.</strong> How sweet is that!?!</li>
          <li>
            <strong>&lt;prebuild /&gt; section allows custom tasks to run prior to the build.</strong> This
one is a big bonus; previously, if something went wrong with the build, often the
external log files (NUnit, FXCop) from the previous build would get included in the
current build’s report. Now the prebuild can give them the boot.</li>
          <li>
            <strong>Caching is used on WebDashboard.</strong> We have some huge log files and
some not-so-powerful build servers. Sometimes it takes the machine a while to process
the XSL. I am hoping that caching will help with that.</li>
          <li>
            <strong>WebDashboard can stop and start projects.</strong> I am very excited about
the ability to pause individual projects without having to modify the setup or stop
the entire service.</li>
        </ul>
        <p>
This seems like a nice package (<a href="http://confluence.public.thoughtworks.org/display/CCNET/CCNet+1.1+Final+Release+Notes">Release
Notes</a>). I am eager to pull it down and give it a go.
</p>
        <p>
One gotcha that everyone should be aware of: Old versions of the dashboard and CCTray
are incompatible with the new version of the service, so both will need to be replaced.
Give your development team a heads-up, so they know to replace their tray installation
as soon as the new server version is installed and online.
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=b2373965-3820-4cfe-9faf-7b725eccf7a0" />
      </body>
      <title>CruiseControl.Net v1.1 Released Oct. 1</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,b2373965-3820-4cfe-9faf-7b725eccf7a0.aspx</guid>
      <link>http://www.cptloadtest.com/2006/10/10/CruiseControlNet-V11-Released-Oct-1.aspx</link>
      <pubDate>Tue, 10 Oct 2006 02:51:12 GMT</pubDate>
      <description>&lt;p&gt;
For those that missed the &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/2006/10/01/CruiseControl.NET+1.1+is+released."&gt;announcement&lt;/a&gt; last
week (like I did), the latest version of &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET"&gt;CruiseControl.Net&lt;/a&gt; has
been released. 
&lt;/p&gt;
&lt;p&gt;
I plan on checking it out this week, then possibly upgrading our Build environment
on Saturday. There are some modifications that I am really excited about:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Log4Net is used.&lt;/strong&gt; (Default: Rolling file appender for logging server
output.) If the traditional Log4Net configuration block is included in the application
configuration file, I will probably change that to the ADONet appender, instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Users can volunteer to fix a broken build.&lt;/strong&gt; How sweet is that!?!&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&amp;lt;prebuild /&amp;gt; section allows custom tasks to run prior to the build.&lt;/strong&gt; This
one is a big bonus; previously, if something went wrong with the build, often the
external log files (NUnit, FXCop) from the previous build would get included in the
current build’s report. Now the prebuild can give them the boot.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Caching is used on WebDashboard.&lt;/strong&gt; We have some huge log files and
some not-so-powerful build servers. Sometimes it takes the machine a while to process
the XSL. I am hoping that caching will help with that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebDashboard can stop and start projects.&lt;/strong&gt; I am very excited about
the ability to pause individual projects without having to modify the setup or stop
the entire service.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
This seems like a nice package (&lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/CCNet+1.1+Final+Release+Notes"&gt;Release
Notes&lt;/a&gt;). I am eager to pull it down and give it a go.
&lt;/p&gt;
&lt;p&gt;
One gotcha that everyone should be aware of: Old versions of the dashboard and CCTray
are incompatible with the new version of the service, so both will need to be replaced.
Give your development team a heads-up, so they know to replace their tray installation
as soon as the new server version is installed and online.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=b2373965-3820-4cfe-9faf-7b725eccf7a0" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,b2373965-3820-4cfe-9faf-7b725eccf7a0.aspx</comments>
      <category>Continuous Integration</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=ccfd87ed-d405-4ede-9ae3-999e231d2df9</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,ccfd87ed-d405-4ede-9ae3-999e231d2df9.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,ccfd87ed-d405-4ede-9ae3-999e231d2df9.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ccfd87ed-d405-4ede-9ae3-999e231d2df9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
NAnt hates .Net’s resource files, or .resx. Don’t get me wrong–it handles them just
fine–but large quantities of resx will really bog it down.
</p>
        <p>
Visual Studio loves resx. The IDE will automatically create a resource file for you
when you open pages and controls in the ‘designer’ view. Back when we still used Visual
SourceSafe as our SCM, Visual Studio happily checked the file in and forgot about
it. Now, our 500+ page application has 500+ resource files. Most of these 500+ resource
files contain zero resources, making them useless, pointless, and a detriment to the
build.
</p>
        <p>
This morning I went through the build log, noting every resx that contained zero resources,
and deleted all of these useless files.
</p>
        <p>
The compile time dropped by 5 minutes.
</p>
        <p>
          <em>Moral of the story:</em> Be weary of Visual Studio. With regards to resx, VS is
a malware program that’s just filling your hard drive with junk. If you use resx,
great, but if you don’t, delete them all. NAnt will love you for it.
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=ccfd87ed-d405-4ede-9ae3-999e231d2df9" />
      </body>
      <title>NAnt slowdowns: Visual Studio, the .resx machine</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,ccfd87ed-d405-4ede-9ae3-999e231d2df9.aspx</guid>
      <link>http://www.cptloadtest.com/2006/02/15/NAnt-Slowdowns-Visual-Studio-The-Resx-Machine.aspx</link>
      <pubDate>Wed, 15 Feb 2006 16:31:31 GMT</pubDate>
      <description>&lt;p&gt;
NAnt hates .Net’s resource files, or .resx. Don’t get me wrong–it handles them just
fine–but large quantities of resx will really bog it down.
&lt;/p&gt;
&lt;p&gt;
Visual Studio loves resx. The IDE will automatically create a resource file for you
when you open pages and controls in the ‘designer’ view. Back when we still used Visual
SourceSafe as our SCM, Visual Studio happily checked the file in and forgot about
it. Now, our 500+ page application has 500+ resource files. Most of these 500+ resource
files contain zero resources, making them useless, pointless, and a detriment to the
build.
&lt;/p&gt;
&lt;p&gt;
This morning I went through the build log, noting every resx that contained zero resources,
and deleted all of these useless files.
&lt;/p&gt;
&lt;p&gt;
The compile time dropped by 5 minutes.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Moral of the story:&lt;/em&gt; Be weary of Visual Studio. With regards to resx, VS is
a malware program that’s just filling your hard drive with junk. If you use resx,
great, but if you don’t, delete them all. NAnt will love you for it.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=ccfd87ed-d405-4ede-9ae3-999e231d2df9" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,ccfd87ed-d405-4ede-9ae3-999e231d2df9.aspx</comments>
      <category>ASP.Net</category>
      <category>Continuous Integration</category>
      <category>NAnt</category>
      <category>Programming</category>
      <category>Task Automation</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=d0a8c19d-e021-4631-820c-f32e0992083a</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,d0a8c19d-e021-4631-820c-f32e0992083a.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,d0a8c19d-e021-4631-820c-f32e0992083a.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d0a8c19d-e021-4631-820c-f32e0992083a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
CruiseControl .Net 1.0 has been released. <a href="http://sourceforge.net/project/showfiles.php?group_id=71179&amp;package_id=83198&amp;release_id=370756">download</a> | <a href="http://confluence.public.thoughtworks.org/display/CCNET/CCNet+1.0+Final+Release+Notes">release
notes</a></p>
        <p>
This is a <em>must</em> upgrade for anyone running v0.9 or earlier. There are many
updates that I am excited about, most notably the overhaul to CCTray (the client-side
build monitoring tool that sits in your system tray). Our developers have had to use
Firefox’s CC.Net monitor extension to monitor multiple builds, simultaneously. No
more.
</p>
        <p>
We will be upgrading within the next week.
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=d0a8c19d-e021-4631-820c-f32e0992083a" />
      </body>
      <title>CruiseControl.Net 1.0 released</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,d0a8c19d-e021-4631-820c-f32e0992083a.aspx</guid>
      <link>http://www.cptloadtest.com/2005/11/15/CruiseControlNet-10-Released.aspx</link>
      <pubDate>Tue, 15 Nov 2005 16:34:32 GMT</pubDate>
      <description>&lt;p&gt;
CruiseControl .Net 1.0 has been released. &lt;a href="http://sourceforge.net/project/showfiles.php?group_id=71179&amp;amp;package_id=83198&amp;amp;release_id=370756"&gt;download&lt;/a&gt; | &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/CCNet+1.0+Final+Release+Notes"&gt;release
notes&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
This is a &lt;em&gt;must&lt;/em&gt; upgrade for anyone running v0.9 or earlier. There are many
updates that I am excited about, most notably the overhaul to CCTray (the client-side
build monitoring tool that sits in your system tray). Our developers have had to use
Firefox’s CC.Net monitor extension to monitor multiple builds, simultaneously. No
more.
&lt;/p&gt;
&lt;p&gt;
We will be upgrading within the next week.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=d0a8c19d-e021-4631-820c-f32e0992083a" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,d0a8c19d-e021-4631-820c-f32e0992083a.aspx</comments>
      <category>Continuous Integration</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=8a466c03-70e5-4d01-ab90-bc9052145e1c</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,8a466c03-70e5-4d01-ab90-bc9052145e1c.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,8a466c03-70e5-4d01-ab90-bc9052145e1c.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8a466c03-70e5-4d01-ab90-bc9052145e1c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
MSIExec error code 1605 has been a thorn in my side for quite a while. When an MSI
was command-line deployed by one user (manually deployed by me in the middle of the
day), it couldn’t be uninstalled by another (automation during the nightly) due to
the “Just Me” default. If I installed it through using the UI, and installed it for
use by “Everyone”, then the nightly would build just fine. I needed a way to run an
“Everyone” install from the command line, but Google wasn’t helping me out. Unfortunately,
Microsoft does not seem to have a lot of documentation on this functionality, either.
</p>
        <p>
It further frustrated me this morning when my nightlies were failing again, but only
on one server. Of course, I manually deployed the package to this same server to a
few days ago. I tried Google again, and this time hit pay dirt. Executing it with
ALLUSERS=2 in the command line makes it available for everyone. Apparently, it forces
an “Everyone” install for the UI, too.
</p>
        <p>
Finally I can pull the thorn out.
</p>
        <p>
MSIExec /i mypackage .msi … ALLUSERS=2
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=8a466c03-70e5-4d01-ab90-bc9052145e1c" />
      </body>
      <title>MSIExec for Everyone, not Just Me</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,8a466c03-70e5-4d01-ab90-bc9052145e1c.aspx</guid>
      <link>http://www.cptloadtest.com/2005/11/05/MSIExec-For-Everyone-Not-Just-Me.aspx</link>
      <pubDate>Sat, 05 Nov 2005 16:06:26 GMT</pubDate>
      <description>&lt;p&gt;
MSIExec error code 1605 has been a thorn in my side for quite a while. When an MSI
was command-line deployed by one user (manually deployed by me in the middle of the
day), it couldn’t be uninstalled by another (automation during the nightly) due to
the “Just Me” default. If I installed it through using the UI, and installed it for
use by “Everyone”, then the nightly would build just fine. I needed a way to run an
“Everyone” install from the command line, but Google wasn’t helping me out. Unfortunately,
Microsoft does not seem to have a lot of documentation on this functionality, either.
&lt;/p&gt;
&lt;p&gt;
It further frustrated me this morning when my nightlies were failing again, but only
on one server. Of course, I manually deployed the package to this same server to a
few days ago. I tried Google again, and this time hit pay dirt. Executing it with
ALLUSERS=2 in the command line makes it available for everyone. Apparently, it forces
an “Everyone” install for the UI, too.
&lt;/p&gt;
&lt;p&gt;
Finally I can pull the thorn out.
&lt;/p&gt;
&lt;p&gt;
MSIExec /i mypackage .msi … ALLUSERS=2
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=8a466c03-70e5-4d01-ab90-bc9052145e1c" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,8a466c03-70e5-4d01-ab90-bc9052145e1c.aspx</comments>
      <category>Continuous Integration</category>
      <category>Tools</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=8c1f277e-a561-4bca-99e7-facfa9e2583c</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,8c1f277e-a561-4bca-99e7-facfa9e2583c.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,8c1f277e-a561-4bca-99e7-facfa9e2583c.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=8c1f277e-a561-4bca-99e7-facfa9e2583c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I know. I haven’t posted in a while. But I’ve been crazy busy. Twelve hour days are
my norm, right now. But enough complaining; let’s get to the good stuff.
</p>
        <p>
By now you know my love for PsExec. I discovered it when trying to find a way to add
assemblies to a remote GAC [<a href="http://www.cptloadtest.com/?cat=8">post</a>].
I’ve found more love for it. Now, I can remotely execute my performance tests!
</p>
        <h3>Execute LoadRunner test using NAnt via LoadRunner:
</h3>
        <pre name="code" class="xml">&lt;exec basedir="${P1}"
  program="psexec"
  failonerror="false"
  commandline='\${P2} /u ${P3} /p ${P4} /i /w "${P5}" cmd /c wlrun -Run
    -InvokeAnalysis -TestPath "${P6}" -ResultLocation "${P7}"
    -ResultCleanName "${P8}"' /&gt;
</pre>
        <p>
(I’ve created generic parameter names so that you can read it a little better.)<br /><strong>P1</strong>: Local directory for PsExec<br /><strong>P2</strong>: LoadRunner Controller Server name<br /><strong>P3</strong>: LoadRunner Controller Server user username. I use an Admin-level
ID here, since this ID also needs rights to capture Windows PerfMon metrics on my
app servers.<br /><strong>P4</strong>: LoadRunner Controller Server user password<br /><strong>P5</strong>: Working directory on P2 for 'wlrun.exe', such as C:\Program Files\Mercury\Mercury
LoadRunner\bin<br /><strong>P6</strong>: Path on P2 to the LoadRunner scenario file<br /><strong>P7</strong>: Directory on P2 that contains all results from every test<br /><strong>P8</strong>: Result Set name for this test run
</p>
        <p>
'-InvokeAnalysis' will automatically execute LoadRunner analysis at test completion.
If you properly configure your Analysis default template, Analysis will automatically
generate the result set you want, save the Analysis session information, and create
a HTML report of the results. Now, put IIS on your Controller machine, and VDir to
the main results directory in P7, and you will have access to the HTML report within
minutes after your test completes.
</p>
        <h4>Other ideas:
</h4>
        <ul>
          <li>
You can also hook it up to CruiseControl and have your CC.Net report include a link
to the LR report.</li>
          <li>
Create a nightly build in CC.Net that will compile your code, deploy it to your performance
testing environment, and execute the performance test. When you get to work in the
morning, you have a link to your full performance test report waiting in your inbox.</li>
        </ul>
        <p>
The catch for all of this: you need a session logged in to the LoadRunner controller
box at all times. The '/i' in the PsExec command means that it interacts with the
desktop.
</p>
        <h4>
          <em>Sidenote</em>
        </h4>
        <p>
PsExec is my favorite tool right now. I can do so many cool things. I admit, as a
domain administrator, I also get a little malicious, sometimes. The other day I used
PsExec to start up solitaire on a co-workers box, then razzed him for playing games
on the clock.
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=8c1f277e-a561-4bca-99e7-facfa9e2583c" />
      </body>
      <title>Automate LoadRunner through NAnt</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,8c1f277e-a561-4bca-99e7-facfa9e2583c.aspx</guid>
      <link>http://www.cptloadtest.com/2005/10/14/Automate-LoadRunner-Through-NAnt.aspx</link>
      <pubDate>Fri, 14 Oct 2005 15:35:40 GMT</pubDate>
      <description>&lt;p&gt;
I know. I haven’t posted in a while. But I’ve been crazy busy. Twelve hour days are
my norm, right now. But enough complaining; let’s get to the good stuff.
&lt;/p&gt;
&lt;p&gt;
By now you know my love for PsExec. I discovered it when trying to find a way to add
assemblies to a remote GAC [&lt;a href="http://www.cptloadtest.com/?cat=8"&gt;post&lt;/a&gt;].
I’ve found more love for it. Now, I can remotely execute my performance tests!
&lt;/p&gt;
&lt;h3&gt;Execute LoadRunner test using NAnt via LoadRunner:
&lt;/h3&gt;
&lt;pre name="code" class="xml"&gt;&amp;lt;exec basedir="${P1}"
  program="psexec"
  failonerror="false"
  commandline='\${P2} /u ${P3} /p ${P4} /i /w "${P5}" cmd /c wlrun -Run
    -InvokeAnalysis -TestPath "${P6}" -ResultLocation "${P7}"
    -ResultCleanName "${P8}"' /&amp;gt;
&lt;/pre&gt;
&lt;p&gt;
(I’ve created generic parameter names so that you can read it a little better.)&lt;br&gt;
&lt;strong&gt;P1&lt;/strong&gt;: Local directory for PsExec&lt;br&gt;
&lt;strong&gt;P2&lt;/strong&gt;: LoadRunner Controller Server name&lt;br&gt;
&lt;strong&gt;P3&lt;/strong&gt;: LoadRunner Controller Server user username. I use an Admin-level
ID here, since this ID also needs rights to capture Windows PerfMon metrics on my
app servers.&lt;br&gt;
&lt;strong&gt;P4&lt;/strong&gt;: LoadRunner Controller Server user password&lt;br&gt;
&lt;strong&gt;P5&lt;/strong&gt;: Working directory on P2 for 'wlrun.exe', such as C:\Program Files\Mercury\Mercury
LoadRunner\bin&lt;br&gt;
&lt;strong&gt;P6&lt;/strong&gt;: Path on P2 to the LoadRunner scenario file&lt;br&gt;
&lt;strong&gt;P7&lt;/strong&gt;: Directory on P2 that contains all results from every test&lt;br&gt;
&lt;strong&gt;P8&lt;/strong&gt;: Result Set name for this test run
&lt;/p&gt;
&lt;p&gt;
'-InvokeAnalysis' will automatically execute LoadRunner analysis at test completion.
If you properly configure your Analysis default template, Analysis will automatically
generate the result set you want, save the Analysis session information, and create
a HTML report of the results. Now, put IIS on your Controller machine, and VDir to
the main results directory in P7, and you will have access to the HTML report within
minutes after your test completes.
&lt;/p&gt;
&lt;h4&gt;Other ideas:
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;
You can also hook it up to CruiseControl and have your CC.Net report include a link
to the LR report.&lt;/li&gt;
&lt;li&gt;
Create a nightly build in CC.Net that will compile your code, deploy it to your performance
testing environment, and execute the performance test. When you get to work in the
morning, you have a link to your full performance test report waiting in your inbox.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
The catch for all of this: you need a session logged in to the LoadRunner controller
box at all times. The '/i' in the PsExec command means that it interacts with the
desktop.
&lt;/p&gt;
&lt;h4&gt;&lt;em&gt;Sidenote&lt;/em&gt;
&lt;/h4&gt;
&lt;p&gt;
PsExec is my favorite tool right now. I can do so many cool things. I admit, as a
domain administrator, I also get a little malicious, sometimes. The other day I used
PsExec to start up solitaire on a co-workers box, then razzed him for playing games
on the clock.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=8c1f277e-a561-4bca-99e7-facfa9e2583c" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,8c1f277e-a561-4bca-99e7-facfa9e2583c.aspx</comments>
      <category>Continuous Integration</category>
      <category>NAnt</category>
      <category>Performance</category>
      <category>Task Automation</category>
      <category>Testing</category>
      <category>LoadRunner</category>
    </item>
    <item>
      <trackback:ping>http://www.cptloadtest.com/Trackback.aspx?guid=de45fc73-2205-457c-ac02-5c83a8cd4ad9</trackback:ping>
      <pingback:server>http://www.cptloadtest.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.cptloadtest.com/PermaLink,guid,de45fc73-2205-457c-ac02-5c83a8cd4ad9.aspx</pingback:target>
      <dc:creator>Jay Harris</dc:creator>
      <wfw:comment>http://www.cptloadtest.com/CommentView,guid,de45fc73-2205-457c-ac02-5c83a8cd4ad9.aspx</wfw:comment>
      <wfw:commentRss>http://www.cptloadtest.com/SyndicationService.asmx/GetEntryCommentsRss?guid=de45fc73-2205-457c-ac02-5c83a8cd4ad9</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
With our new <a href="http://www.cptloadtest.com/2005/08/23/DatabaseRestoreThroughNAnt.aspx">nightly
database restore</a> we now have the desire to automatically run all of the change
scripts associated with a project. We’ve found a way; I created a NAnt script that
will parse the Visual Studio Database Project (or "DBP") and execute all of the change
scripts in it. Here’s how we got there.
</p>
        <hr />
        <h3>Problem 1: Visual Studio Command Files are worthless
</h3>
        <p>
Our first idea was to have everyone update a command file in the DBP, and have NAnt
run it every night. Visual Studio command files are great and all, but we have discovered
a problem with them: they do not keep the files in order. We have named all of our
folders (01 DDL, 02 DML, etc) and our change scripts (0001 Create MyTable.sql, 0002
AddInfoColumn to MyTable.sql) accordingly so that they <em>should</em> run in order.
We have found that the command file feature of VS.Net 2003 does not keep them in order
but rather seems to sort them first by extension, then by order, or some similar oddness.
Obviously, if I try to at InfoColumn to MyTable before MyTable exists, I’m going to
have a problem. So, the command file idea was axed.
</p>
        <h3>Problem 2: Visual SourceSafe contents can’t be trusted
</h3>
        <p>
Our second idea was to VSSGET the DBP directory in VSS and execute every script in
it. However, the VSS store cannot be trusted. If a developer creates a script in VS.Net
called ‘0001 Crate MyTable.sql’ and checks it in to the project, then proceeds to
correct the spelling error in VS.Net to ‘0001 Create MyTable.sql’, VS does not rename
the old file in VSS. Instead, it removes the old file from the project, renames it
locally, then adds the new name to the project and to VSS. It also never deletes the
old file name from the VSS store. Now, both files (’0001 Crate MyTable.sql’ and ‘0001
Create MyTable.sql’) exist in VSS. Performing a VSSGET and executing all scripts will
run both scripts, which could lead to more troubles.
</p>
        <hr />
        <p>
So, we can’t use a command file, because it won’t maintain the order. We can’t trust
VSS, since it can have obsolete files. We can only trust the project, but how do we
get a list of files, ourselves?
</p>
        <p>
Fortunately, DBP files are just text in a weird XML-wannabe format. The NAnt script
will open the file and run through it looking for every ‘SCRIPT’ entry in the file.
If it finds a ‘BEGIN something’ entry, it assumes that ’something’ is a folder name,
and appends it to the working path until it finds ‘END’, at which time it returns
to the parent directory.
</p>
        <p>
It’s not perfect. It still runs in to some problems, but here it is in v0.1 form.
</p>
        <pre name="code" class="xml">&lt;project name="RunDBPScripts" default="RunScripts"&gt;
&lt;!–-
Execute all scripts in a VS.Net DBP
Author: Jay Harris, http://www.cptloadtest.com, (c) 2005 Jason Harris
License: This work is licensed under a  
   Creative Commons Attribution 3.0 United States License.  
   http://creativecommons.org/licenses/by/3.0/us/ 

This script is offered as-is.
I am not responsible for any misfortunes that may arise from its use.
Use at your own risk.
-–&gt;
&lt;!-– Project: The path of the DBP file –-&gt;
&lt;property name="project" value="Scripts.dbp" overwrite="false" /&gt;
&lt;!-– Server: The machine name of the Database Server –-&gt;
&lt;property name="server" value="localhost" overwrite="false" /&gt;
&lt;!-– Database: The database that the scripts will be run against –-&gt;
&lt;property name="database" value="Northwind" overwrite="false" /&gt;
&lt;target name="RunScripts"&gt;
        &lt;property name="currentpath"
            value="${directory::get-parent-directory(project)}" /&gt;
        &lt;foreach item="Line" property="ProjectLineItem" in="${project}"&gt;
            &lt;if test="${string::contains(ProjectLineItem, 'Begin Folder = ')}"&gt;
                &lt;regex pattern="Folder = &amp;quot;(?’ProjectFolder’.*)&amp;quot;$"
                    input="${string::trim(ProjectLineItem)}" /&gt;
                &lt;property name="currentpath"
                    value="${path::combine(currentpath, ProjectFolder)}" /&gt;
            &lt;/if&gt;
            &lt;if test="${string::contains(ProjectLineItem, 'Script = ')}"&gt;
                &lt;regex pattern="Script = &amp;quot;(?’ScriptName’.*)&amp;quot;$"
                    input="${string::trim(ProjectLineItem)}" /&gt;
                &lt;echo message="Executing Change Script (${server+"\"+database}): ${path::combine(currentpath, ScriptName)}" /&gt;
                &lt;exec workingdir="${currentpath}" program="osql"
                    basedir="C:\Program Files\Microsoft SQL Server\80\Tools\Binn"
                    commandline=’-S ${server} -d ${database} -i “${ScriptName}" -n -E -b’ /&gt;
            &lt;/if&gt;
            &lt;if test="${string::trim(ProjectLineItem) == 'End’}"&gt;
                &lt;property name="currentpath"
                    value="${directory::get-parent-directory(currentpath)}" /&gt;
            &lt;/if&gt;
        &lt;/foreach&gt;
    &lt;/target&gt;
&lt;/project&gt;</pre>
        <p>
I used an &lt;EXEC&gt; NAnt task rather than &lt;SQL&gt;. I found that a lot of the
scripts would not execute in the SQL task because of their design. VS Command Files
use OSQL, so that’s what I used. I guess those command files were worth something
after all.
</p>
        <p>
If you know of a better way, or have any suggestions or comments, please let me know.
</p>
        <img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=de45fc73-2205-457c-ac02-5c83a8cd4ad9" />
      </body>
      <title>NAnt and Visual Studio database projects</title>
      <guid isPermaLink="false">http://www.cptloadtest.com/PermaLink,guid,de45fc73-2205-457c-ac02-5c83a8cd4ad9.aspx</guid>
      <link>http://www.cptloadtest.com/2005/08/25/NAnt-And-Visual-Studio-Database-Projects.aspx</link>
      <pubDate>Thu, 25 Aug 2005 16:15:41 GMT</pubDate>
      <description>&lt;p&gt;
With our new &lt;a href="http://www.cptloadtest.com/2005/08/23/DatabaseRestoreThroughNAnt.aspx"&gt;nightly
database restore&lt;/a&gt; we now have the desire to automatically run all of the change
scripts associated with a project. We’ve found a way; I created a NAnt script that
will parse the Visual Studio Database Project (or "DBP") and execute all of the change
scripts in it. Here’s how we got there.
&lt;/p&gt;
&lt;hr&gt;
&lt;h3&gt;Problem 1: Visual Studio Command Files are worthless
&lt;/h3&gt;
&lt;p&gt;
Our first idea was to have everyone update a command file in the DBP, and have NAnt
run it every night. Visual Studio command files are great and all, but we have discovered
a problem with them: they do not keep the files in order. We have named all of our
folders (01 DDL, 02 DML, etc) and our change scripts (0001 Create MyTable.sql, 0002
AddInfoColumn to MyTable.sql) accordingly so that they &lt;em&gt;should&lt;/em&gt; run in order.
We have found that the command file feature of VS.Net 2003 does not keep them in order
but rather seems to sort them first by extension, then by order, or some similar oddness.
Obviously, if I try to at InfoColumn to MyTable before MyTable exists, I’m going to
have a problem. So, the command file idea was axed.
&lt;/p&gt;
&lt;h3&gt;Problem 2: Visual SourceSafe contents can’t be trusted
&lt;/h3&gt;
&lt;p&gt;
Our second idea was to VSSGET the DBP directory in VSS and execute every script in
it. However, the VSS store cannot be trusted. If a developer creates a script in VS.Net
called ‘0001 Crate MyTable.sql’ and checks it in to the project, then proceeds to
correct the spelling error in VS.Net to ‘0001 Create MyTable.sql’, VS does not rename
the old file in VSS. Instead, it removes the old file from the project, renames it
locally, then adds the new name to the project and to VSS. It also never deletes the
old file name from the VSS store. Now, both files (’0001 Crate MyTable.sql’ and ‘0001
Create MyTable.sql’) exist in VSS. Performing a VSSGET and executing all scripts will
run both scripts, which could lead to more troubles.
&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;
So, we can’t use a command file, because it won’t maintain the order. We can’t trust
VSS, since it can have obsolete files. We can only trust the project, but how do we
get a list of files, ourselves?
&lt;/p&gt;
&lt;p&gt;
Fortunately, DBP files are just text in a weird XML-wannabe format. The NAnt script
will open the file and run through it looking for every ‘SCRIPT’ entry in the file.
If it finds a ‘BEGIN something’ entry, it assumes that ’something’ is a folder name,
and appends it to the working path until it finds ‘END’, at which time it returns
to the parent directory.
&lt;/p&gt;
&lt;p&gt;
It’s not perfect. It still runs in to some problems, but here it is in v0.1 form.
&lt;/p&gt;
&lt;pre name="code" class="xml"&gt;&amp;lt;project name="RunDBPScripts" default="RunScripts"&amp;gt;
&amp;lt;!–-
Execute all scripts in a VS.Net DBP
Author: Jay Harris, http://www.cptloadtest.com, (c) 2005 Jason Harris
License: This work is licensed under a  
   Creative Commons Attribution 3.0 United States License.  
   http://creativecommons.org/licenses/by/3.0/us/ 

This script is offered as-is.
I am not responsible for any misfortunes that may arise from its use.
Use at your own risk.
-–&amp;gt;
&amp;lt;!-– Project: The path of the DBP file –-&amp;gt;
&amp;lt;property name="project" value="Scripts.dbp" overwrite="false" /&amp;gt;
&amp;lt;!-– Server: The machine name of the Database Server –-&amp;gt;
&amp;lt;property name="server" value="localhost" overwrite="false" /&amp;gt;
&amp;lt;!-– Database: The database that the scripts will be run against –-&amp;gt;
&amp;lt;property name="database" value="Northwind" overwrite="false" /&amp;gt;
&amp;lt;target name="RunScripts"&amp;gt;
        &amp;lt;property name="currentpath"
            value="${directory::get-parent-directory(project)}" /&amp;gt;
        &amp;lt;foreach item="Line" property="ProjectLineItem" in="${project}"&amp;gt;
            &amp;lt;if test="${string::contains(ProjectLineItem, 'Begin Folder = ')}"&amp;gt;
                &amp;lt;regex pattern="Folder = &amp;amp;quot;(?’ProjectFolder’.*)&amp;amp;quot;$"
                    input="${string::trim(ProjectLineItem)}" /&amp;gt;
                &amp;lt;property name="currentpath"
                    value="${path::combine(currentpath, ProjectFolder)}" /&amp;gt;
            &amp;lt;/if&amp;gt;
            &amp;lt;if test="${string::contains(ProjectLineItem, 'Script = ')}"&amp;gt;
                &amp;lt;regex pattern="Script = &amp;amp;quot;(?’ScriptName’.*)&amp;amp;quot;$"
                    input="${string::trim(ProjectLineItem)}" /&amp;gt;
                &amp;lt;echo message="Executing Change Script (${server+"\"+database}): ${path::combine(currentpath, ScriptName)}" /&amp;gt;
                &amp;lt;exec workingdir="${currentpath}" program="osql"
                    basedir="C:\Program Files\Microsoft SQL Server\80\Tools\Binn"
                    commandline=’-S ${server} -d ${database} -i “${ScriptName}" -n -E -b’ /&amp;gt;
            &amp;lt;/if&amp;gt;
            &amp;lt;if test="${string::trim(ProjectLineItem) == 'End’}"&amp;gt;
                &amp;lt;property name="currentpath"
                    value="${directory::get-parent-directory(currentpath)}" /&amp;gt;
            &amp;lt;/if&amp;gt;
        &amp;lt;/foreach&amp;gt;
    &amp;lt;/target&amp;gt;
&amp;lt;/project&amp;gt;&lt;/pre&gt;
&lt;p&gt;
I used an &amp;lt;EXEC&amp;gt; NAnt task rather than &amp;lt;SQL&amp;gt;. I found that a lot of the
scripts would not execute in the SQL task because of their design. VS Command Files
use OSQL, so that’s what I used. I guess those command files were worth something
after all.
&lt;/p&gt;
&lt;p&gt;
If you know of a better way, or have any suggestions or comments, please let me know.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.cptloadtest.com/aggbug.ashx?id=de45fc73-2205-457c-ac02-5c83a8cd4ad9" /&gt;</description>
      <comments>http://www.cptloadtest.com/CommentView,guid,de45fc73-2205-457c-ac02-5c83a8cd4ad9.aspx</comments>
      <category>Continuous Integration</category>
      <category>NAnt</category>
      <category>Task Automation</category>
      <category>Visual Studio</category>
    </item>
  </channel>
</rss>