<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://devlicio.us/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hadi Hariri : Tools, TeamCity</title><link>http://devlicio.us/blogs/hadi_hariri/archive/tags/Tools/TeamCity/default.aspx</link><description>Tags: Tools, TeamCity</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><item><title>Setting up TeamCity as a native NuGet Server</title><link>http://devlicio.us/blogs/hadi_hariri/archive/2011/12/01/setting-up-teamcity-as-a-native-nuget-server.aspx</link><pubDate>Thu, 01 Dec 2011 16:27:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68448</guid><dc:creator>Hadi Hariri</dc:creator><slash:comments>18</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/hadi_hariri/rsscomments.aspx?PostID=68448</wfw:commentRss><comments>http://devlicio.us/blogs/hadi_hariri/archive/2011/12/01/setting-up-teamcity-as-a-native-nuget-server.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.jetbrains.com/teamcity/2011/11/24/new-teamcity-7-0-eap-build-20702/"&gt;TeamCity 7.0 EAP (Early Access Program) was recently opened&lt;/a&gt; and one of the new features is the built-in support for NuGet. I recently blogged about setting up &lt;a href="http://blogs.jetbrains.com/dotnet/2011/08/native-nuget-support-in-teamcity/"&gt;TeamCity to pack and publish NuGet packages via a plug-in&lt;/a&gt; and this plug-in is now included by default in TeamCity 7. However, the real new interesting feature is that TeamCity is now a native NuGet repository too! &lt;/p&gt;
&lt;h3&gt;Native NuGet Server? &lt;/h3&gt;
&lt;p&gt;Many of those that have been using NuGet, have most likely been using it to consume packages from nuget.org where there are currently over 3800 unique packages, most of which are open source. &lt;/p&gt;
&lt;p align="center"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_12197754.png" border="0" height="138" width="483" /&gt;&lt;/p&gt;
&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="justify"&gt;What happens however if for some reason or another you do not want to submit packages to nuget.org? For instance, think that you want to use NuGet to modularize and distribute code inside your own organization, or create libraries for private consumption. In this case, publishing to nuget.org does not make sense. This leaves you with basically two options:&lt;/p&gt;
&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div align="justify"&gt;Setup your own NuGet repository by downloading and installing the code that nuget.org for instance&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align="justify"&gt;Copy nuget packages to a local share and have everyone read off of that&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="justify"&gt;Both of these options come with their own share of overhead. With the local share you now require sharing of folders and permissions. Setting up your own NuGet repository also requires managing permissions and whatnot separately. At the end of the day, its another service to manage. &lt;/p&gt;
&lt;p align="justify"&gt;Fortunately, you now have a third option: TeamCity. The same server that builds your projects, runs your tests, packs and publishes your packages can now also serve them. The best part of it is that it is so simple, that I had to take up the rest of this blog with the previous nonsense just to give it some meat. &lt;/p&gt;
&lt;h3 align="justify"&gt;Enabling TeamCity as a NuGet Server&lt;/h3&gt;
&lt;p align="justify"&gt;I am not going to cover how to pack and publish packages in this post. All that is covered in detail in the &lt;a href="http://blogs.jetbrains.com/dotnet/2011/08/native-nuget-support-in-teamcity/"&gt;previous post&lt;/a&gt; I wrote, so please read that first if you&amp;rsquo;re not familiar with the process. Enabling TeamCity as NuGet and making packages available consists of two steps:&lt;/p&gt;
&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4 align="justify"&gt;1. Enable the server to be a NuGet server&lt;/h4&gt;
&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="justify"&gt;Go to &lt;b&gt;Administration | Server Configuration | NuGet&lt;/b&gt; tab&lt;/p&gt;
&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_1787E7F8.png" border="0" height="306" width="679" /&gt;&lt;/p&gt;
&lt;p align="justify"&gt;Click on the &lt;b&gt;Enable&lt;/b&gt; button to enable it. The same screen with then display two different feeds: a public and a private one:&lt;/p&gt;
&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p align="justify"&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_2F3F1F5E.png" border="0" height="269" width="628" /&gt;&lt;/p&gt;
&lt;p&gt;If by chance the Public Url is not available, you will probably see a message telling you that you &lt;b&gt;need to enable the Guest account in TeamCity&lt;/b&gt;, which can be done from the General tab.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h4&gt;2. Make your packages be your Artifacts&lt;/h4&gt;
&lt;p&gt;Since TeamCity itself is going to be a NuGet server, the step to publish a package is no longer required. However, packing the package is. In this step (&lt;b&gt;NuGet Pack Build Type&lt;/b&gt;), we can just configure the output for the package to point to some specific folder, for instance &lt;i&gt;packages&lt;/i&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_22D0FC35.png" border="0" height="123" width="885" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We need instruct TeamCity to ouput the results of this folder as artifacts. This is done in the &lt;b&gt;General Settings&lt;/b&gt; step of the Build Configuration&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_4CD0FA5D.png" border="0" height="200" width="752" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;and with that, we&amp;rsquo;re done. Next up is to configure Visual Studio to consume from this feed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Configuring Visual Studio&lt;/h3&gt;
&lt;p&gt;Although this step is optional, it is recommended to add your repositories to Visual Studio to avoid having to type long URL&amp;rsquo;s in each time you want to read from a specific package repository. To do this, click on &lt;b&gt;Options | Library Package Manager | Package Manager Settings&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_4B8C617E.png" border="0" height="420" width="617" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We need to add a new NuGet Repository. I&amp;rsquo;ve called it &lt;i&gt;Local TeamCity&lt;/i&gt;&amp;nbsp; and the URL corresponds to the public URL provided to me by TeamCity in Step 1:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_581A0E9A.png" border="0" height="384" width="479" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Notice that I have another entry which is &lt;i&gt;Local TeamCity Auth &lt;/i&gt;which corresponds to the authenticated version. &lt;/p&gt;
&lt;p&gt;Once we have this, we can now easily consume packages from our repository by merely specifying it in the Package Manager Console, either via the Combobox or explicitly in each call:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;margin:10px 0px 0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" alt="image" src="http://devlicious.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_56D575BB.png" border="0" height="161" width="743" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;That&amp;rsquo;s all there is to it. By merely publishing our packages as artifacts, TeamCity now provides a full-fledged nuget server which opens up great possibilities when it comes to working and managing dependencies between projects. TeamCity is currently in EAP and much of what I&amp;rsquo;ve described here is in open to improvements. That is why your feedback is very important. &lt;a href="http://confluence.jetbrains.net/display/TW/TeamCity+EAP"&gt;Download 7 and start playing with it today&lt;/a&gt;. Let us know what you think. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68448" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Tools/default.aspx">Tools</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/TeamCity/default.aspx">TeamCity</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/NuGet/default.aspx">NuGet</category></item><item><title>Native NuGet Support in TeamCity</title><link>http://devlicio.us/blogs/hadi_hariri/archive/2011/08/24/native-nuget-support-in-teamcity.aspx</link><pubDate>Wed, 24 Aug 2011 20:01:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:68133</guid><dc:creator>Hadi Hariri</dc:creator><slash:comments>26</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/hadi_hariri/rsscomments.aspx?PostID=68133</wfw:commentRss><comments>http://devlicio.us/blogs/hadi_hariri/archive/2011/08/24/native-nuget-support-in-teamcity.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A few months ago, &lt;a href="http://twitter.com/shanselman"&gt;Scott Hanselman&lt;/a&gt; gave a session at TechEd US were he showed some new features we were working on for TeamCity, in order to provide first class support for NuGet. He later &lt;a href="http://www.hanselman.com/blog/NuGetForTheEnterpriseNuGetInAContinuousIntegrationAutomatedBuildSystem.aspx"&gt;blogged about it here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Instead of delaying until the next release of TeamCity, this feature (like many), has been developed as a plug-in. &lt;a href="http://twitter.com/jonnyzzz"&gt;Eugene&lt;/a&gt;, who has been working on it, announced the availability of a first build a few weeks ago. After some initial trials and changes, I decided to setup &lt;a href="http://github.com/JetBrains/YouTrackSharp"&gt;YouTrackSharp&lt;/a&gt; to automate the publishing of the NuGet package. It was surprisingly easy as you&amp;#39;ll see.&lt;/p&gt;
&lt;h3&gt;1. Installing the Plug-in&lt;/h3&gt;
&lt;p&gt;If your project is running on &lt;a href="http://teamcity.codebetter.com"&gt;TeamCity at Codebetter.com&lt;/a&gt;, you can skip to Step 3, since it&amp;#39;s already installed and configured. If not, then grab the &lt;a href="http://teamcity.jetbrains.com/viewType.html?buildTypeId=bt324&amp;amp;tab=buildTypeStatusDiv"&gt;latest build from our public TeamCity server&lt;/a&gt;. Place the zip file into the plugins folder of your TeamCity installation and restart the server.&lt;/p&gt;
&lt;h3&gt;2. Configuring the NuGet version&lt;/h3&gt;
&lt;p&gt;Once the server is running, and agents updated (automated procedure), you then need to tell TeamCity what NuGet version you want to use. The plug-in knows about the nuget.org feed to it can grab the latest version of the command line tool directly. Click on &lt;b&gt;Administration | Server Configuration&lt;/b&gt;. If the plug-in installed correctly, you should now have a new Tab called NuGet:&lt;/p&gt;
&lt;p&gt;&lt;img title="AdminPanelNuGet.png" alt="AdminPanelNuGet" src="http://blogs.jetbrains.com/dotnet/wp-content/uploads/2011/08/adminpanelnuget.png" border="0" /&gt;&lt;/p&gt;
&lt;p&gt;Click on the &amp;quot;Install additional versions of the NuGet.exe Command Line&amp;quot;. TeamCity will read from the feed and display available versions to you in the dialog box. Select the version you want and click Install:&lt;/p&gt;
&lt;p&gt;&lt;img title="NuGetVersion.png" alt="NuGetVersion" src="http://blogs.jetbrains.com/dotnet/wp-content/uploads/2011/08/nugetversion.png" border="0" /&gt;&lt;/p&gt;
&lt;h3&gt;Pull, Pack, Publish&lt;/h3&gt;
&lt;p&gt;The plug-in offers three main operations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Pulling NuGet packages required to build your project &lt;/li&gt;
&lt;li&gt;Creating NuGet packages &lt;/li&gt;
&lt;li&gt;Publishing Packages &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In my case, I want to create the package and publish it. To give you a general idea of my build process, here&amp;#39;s the outline of the build steps:&lt;/p&gt;
&lt;p&gt;&lt;img title="BuildOverview.png" alt="BuildOverview" src="http://blogs.jetbrains.com/dotnet/wp-content/uploads/2011/08/buildoverview.png" width="600" border="0" height="235" /&gt;&lt;/p&gt;
&lt;p&gt;The NuGet related steps are 3 and 4. Step 1 simply builds the project by building the solution file. Step 2 runs the MSpec tests.&lt;/p&gt;
&lt;h3&gt;3. Building the package&lt;/h3&gt;
&lt;p&gt;This step is for building the actual package. We create a new Build Step in our project and select &lt;b&gt;NuGet Packages Pack&lt;/b&gt;. This will give us the following configuration screen:&lt;/p&gt;
&lt;p&gt;&lt;img title="Step3.png" alt="Step3" src="http://blogs.jetbrains.com/dotnet/wp-content/uploads/2011/08/step3.png" width="600" border="0" height="460" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see, the configuration is pretty straightforward. Notice that in the Specification file, we can also provide a &lt;i&gt;csproj&lt;/i&gt; file as opposed to a NuGet spec file. The advantage to this is that we do not have to redefine information such as version number and copyright information in the spec file. If you&amp;#39;re not familiar with this feature, check out &lt;a href="http://blog.davidebbo.com/2011/04/easy-way-to-publish-nuget-packages-with.html"&gt;David Ebbo&amp;#39;s post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve also checked the option to &lt;b&gt;Include Sources and Symbols&lt;/b&gt;. This is also explained in David Ebbo&amp;#39;s post and it&amp;#39;s for publishing the sources to &lt;a href="http://symbolsource.org"&gt;Symbolsource&lt;/a&gt;. Additional command line parameters (if required) can be passed in the &lt;b&gt;Additional Commandline arguments&lt;/b&gt;. If you want to make this a release build, you can also do this by defining &lt;b&gt;Configuration=Release&lt;/b&gt; in the &lt;b&gt;Properties&lt;/b&gt; field.&lt;/p&gt;
&lt;p&gt;Finally I&amp;#39;ve specified the Build number of the package using the TeamCity variable %build.number% which auto increments on each build, and is also used by another feature of TeamCity new in 6.5 which is called the AssemblyPatcher, which I&amp;#39;ll show you as the last step.&lt;/p&gt;
&lt;h3&gt;4. Publishing the package&lt;/h3&gt;
&lt;p&gt;The next step is to publish the package. As before, we need to add a Build Step and select &lt;b&gt;NuGet Packages Publish&lt;/b&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img title="BuildStep4.png" alt="BuildStep4" src="http://blogs.jetbrains.com/dotnet/wp-content/uploads/2011/08/buildstep4.png" width="600" border="0" height="374" /&gt;&lt;/p&gt;
&lt;p&gt;This step is even easier to configure. By convention it uses nuget.org as the destination to publish the package. If you have your own NuGet server then fill in the address in the &lt;b&gt;Packages Sources&lt;/b&gt; field. If you&amp;#39;re using nuget.org, leave it blank. You need to provide your API key which is stored in a password protected field and finally indicate which packages you want published. Here you can list each package individually or use wildcards. [Note: relative paths are allowed but at the time of writing this post, there was an issue and I was using the full path. This should be fixed soon].&lt;/p&gt;
&lt;p&gt;If you want to publish to multiple sources, all you need to do is add another step. Note however that we did not have to specify an extra step to publish the sources to symbolsource.org. TeamCity will follow NuGet&amp;#39;s convention and do this for you automatically.&lt;/p&gt;
&lt;h3&gt;5. AssemblyInfo Patcher&lt;/h3&gt;
&lt;p&gt;Although this step is optional I recommend you use it. The AssemblyInfo Patcher is a new Build Feature added to TeamCity which temporarily patches all your projects AssemblyInfo.cs files to update the version number, and then reverts it back after the build is complete. This allows your build number, artifacts, packages and assemblies to all have the same version number. Adding this option is as simple as selecting it from the main project configuration screen:&lt;/p&gt;
&lt;p&gt;&lt;img title="AssemblyPatcher.png" alt="AssemblyPatcher" src="http://blogs.jetbrains.com/dotnet/wp-content/uploads/2011/08/assemblypatcher.png" width="600" border="0" height="164" /&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it. There&amp;#39;s nothing more to it. With a few simple build steps we have now fully automated packaging and publishing NuGet packages. As I mentioned initially, if you&amp;#39;ve got your project on CodeBetter, you already have this feature enabled. If you&amp;#39;re running your own server, just download the plugin and set it up. It&amp;#39;s very simple.&lt;/p&gt;
&lt;p&gt;Try it out and please give us your feedback!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=68133" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Tools/default.aspx">Tools</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/TeamCity/default.aspx">TeamCity</category></item><item><title>Coverage with TeamCity and dotCover with MSTest, NUnit or MSpec</title><link>http://devlicio.us/blogs/hadi_hariri/archive/2010/12/10/coverage-with-teamcity-and-dotcover-with-mstest-nunit-or-mspec.aspx</link><pubDate>Fri, 10 Dec 2010 11:26:00 GMT</pubDate><guid isPermaLink="false">40756a8b-6212-4073-9d98-6c26781577de:63891</guid><dc:creator>Hadi Hariri</dc:creator><slash:comments>17</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://devlicio.us/blogs/hadi_hariri/rsscomments.aspx?PostID=63891</wfw:commentRss><comments>http://devlicio.us/blogs/hadi_hariri/archive/2010/12/10/coverage-with-teamcity-and-dotcover-with-mstest-nunit-or-mspec.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As some of you know, we recently shipped &lt;a href="http://www.jetbrains.com/teamcity"&gt;TeamCity&lt;/a&gt; 6 which includes, out of the box, a bundled version of &lt;a href="http://www.jetbrains.com/dotcover"&gt;dotCover&lt;/a&gt;. What this means is that you can now get coverage reports for your code easily, and of course, for free if you&amp;rsquo;re using the Professional version of &lt;a href="http://www.jetbrains.com/teamcity"&gt;TeamCity&lt;/a&gt;.&amp;nbsp; The setup is quite easy if you are using MSTest and NUnit. For MSpec, you need to take a few additional steps.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;Using MSTest / NUnit Runners&lt;/h3&gt;
&lt;p&gt;Normally build files consist of a series of tasks that involve compilation and running of tests. With TeamCity, you can separate some of these steps out into individual TeamCity Build steps, which is what we will be doing in this case (everything that we see here applies to both MSTest and NUnit). &lt;/p&gt;
&lt;p&gt;Here is our build.xml (MSBuild) file:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_4AF768D1.png"&gt;&lt;img height="133" width="646" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_63A69014.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;As we can see, other than compiling a solution, which in this case consists of the actual application and the test assemblies, not much else going on. &lt;/p&gt;
&lt;p&gt;[Note: this could have been done using the SLN as the Runner Type under TeamCity since this example build script does not do much else. In real scenarios however, build scripts do more than just call a solution (in fact normally you&amp;rsquo;d call projects not solutions)]. &lt;/p&gt;
&lt;p&gt;In TeamCity, we create a new build project and setup the VCS root. We then add a new Build Step which calls this MSBuild file:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_534B185B.png"&gt;&lt;img height="499" width="642" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_61C61480.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Notice that all we are doing here is calling our MSBuild script. No coverage settings yet. &lt;/p&gt;
&lt;p&gt;Next thing is to add an additional build step in TeamCity. This time, we are going to call MSTest as opposed to MSBuild:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/SNAGHTML1e386e79_5F00_2B947664.png"&gt;&lt;img height="265" width="664" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/SNAGHTML1e386e79_5F00_thumb_5F00_6DD768DA.png" alt="SNAGHTML1e386e79" border="0" title="SNAGHTML1e386e79" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/SNAGHTML1e3d642d_5F00_3CF4B16F.png"&gt;&lt;img height="355" width="664" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/SNAGHTML1e3d642d_5F00_thumb_5F00_0EBAB5B5.png" alt="SNAGHTML1e3d642d" border="0" title="SNAGHTML1e3d642d" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;(the sections cut out are blank). &lt;/p&gt;
&lt;p&gt;In the &lt;strong&gt;.NET Coverage tool &lt;/strong&gt;section we select JetBrains dotCover and then&amp;nbsp; add the assemblies we want coverage for (just the name of the assembly) prefixing them with &lt;strong&gt;+:&lt;/strong&gt; and filtering out those we do not want coverage for with &lt;strong&gt;&amp;ndash;:&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;That&amp;rsquo;s all there is to it. Once we run the Build, we should now see a new tab with Coverage Reports as well as a new Artifact which contains the Coverage files zipped up. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_4B230492.png"&gt;&lt;img height="227" width="650" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_13F97699.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;The Code Coverage tab goes into more detail:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_06B2ED86.png"&gt;&lt;img height="219" width="664" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_3D4098CA.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We can even drill down into individual classes and examine the code coverage:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_45E0F156.png"&gt;&lt;img height="376" width="648" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_5770DC21.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;If we are using NUnit instead of MSTest, the only difference is there test runner we select when adding a new Build Step in TeamCity. Instead of MSTest we choose NUnit along with the version:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_3962A860.png"&gt;&lt;img height="284" width="659" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_00F48188.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h3&gt;What about MSpec or my Specific Test Runner?&lt;/h3&gt;
&lt;p&gt;If we are using MSpec or a different test runner that is not supported directly by TeamCity, we can still get coverage reports; we just need to do a little bit of additional configuration. TeamCity has an API which allows us to send it messages when we want to interact with it (this is actually quite a powerful feature but out of scope for this post so please leave a comment if you&amp;rsquo;d like me to cover it in more detail). We can leverage this API to tell it when to start coverage and where to get the results from. &lt;/p&gt;
&lt;p&gt;Here is the build script for MSpec: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_5D77DD22.png"&gt;&lt;img height="240" width="664" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_20933583.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;We have created two targets. The second one (TeamCity) is the one we are interested in. This does a couple of things:&lt;/p&gt;
&lt;p&gt;1. The first &lt;strong&gt;&amp;lt;Exec&amp;gt; &lt;/strong&gt;runs all MSpec tests so that we can see the test results inside TeamCity. This is not strictly necessary for Code Coverage but usually build processes do display these results. The --&lt;strong&gt;teamcity &lt;/strong&gt;option we are passing in to MSpec is for it to generate the system messages that are then fed to TeamCity (see point 3)&lt;/p&gt;
&lt;p&gt;2. The second &lt;strong&gt;&amp;lt;Exec&amp;gt; &lt;/strong&gt;is the one that runs dotCover. This uses a configuration file called dotCover.xml which we will examine further down. We pass in the c (or coverage) option when calling dotCover. &lt;/p&gt;
&lt;p&gt;3. This is a message we send to TeamCity to tell it that we have run coverage. We indicate the tool we are using (&lt;strong&gt;dotcover &lt;/strong&gt;in this case) and where the results are located. TeamCity uses this information to then display the results in the UI. This is one of the API messages mentioned earlier. &lt;/p&gt;
&lt;p&gt;Finally we need to define the dotcover.xml file with out configuration for running dotCover (for detailed information on creating &lt;a href="http://www.jetbrains.com/dotcover"&gt;dotCover&lt;/a&gt; configuration files, see &lt;a href="https://hhariri.wordpress.com/2010/07/28/running-code-coverage-from-the-console-with-dotcover/"&gt;here&lt;/a&gt; and &lt;a href="https://hhariri.wordpress.com/2010/08/05/advanced-scenarios-with-dotcover-console-runner/"&gt;here&lt;/a&gt;):&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_7180D3DE.png"&gt;&lt;img height="581" width="673" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_6476CE00.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;In terms of TeamCity, we then just define our build step that calls out to the build script:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_7C1DDF99.png"&gt;&lt;img height="472" width="588" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_553FA38C.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Notice how we do not specify &lt;strong&gt;.NET Coverage &lt;/strong&gt;options explicitly. And if all goes well, we can see the coverage output just as before: &lt;/p&gt;
&lt;p&gt;&lt;a href="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_113BBF75.png"&gt;&lt;img height="296" width="684" src="http://devlicio.us/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/hadi_5F00_hariri/image_5F00_thumb_5F00_0793513F.png" alt="image" border="0" title="image" style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" /&gt;&lt;/a&gt; &lt;/p&gt;
&lt;h3&gt;Summary&lt;/h3&gt;
&lt;p&gt;We can see that running code coverage is now pretty straightforward when using MSTest, NUnit or even a custom test runner. Most of what we have covered for MSpec will work with pretty much any test runner in terms of coverage (feel free to vote &lt;a href="http://youtrack.jetbrains.net/issue/TW-14864"&gt;here for MSpec support&lt;/a&gt;). &lt;/p&gt;
&lt;p&gt;With any build process, there are numerous ways of doing the same thing. I&amp;rsquo;m going to show you one of them. Based on your setup and needs you might want to do things differently. Fortunately TeamCity is flexible enough to allow for many scenarios. &lt;/p&gt;
&lt;p&gt;One thing to be aware of is that dotCover creates some temporary files for the XmlSerailizer in the Temp profile folder. This normally is not a problem unless the folder does not exist. If you are running TeamCity under the SYSTEM account, make sure that the folder C:\Windows\system32\config\systemprofile\AppData\Local\&lt;strong&gt;Temp &lt;/strong&gt;exists. This will probably change in future versions so to avoid any possible issues. &lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://devlicio.us/aggbug.aspx?PostID=63891" width="1" height="1"&gt;</description><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/Tools/default.aspx">Tools</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/MSpec/default.aspx">MSpec</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/dotCover/default.aspx">dotCover</category><category domain="http://devlicio.us/blogs/hadi_hariri/archive/tags/TeamCity/default.aspx">TeamCity</category></item></channel></rss>