1
votes

I'm have command line tool built as a NuGet by TeamCity.

My problem is that I would like to use the tool in a build step within the same TeamCity server and the execute the command line tool as part of the step.

The easiest way would be to just compile the command line tool and create an artifact without creating a NuGet and then take an artifact dependency in the other build process and execute the command.

But I would like to know if it's possible to do the same with a NuGet package so I can reuse the tool for other purposes?

Update After some more testing with TeamCity I think the main issue is that the "NuGet Installer" runner requires a solution file. I can do what I want with a powershell task:

# install the latest package 
%teamcity.agent.tools.dir%\NuGet.CommandLine.2.7.1.nupkg\tools\NuGet.exe install octospike-migrator -o tools -excludeversion -source %teamcity.nuget.feed.server%
# run the command line tool
.\tools\octospike-migrator\lib\Octospike.Command.exe

The build step above is working a intended but I have the feeling that the default runner "Nuget Installer" should be able to handle this?

I'm running TC7 so it might be working in TC8

1

1 Answers

1
votes

Assuming the package is referenced in your solution and you have enable missing package restore enabled, the package will be downloaded and unpacked into your solution. The executable will go into a known location (whatever directory you've specified for the package). You should then be able to access the executable as you would any other resource.

If you need flexibility in regards to where and how the resources are unpacked (e.g., if they need to go in a directory outside of the project), you can build this as a Tools package in NuGet.

In TeamCity, the complexity will be reduced if you break this process into separate tasks.