Native NuGet Support in TeamCity

 

A few months ago, Scott Hanselman 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 blogged about it here.

Instead of delaying until the next release of TeamCity, this feature (like many), has been developed as a plug-in. Eugene, 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 YouTrackSharp to automate the publishing of the NuGet package. It was surprisingly easy as you'll see.

1. Installing the Plug-in

If your project is running on TeamCity at Codebetter.com, you can skip to Step 3, since it's already installed and configured. If not, then grab the latest build from our public TeamCity server. Place the zip file into the plugins folder of your TeamCity installation and restart the server.

2. Configuring the NuGet version

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 Administration | Server Configuration. If the plug-in installed correctly, you should now have a new Tab called NuGet:

AdminPanelNuGet

Click on the "Install additional versions of the NuGet.exe Command Line". TeamCity will read from the feed and display available versions to you in the dialog box. Select the version you want and click Install:

NuGetVersion

Pull, Pack, Publish

The plug-in offers three main operations:

  • Pulling NuGet packages required to build your project
  • Creating NuGet packages
  • Publishing Packages

In my case, I want to create the package and publish it. To give you a general idea of my build process, here's the outline of the build steps:

BuildOverview

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.

3. Building the package

This step is for building the actual package. We create a new Build Step in our project and select NuGet Packages Pack. This will give us the following configuration screen:

Step3

As you can see, the configuration is pretty straightforward. Notice that in the Specification file, we can also provide a csproj 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're not familiar with this feature, check out David Ebbo's post.

I've also checked the option to Include Sources and Symbols. This is also explained in David Ebbo's post and it's for publishing the sources to Symbolsource. Additional command line parameters (if required) can be passed in the Additional Commandline arguments. If you want to make this a release build, you can also do this by defining Configuration=Release in the Properties field.

Finally I'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'll show you as the last step.

4. Publishing the package

The next step is to publish the package. As before, we need to add a Build Step and select NuGet Packages Publish.

BuildStep4

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 Packages Sources field. If you'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].

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's convention and do this for you automatically.

5. AssemblyInfo Patcher

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:

AssemblyPatcher

That's it. There'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've got your project on CodeBetter, you already have this feature enabled. If you're running your own server, just download the plugin and set it up. It's very simple.

Try it out and please give us your feedback!


Posted 08-24-2011 10:01 PM by Hadi Hariri
Filed under: ,

[Advertisement]

Comments

Mary wrote re: Native NuGet Support in TeamCity
on 02-21-2012 9:49 PM

OSS's prmraiy beneficiary is and should be yourself. You're welcome to seek compensation for it, but you can't demand it. Not sure what MVP's have to do with it though since this post isn't about MVP's  .

Nabila wrote re: Native NuGet Support in TeamCity
on 02-23-2012 9:16 PM

I agree with George here. If your hobby helps orhtes I think is legitimate to seek some kind of compensation.Also, don't believe everything the IP lobbies say. I'm not sure things in Spain are so bad

social bookmarking link wrote re: Native NuGet Support in TeamCity
on 01-18-2013 4:49 PM

P6rpJ5 Great, thanks for sharing this article post.Thanks Again. Will read on...

discount stendra wrote re: Native NuGet Support in TeamCity
on 01-27-2013 5:43 AM

c62YoJ Appreciate you sharing, great blog article.Thanks Again. Want more.

loss weight pills wrote re: Native NuGet Support in TeamCity
on 02-01-2013 12:40 AM

XiJqnO Thank you ever so for you article post.Really thank you! Keep writing.

buy viagra online wrote re: Native NuGet Support in TeamCity
on 02-02-2013 11:57 PM

uAuq6I Thanks a lot for the blog article.Really looking forward to read more. Cool.

buy discount viagra wrote re: Native NuGet Support in TeamCity
on 02-03-2013 5:24 PM

wBUqqn Thank you ever so for you blog.Really looking forward to read more. Want more.

http://bestmedicineonline.info wrote re: Native NuGet Support in TeamCity
on 02-14-2013 11:15 AM

eXYUGl Fantastic post.Thanks Again. Will read on...

http://bestmedicineonline.info wrote re: Native NuGet Support in TeamCity
on 02-15-2013 4:03 PM

KW6BS7 Thanks for sharing, this is a fantastic article.Thanks Again. Great.

buyviagra online wrote re: Native NuGet Support in TeamCity
on 02-24-2013 2:07 PM

P8rN9V I really liked your blog article.Thanks Again. Fantastic.

clomid no prescription wrote re: Native NuGet Support in TeamCity
on 02-25-2013 4:22 AM

25kqOe I cannot thank you enough for the post.Really thank you! Really Cool.

clomid no prescription wrote re: Native NuGet Support in TeamCity
on 02-27-2013 5:45 PM

RVoUy8 I think this is a real great article.Really thank you! Great.

clomid no prescription wrote re: Native NuGet Support in TeamCity
on 02-27-2013 7:52 PM

4A7zId Hey, thanks for the article.Really looking forward to read more. Really Great.

buy viagra wrote re: Native NuGet Support in TeamCity
on 03-02-2013 11:12 AM

d6lM0D I think this is a real great post.Really thank you! Cool.

click here wrote re: Native NuGet Support in TeamCity
on 03-03-2013 12:08 PM

6mNZT6 Thank you for your blog.Really thank you! Really Cool.

bookmaring service wrote re: Native NuGet Support in TeamCity
on 03-13-2013 11:10 AM

Kqu3oj Really informative blog post.Really looking forward to read more.

bookmarks wrote re: Native NuGet Support in TeamCity
on 03-13-2013 12:15 PM

Udis6v I appreciate you sharing this article post.Really thank you! Want more.

bookmarks wrote re: Native NuGet Support in TeamCity
on 03-14-2013 8:13 PM

mbYzAi I am often to blogging and i really appreciate your content. The article has really peaks my interest. I am going to bookmark your site and keep checking for new information.

buy social bookmarks wrote re: Native NuGet Support in TeamCity
on 03-23-2013 2:29 AM

bxlYhZ Thanks for sharing, this is a fantastic article.Really looking forward to read more. Fantastic.

buy social bookmarks wrote re: Native NuGet Support in TeamCity
on 03-24-2013 10:25 AM

DEJNN0 A round of applause for your blog post.Thanks Again. Want more.

buy social bookmarks wrote re: Native NuGet Support in TeamCity
on 04-03-2013 5:15 AM

umRwtt I value the blog post.Really thank you! Much obliged.

Social bookmarks wrote re: Native NuGet Support in TeamCity
on 04-03-2013 7:58 AM

c7klaE Wow, great post.Really thank you!

comedy shirts wrote re: Native NuGet Support in TeamCity
on 04-05-2013 1:11 PM

A round of applause for your article post.Really thank you! Keep writing.

funny shirts wrote re: Native NuGet Support in TeamCity
on 04-05-2013 2:55 PM

Great article. Want more.

Social bookmarks wrote re: Native NuGet Support in TeamCity
on 04-07-2013 1:48 PM

TKQQLf A big thank you for your blog post. Cool.

buy social bookmarks wrote re: Native NuGet Support in TeamCity
on 04-07-2013 4:33 PM

8A2iVV I loved your post. Fantastic.

social bookmarking service wrote re: Native NuGet Support in TeamCity
on 06-06-2013 7:20 PM

W8fYUv Very good article.Really looking forward to read more. Want more.

best social bookmarks wrote re: Native NuGet Support in TeamCity
on 06-19-2013 12:14 PM

iDCt3u Looking forward to reading more. Great blog. Awesome.

good social bookmarks wrote re: Native NuGet Support in TeamCity
on 06-21-2013 7:44 PM

ha2maD Wow, great blog post.Much thanks again. Will read on...

news and many more wrote re: Native NuGet Support in TeamCity
on 07-04-2013 10:15 AM

JS6IcE Really appreciate you sharing this blog article.Thanks Again. Much obliged.

news wrote re: Native NuGet Support in TeamCity
on 07-13-2013 8:32 AM

LE4CeJ I appreciate you sharing this blog. Will read on...

buy viagra online cheap wrote re: Native NuGet Support in TeamCity
on 07-23-2013 3:42 PM

Really appreciate you sharing this article.Really thank you! Keep writing.

click here wrote re: Native NuGet Support in TeamCity
on 07-24-2013 5:20 PM

Looking forward to reading more. Great post.Thanks Again. Fantastic.

buy social bookmarks wrote re: Native NuGet Support in TeamCity
on 07-29-2013 8:16 AM

T1plee Thank you for your article.Really thank you! Cool.

best news wrote re: Native NuGet Support in TeamCity
on 08-02-2013 10:21 AM

Appreciate you sharing, great blog post.Thanks Again. Will read on...

best news wrote re: Native NuGet Support in TeamCity
on 08-02-2013 2:49 PM

rEu838 Appreciate you sharing, great blog article.Really thank you! Really Cool.

news news news news wrote re: Native NuGet Support in TeamCity
on 08-05-2013 1:45 AM

bdFp0g Thanks a lot for the article post.Much thanks again.

great link buildng wrote re: Native NuGet Support in TeamCity
on 08-19-2013 7:23 AM

MKCXeE Thanks-a-mundo for the blog article. Really Great.

awesome links for you wrote re: Native NuGet Support in TeamCity
on 08-19-2013 9:29 PM

Ji6td8 Fantastic blog article.Thanks Again. Much obliged.

great link buildng wrote re: Native NuGet Support in TeamCity
on 08-21-2013 6:36 AM

pmV45i Really appreciate you sharing this post.Much thanks again. Much obliged.

buy viagra online cheap wrote re: Native NuGet Support in TeamCity
on 09-02-2013 5:04 AM

I really like and appreciate your blog.

link building wrote re: Native NuGet Support in TeamCity
on 09-06-2013 8:23 AM

hQvVfE Thanks-a-mundo for the blog article.Really thank you! Really Great.

visit now wrote re: Native NuGet Support in TeamCity
on 09-08-2013 6:20 AM

Thanks so much for the post.Much thanks again. Keep writing.

make money online wrote re: Native NuGet Support in TeamCity
on 09-11-2013 5:20 PM

lMctwc Wow, great blog.Really thank you! Really Cool.

only for 5 dollars wrote re: Native NuGet Support in TeamCity
on 09-13-2013 12:46 PM

OImMCP I really like and appreciate your article.Much thanks again. Awesome.

awesome link building wrote re: Native NuGet Support in TeamCity
on 09-24-2013 7:31 AM

F2o7zJ Thank you for your blog article.Really thank you! Really Great.

check out seo wrote re: Native NuGet Support in TeamCity
on 09-29-2013 7:55 AM

R3T57Z I cannot thank you enough for the blog.Really looking forward to read more. Awesome.

link building team wrote re: Native NuGet Support in TeamCity
on 09-30-2013 6:09 PM

VTJdtJ wow, awesome blog article.Thanks Again. Great.

best link build wrote re: Native NuGet Support in TeamCity
on 10-15-2013 10:06 PM

wzWaF9 Great article post.Really thank you!

top seo guys wrote re: Native NuGet Support in TeamCity
on 10-26-2013 5:22 PM

SU2tFr Im grateful for the blog post.Much thanks again. Much obliged.

crorkservice wrote re: Native NuGet Support in TeamCity
on 07-18-2014 8:02 PM

JAJBYj Thank you for your article post. Want more.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)