Support inheritance in version.json config (or limit Update Build Number tasks)
See original GitHub issueWe are using GitVersioning in a number of solutions (~66 projects total). All assemblies should be versioned the same across the codebase, so the GitVersioning package was installed in each project and we created a version.json in the repo root. We use TFS as our build server so the cloudBuild.buildNumber feature was enabled. As a result, when solutions are built, the log shows that the build number is being updated dozens of times. It seems like this is causing some of our builds to fail intermittently (“Error while copying content to a stream” or “An error occurred while sending the request”).
While I’m sure the builds failing is a Microsoft issue, I’d also like to limit the number of “update build number” tasks to keep the logged output clean. One of the projects in this codebase contains core shared business logic that is referenced in every solution. I’d like to enable cloudBuild.buildNumber task in this shared project only but have it inherit the version and other settings from the root project.json file. Unfortunately, when I tried to configure this:
The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly.
System.NullReferenceException: Object reference not set to an instance of an object.
at Nerdbank.GitVersioning.VersionOracle.get_PrereleaseVersion()
at Nerdbank.GitVersioning.VersionOracle.get_AssemblyInformationalVersion()
at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner()
at MSBuildExtensionTask.ContextAwareTask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Is there a way to inherit config or otherwise limit the number of “Update Build Number” tasks when cloudBuild output is enabled in the root across multiple projects?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Thanks very much, @AArnott - it’s working perfectly! I moved the cloudBuild section to a separate version.json file in a shared base project and now I only see a single “Update Build Number” command in the TFS build logs.
For reference, my root $/version.json now looks like this:
… and I added a new version.json at $/Domain/Common/version.json, where the Domain.Common project is referenced in every solution:
Your scenario is very compelling. While I don’t see the failures you see in my VSTS cloud builds, I do have other trouble with all projects trying to set the cloud build number and would rather just pick one to be the one. Inheritance is an interesting idea. I’ll play with that and see if I can make that work and that it makes overall.