Features How-To's Tips & Tricks

TeamCity integration with .NET, Part 3: Deploying projects

Today we are wrapping up our .NET integration demo. In this series, we’ve been explaining how TeamCity can integrate with .NET and walking you through a tutorial. To catch up with the demo, read the previous posts:

  • Part 1: New approach and demo
  • Part 2: Testing and building projects

This project has already been built on the demo TeamCity server. You can sign in as a guest and explore the build results. Or, fork the source repo and build the project yourself.

After we tested and built our applications for different platforms, we can finally pack and deploy them!

Creating NuGet packages

The "Pack" build configuration has only one .NET step:

NuGet pack

It executes the pack command to create NuGet packages for Clock and Clock.IoC projects. These projects are responsible for implementing the common logic for all apps.

You might remember that we specified all metadata of these packages, such as name or repository type, via system parameters of the "Pack" configuration. See Part 1 for details.

A successful "Pack" build produces NuGet packages as build artifacts. We will send these packages to a repository on the deployment stage.

Collecting artifacts

The high-level "Build" configuration is a special one: it has zero steps but multiple artifact dependencies on other configurations. This is just a little trick to bring all their artifacts together in one location:

Build artifacts

Deploying apps and packages

Finally, it’s time to deploy. The high-level "Deploy" configuration doesn’t have any steps as well. But, it has several dependencies on other configurations from the "Deployment" subproject:

  • The "Push image…" configurations create and publish images for Linux and Windows.
  • The "Push multi-arch image…" configurations create and publish manifests for multi-architectural Docker images.
  • The "Publish to NuGet" configuration publishes the previously created NuGet packages to the TeamCity NuGet feed.

To connect the specific projects to the the NuGet packages with the common logic, you can use this NuGet source.

If you’ve been following the tutorial, now it’s time to trigger the "Deploy" build and wait while TeamCity consequently builds the whole chain:

Build chain

After the successful deployment, you can launch Clock.Console apps in Docker using the following commands:

docker pull <user>/clock-console
docker run -it --rm <user>/clock-console

For Clock.Web:

docker pull <user>/clock-web
docker run -it --rm -p 5000:5000 <user>/clock-web

The web app will be available in your browser at http://localhost:5000/.

Other apps and packages will be accessible in build artifacts of the "Build" configuration (see it on the demo server).

Conclusion

Congratulations! We are done with the demo, and, hopefully, you were able to explore the project on our server or build it yourself.

Microsoft is actively developing .NET 5 in order to provide developers with a single free toolset, enough for building projects of any scale, on any platform. We believe our new .NET runner will allow you to integrate .NET 5 projects with ease.

If you have already tried the new runner and want to share your feedback, please leave the comments.

Helpful links:

Happy building and happy new year!

image description