We’ve just deployed support for service messages in MyGet Build Services. With them, you can interact with our build agent by simply writing a message to the build output. This makes it easy to work with them from any build framework used, be it a simple batch file, PSAKE, MSBuild or others.
But what can you do with them? Why are they useful? There are a couple of situations that come to mind:
- NuGet packages are typically versioned using the
%PackageVersion%environment variable. With service m, the package version variable can be overridden so you are in complete control of the package version number.
- When using pre- or post-build steps, service messages can be used to set environment variables for the actual build. Sure, you can also do this from the UI but if the build generates the values, it’s much more useful to do this using service messages.
- When does a build fail? MyGet fails the build if compilation fails and when no NuGet packages are generated. If you want to be in control of when a build fails or succeeds, a service message can be written to fail the build at the location and condition of your choice. This gives a much more reliable build status.
A service message looks like this:
##myget[buildNumber '1.0.0-beta1']. We also support a subset of TeamCity service messages. This makes your builds more portable between build systems and gives you more control of the build process. More information is available from our documentation.
Happy building, and happy packaging!