- Trigger a new version of the Class Library to be built
- A nuget package created with the new version number of the class library included in the name of the package.
- The package will be moved to a network shared location where the other team members can consume the package
Now we create a MSBuild file and add and call the following targets:
<Target Name="CreatePackage">
<Exec WorkingDirectory="$(WorkingFolder)"
Command="$(NuGetApp) spec -f" />
<Exec WorkingDirectory="$(WorkingFolder)"
Command="$(NuGetApp) pack MyProject.csproj -Verbose -Prop Configuration=Release" />
</Target>
<Target Name="MovePackage">
<Exec WorkingDirectory="$(WorkingFolder)"
Command="move /y *.nupkg $(PackageDir)" />
</Target>
The NugetApp variable represents the path to the Nuget.exe command line utility used to create the Nuget package. In my case, I downloaded the utility into a folder on the same level as the working folder and named it "Tools" with subfolder "Nuget", I set the NugetApp property to like so:
<NugetApp>$(WorkingFolder)/../Tools/Nuget/Nuget.exe</NugetApp>
The PackageDir property is whatever network share location of your choice.
Now run your your MSBuild file in TeamCity.
Happy building!!!.