0

I am trying to create Team City build template which requires minimum customisation, and I want it to play nicely with legacy projects and projects developed with .NET Core/Standard and .NET CLI. I am stuck with NuGet as there were some considerable changes in how things work.

Earlier we had to create nuspec file to pack project as a NuGet package. At least in that file we could define various package-related properties.

New csproj file format allows us to define all package properties inside itself. That's fine, but how then do we know which projects should be packaged and which should not?

So far our TeamCity's build step Pack NuGet just contained **.nuspec for Specification files: field. The very fact of nuspec file presence served like a flag pack & publish this project.

However, for dotnet pack we need to specify the project. There is no simple way to distinguish 'main' projects from 'auxiliary' ones on which mains depend. (Let us ignore that project-to-project references are currently not supported.)

We either could pack all projects specifying **.*proj (yet in that case we are to know which packages to publish) or we might specify projects explicitly in a build configuration, but I don't like this approach because you must edit build configuration each time new project is added to the solution.

I also considered the option Generate package on build and omit dot net pack step as package is created on build. The only thing left is publishing the packages with dotnet nuget push specifying **/%BuildConfiguration%/*.nupkg. Unfortunately when starting build against solution without projects with enabled Generate package on build makes TC fail complaining that

Target files not found for pattern "**/Release/*.nupkg"

Hence, I either need another recipe for achieving the required result or an advice how to make TC consider empty result just as a NOP and mark build as successful.

Yet another option is to use nuspec even for new csproj...

Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137

1 Answers1

1

Since TeamCity 2017.2 will be available option to associate build configuration with multiple templates. So you will be able to create different templates to create packages for old projects and new .NET CLI projects.

To specify paths for target .NET projects, which should be packaged, you could use build configuration parameters.

To set such parameters during the build you could send in the preceding build step service message. The value of this parameter could be set to the list of target project files which could be selected via script like that: https://stackoverflow.com/a/8153857/305875

dtretyakov
  • 373
  • 4
  • 10