[HOWTO] PowerShell NuGet package creation with JetBrains TeamCity

Hi, this is Marc Rufer from d-fens GmbH. I started working at d-fens as a Software Engineer this week. I already wrote some posts and I’ll continue sharing information about my work on this blog.


In todays blog post I’ll explain step by step how to set up a build configuration for a PowerShell-Project on a JetBrains TeamCity 9 server.

Creation of PowerShell build configuration

The build configuration will be responsible to create a NuGet-package out of the PowerShell scripts. To show the build configuraiton I used the PS.System.Utilities project, which is available on GitHub, as sample.


  • Running TeamCity instance (Setup manual can be found here)
  • NuGet has to be enabled as described in the setup manual

Step by step manual
1. Log in to your TeamCity server and go to the Administration board
2. Click Create project from URL
3. Select the parent project, enter the repository URL and the repository credentials
4. Define the project and build config names
5. Next, TeamCity will scan the source code and try to auto detect some build steps
6. Choose the desired build steps out of the recommendations
7. To adjust the build step click on edit in the row of the build step
8. [OPTIONAL] Create a build trigger (for more details see Trigger build on commit to VCS)
9. Now the build configuration is ready to run

Upload generated package to NuGet-Server

The distribution of the NuGet package to a NuGet repository can be directly integrated into the build process. To integrate the distribution into the build process you have to perfrom the following steps.

  1. Go to the projects build configuration settings
  2. Navigate to Build Step: NuGet Pack in left menu
  3. Add a new build step of type NuGet Publish
    Under package files you can define which packages should be uploaded.
  4. Now the build configuration is ready to run


The following message appeared in the build log.

[push] Failed to process request. ‘The specified API key is invalid or does not have permission to access the specified package.’.

The API key was valid, so I searched for the reason of the problem and found a discussion on stackoverflow with the answer to the problem. The same message appears in the build log if the package already exists on the nuget repository.

The TeamCity Free Open Source License was generously provided by JetBrains

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: