Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net 5 Semantic Versioning

It seems that versioning works differently than in previous versions of .Net. The project.json seems to use semantic versioning (from what I have seen online) with the format Major.Minor.Patch-Special.

  1. Does this replace the Assembly version idea or add to it? Or does it just get used with Nuget.
  2. How does one access the version during runtime. I came across Nuget.SemanticVersion object online in the Microsoft.Framework.Runtime package but I can't find out how to retrieve it in code.
  3. Is there a programmatic way to update this value on a build or just custom scripts?
like image 952
Gekctek Avatar asked Aug 05 '15 18:08

Gekctek


1 Answers

I wouldn't say that versioning has changed in a particularly dramatic way. In a version number x.y.z, the "x" means "big changes / breaking changes," the "y" means "minor additions and fixes," and the "z" means "very minor fixes." That's pretty close to what Semantic Versioning (SemVer) states.

In a project.json-based project, there is only one place to specify the version, and that's in the project.json file itself. That one version is a SemVer (e.g. x.y.z-prerel) and is used for the NuGet package version and the assembly version, and the assembly informational version. If you've explicitly set the assembly version or informational version in the assembly, those will be respected and not overridden. (You can see the code here.)

At runtime you can read the assembly version through reflection (just like you always could).

When running in a DNX application there's also an ILibraryManager interface that you can use to inspect the running application. However, that's a fairly advanced scenario.

Lastly, in the project.json file you can hard-code the x.y.z part of the version, e.g. 1.2.3 but you can also specify a * for the pre-release specifier, e.g. 1.2.3-*. If you use * for the pre-release specifier, you can set an environment variable named DNX_BUILD_VERSION to specify the value of the *, e.g. beta1 or rc2-54289.

There are some feature requests logged to allow more flexibility in specifying the entire version number externally.

like image 185
Eilon Avatar answered Sep 20 '22 22:09

Eilon