AppVeyor configuration project version patching clarification

📆

👤

AppVeyor is a CI environment that can build projects of various types, like .NET 6.0 projects. It is highly customizable, given that you can either use its own way of building projects, or you can provide scripts for building projects. You can not only insert scripts before and after building, but you can also insert scripts for each and every event, like before testing, job success, environment initialization, and so on.

You may have heard of the AppVeyor.yml file when you’re looking at open-source projects that use this service to check to see if the build is going well or not. Some C# and Visual Basic projects that use the .NET SDK format even have their versions patched to match the version with build information, branch, and whatever else.

We had .NET Core project patching enabled to only patch the NuGet package version and leave everything else alone. All went well until we migrated to appveyor.yml in the root of the repo. Since then, we had builds failing because the version wasn’t conforming to semantic versioning standards.

This is the file that we added: appveyor.yml

We narrowed the issue down to this:

dotnet_csproj:
patch: true
file: ReadLine.Reboot\ReadLine.Reboot.csproj
package_version: 3.3.1-build{build}

Apparently, if we didn’t specify the patching information for all entries that contains Version in our appveyor.yml, they’ll be patched to the main version specifier, which is found at the top of the file:

version: v3.x-{build}

…according to the build logs here:

Patching .NET Core project files
Patching Version in ReadLine.Reboot\ReadLine.Reboot.csproj...OK
Patching PackageVersion in ReadLine.Reboot\ReadLine.Reboot.csproj...OK
Patching AssemblyVersion in ReadLine.Reboot\ReadLine.Reboot.csproj...OK
nuget restore "%APPVEYOR_BUILD_FOLDER%\ReadLine.Reboot.sln"

We only needed to patch the PackageVersion property because we needed to roll the staging NuGet versions of our libraries, so we suppressed the *_version and version entries as illustrated in this commit:

dotnet_csproj:
patch: true
file: ReadLine.Reboot\ReadLine.Reboot.csproj
version: ''
package_version: '3.3.1-build{build}'
assembly_version: ''

As a result, the file now looks like this. When we pushed the changes, we saw that AppVeyor now builds like before, patching the package version property as needed:

Patching .NET Core project files
Patching PackageVersion in ReadLine.Reboot\ReadLine.Reboot.csproj...OK
nuget restore "%APPVEYOR_BUILD_FOLDER%\ReadLine.Reboot.sln"

The system successfully pushed the latest staging version of the package to NuGet.org as in this link.

Enjoy!


Discover more from Aptivi

Subscribe to get the latest posts to your email.

Thoughts?

Subscribe to our newsletter?

Subscribe today to get new articles instantly delivered to you!

Not now

Design a site like this with WordPress.com
Get started