Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publishing NuGet Packages - TeamCity

I have just setup TeamCity to automate our builds, our current solution has both a dev and main branch. What I am trying to achieve is to have the development branch build and publish to a development NuGet feed on our ProGet installation, and then have the main branch publish to our Main NuGet feed on ProGet server.

We are using octopus deploy to deploy the packages, within TeamCity we have the octopus deploy plugin installed and if I tick the box to run OctoPack it builds the packages and they appear as artifacts when the build completes. If I try to use the NuGet Pack build step in TeamCity I get the following error for one of our projects:

[08:33:49] :         [pack] Attempting to build package from 'xxx.csproj'.
[08:33:50]W:         [pack] Unable to find 'xxx.exe'. Make sure the project has been built.

The project has been built and it works with OctoPack so why isn't it working with the NuGet Pack? Wwe have five projects being built and the first four run fine, one is a console app, one is an mvc website, and two are class libraries. The one that doesn't work is a windows service.

The end goal here is to publish these packages to a private feed on ProGet. I don't mind using OctoPack but in my head wanted to remove that dependency from TeamCity but I can live with it. However when I try to use the NuGet Publish runner type how do I select to publish any NuGet artifacts that have been created?

I have been googling like mad and I cannot find any helpful links that describe what you are supposed to enter, I would really appreciate any helpful comments/answers.

We are using version 8.15 of TeamCity.

like image 970
user351711 Avatar asked Oct 25 '14 08:10

user351711


People also ask

How do I publish a NuGet private repository?

Go to Tools > NuGet Package Manager > Package Manager Settings, select Package Manager Sources, and then click the + button. Choose feed Name, set the feed URL to: https://nuget.telerik.com/nuget, and click OK. Create or load your project. Go to Tools > NuGet Package Manager > Manage NuGet Packages for a solution.


1 Answers

Hopefully the following will help with at least part of your question; mainly the bit relating to how to publish packaged artifacts.

NuSpec Approach

When using the NuGet Pack build step, you can specify the Output Directory, which will determine the output location of the packages. You can specify this as a relative path to the checkout directory, probably best to define it as a build parameter, such as %system.PackageDeployOutput% as you'll be using it in the next step...:

Next, specify a NuGet Publish build step, fill in the Package Source / API key etc, and specify the Packages to upload as

%system.PackageDeployOutput%\*.nupkg

This will pick up the packages output in the previous step. I've used this quite effectively, and the parameterisation approach encourages conventions across all your builds.

OctoPack Support

If you're using the MsBuild build step with OctoPack, you can use a similar approach by declaring a system parameter called

system.OctoPackPublishPackageToFileShare = %teamcity.build.checkoutDir%\%system.PackageDeployOutput% (note the same parameter as above)

You can declare these as root project parameters, so you get the best of both worlds. My preferred approach to packaging is currently to use nuspec files for deployable endpoints. I've found OctoPack to be a bit of an overhead when it comes to more complex deployments (it's fine for basic MsBuild projects).

like image 107
SteveChapman Avatar answered Oct 10 '22 22:10

SteveChapman