Publishing NuGet Packages - TeamCity

I just installed TeamCity to automate our builds, our current solution has both a dev and a main branch. What I'm trying to achieve is to create a development branch and publish it to NuGet to develop our ProGet installation, and then publish the main branch in our Main NuGet channel on the ProGet server.

We use octopus deployment to deploy packages, in TeamCity we have the octopus deploy plugin installed, and if I check the box to start OctoPack, it will create packages and they will appear as artifacts when the assembly is complete. 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 was built and works with OctoPack, so why doesnโ€™t it work with NuGet Pack? We have five projects that are under construction, and the first four are working fine, one is a console application, one is the mvc website, and two are class libraries. One that does not work is a Windows service.

The ultimate goal here is to publish these packages on the ProGet personal channel. I am not against using OctoPack, but in my head I wanted to remove this dependency on TeamCity, but I can live with it. However, when I try to use the NuGet Publish runner type, how do I choose to publish any NuGet artifacts that were created?

I searched the search terms like crazy, and I cannot find useful links that describe what you should enter, I would really appreciate any useful comments / answers.

We are using TeamCity version 8.15.

+5
source share
1 answer

I hope the following helps, at least as far as your question is concerned; mostly a bit related to how to publish packaged artifacts.

NuSpec Approach

When using the NuGet Pack build phase, you can specify an Output Directory that will locate the output of the packages. You can specify this as a relative path to the checkout directory, perhaps it is best to define it as a build parameter, for example %system.PackageDeployOutput% , since you will use it in the next step ...:

Next, specify the build step of NuGet Publish , fill in the "Package Source / API" key, etc. and specify packages to download as

%system.PackageDeployOutput%\*.nupkg

This will display the packages in the previous step. I have used this quite effectively, and the parameterization approach encourages conventions in all of your builds.

OctoPack Support

If you use the MsBuild build step with OctoPack , you can use a similar approach by declaring a system parameter with the name

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

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

+9
source

Source: https://habr.com/ru/post/1205488/


All Articles