dotnet/Nerdbank.GitVersioning

Is there a way to not require version.json

msedi opened this issue · 4 comments

msedi commented

We have a large codebase with around 250 projects in one solution, where the FileVersion and AssemblyVersion have been set originally. When switching to NerdBank.GitVersioning these are ignored and the version.json is taken. It turned out many team colleagues are not aware of it and are having problems configuring it.

Each application or library can have different versions and there exists no single version.json in the root folder.

Is there a way to make NerdBank.GitVersioning repect teh AssemblyVersion and FileVersion from the project and do not require a version.json?

If it is required the only way I see that when building I write my own version.json by taking the AssemblyVersion/FileVersion and create a version.json dynamically. But I'm not sure I can write it in the props or targets because I don't which target I should depend on.

Is there any help?

If you already have version attributes that you want to preserve, what benefit do you anticipate from using nerdbank.gitversioning if it isn't generating versions for you?

Generating a version.json during the build will not achieve anything worthwhile imo because the file isn't checked-in, and thus you can't have git-based versioning (where part of the version is computed from git history), which is the whole point of the package.

msedi commented

@AArnott: In the end everything is fine with nerdbank and we are using all of its features. The only problem is that the version needs to be entered in the version.json whereas it would be more help to be able to define the version in the csproj itself since this is the place where we have all our information collected. If that would be possible all problems would be solved on our side and we can keep a single version.json at the root folder ;-)

{
  "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
  **"version": "2.1.0-PRERELEASE",**
  "pathFilters": [ "." ],
  "publicReleaseRefSpec": [
    "^refs/heads/master$",
    "^refs/heads/v\\d+(?:\\.\\d+)?$"
  ],
  "cloudBuild": {
    "setVersionVariables": false
  }
}

I'm afraid defining the version info in the csproj is not supported, and probably couldn't be without unacceptable perf losses during build. version.json is fundamentally a static file, whereas csproj supports msbuild 'evaluation' which makes interpreting its content much slower. csproj also tends to change more frequently than version.json, so it would have to be parsed more to find where the versions changed.

Are you aware that individual project directories can have version.json files defined? They can even inherit settings from a parent directory's version.json file. So you can have your root level with most settings, and each project directory can have just the version info for an individual project.

msedi commented

Alright. Thanks for the info.