6
votes

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.

1
What arguments are you passing to nuget pack? It looks like there are multiple questions here, you may want to consider splitting them up so they are less coupled. The best Stack Overflow questions are ones that can help other people too.Daniel Little
So, it's a bit a different approach, but since you want to simplify your deployment approach, what about just deploying right out of TeamCity? BuildMaster can import and deploy your TeamCity builds without needing to get NuGet involved at all. Disclaimer: i work for inedo.Karl Harnagy

1 Answers

11
votes

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).