I am using the latest (as of today) .NET Core tooling. There, you specify version in an <Version> MSBuild property. However, unlike [assembly:AssemblyVersion], this does not appear to support wildcards. How do I make version increment automatically in the same way?
Explaining why this is a bad idea, and what should be done instead would also be a good answer.
The Version property in MSBuild does not support asterisks (wildcard) format as project.json did.
However, with MSBuild you can compute a version in other ways. There is no one right way to do it, but here is one approach. We use "VersionPrefix" instead. Microsoft.NET.Sdk will also automatically combine VersionPrefix and VersionSuffix to form the final value of "Version".
In file:
<PropertyGroup>
<VersionPrefix>2.0.0</VersionPrefix>
</PropertyGroup>
On build server:
msbuild.exe /t:Pack /p:VersionSuffix=build00123
// or, the dotnet.exe equivalent
dotnet pack --version-suffix build00123
Result:
AssemblyVersion = 2.0.0.0
Package version = 2.0.0-build00123
Our build server generates the build number on each run.
If you want to use the old-school AssemblyVersion asterisk form, you can explicitly set the <AssemblyVersion>
property in MSBuild. If not, this defaults to the major.minor.patch value of <Version>
.
More details:
There are half-a-dozen "version" settings in Microsoft.NET.Sdk. See What is the difference between various MSBuild version properties, such as Version, VersionPrefix, and VersionSuffix? for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With