Team City fails to create Octopack .nupkg from .Net Core Api

I have added the latest Octopack to my .Net Core api using the package manager console.
My team City job uses the
Runner type .NET
Command build
Projects “api/Solution file name here”
Command line Parameters -p:PackageVersion=%build.number%

The web api references a couple of other projects in my solution

As a work around, I have tried creating the package thro the .csproj,
TeamCity now shows the nupkg in my artifacts but only the project dll is in the nupkg and no other nuget references or project dll files

Appreciate any help on this?

TLDR: Team city does not create a .nupkg for .net core api with Octopack nuget.

Hi @Cyril,

Thanks for getting in touch!

I don’t believe that octopack is compatible with .NET Core applications.
Instead, we have a TeamCity plugin that allows you to add individual steps for creating and pushing packages to Octopus regardless of the project or package type.
Full details can be found here: TeamCity - Octopus Deploy


1 Like

Thanks for the quick reply Paul. I’ll take a look at the link you sent.
The Octopus plugin is installed in Team City.
I don’t have write access to TC so need to put the info together for our build team.
I currently have a Build Step, do I just need to add a Pack step in order to create the .nupkg?

That’s correct, the Pack step will be configured to target your build directory and will pack everything it finds there into the .nupkg.

Depending on your pipeline you may also want the Push step to upload the .nupkg to the Octopus Server and a Push Build Information step to include any commit/work item information.

1 Like

Thanks Paul. I have the Pack step working but it seems I am missing a hostfxr.dll in order to self host my api as a windows service.
I can see when I manually publish my app locally that this file is created but is not part of the nupkg when I Pack.
Do I need to create a publish step before my Pack step?

When the Pack step runs it will grab all files in the source folder specified.
Is hostfxr.dll a dependency or referenced file that isn’t being built along with the other files?

1 Like

Paul, the hostfxr.dll is not in the source folder.
I can see when I publish from with Visual Studio that this file and a bunch of other .netcore dll’s get copied to the publish folder.
Seems my api depends on the hostfxr.dll in order to be a self hosted windows service

So, it looks like when the application is being built it is expecting the machine that runs the application to have .NET Core installed. This is where the hostfxr.dll and other .netcore dlls would come from.

I believe you can change this so that your application is built as a self-contained .NET Core app that wouldn’t have this dependency.
Adding the following to your csproj file should enable this.


Building it as a self-contained app in this way may cause the package size to inflate in size though, so, you could take a look through this to trim it down if necessary: Trim self-contained applications - .NET | Microsoft Docs

1 Like

Thanks Paul, that got the .net core files generated.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.