Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inheritance in version.json config (or limit Update Build Number tasks) #145

Closed
desmondgc opened this issue Aug 14, 2017 · 7 comments
Assignees

Comments

@desmondgc
Copy link

We 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?

@AArnott
Copy link
Collaborator

AArnott commented Aug 14, 2017

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.

@AArnott AArnott self-assigned this Aug 14, 2017
@AArnott
Copy link
Collaborator

AArnott commented Nov 22, 2017

I'm going to try this out over the next few days.

@robmen
Copy link
Contributor

robmen commented Nov 22, 2017

If you want someone to test some early bits @AArnott, we can try it out in our VSTS builds.

@AArnott
Copy link
Collaborator

AArnott commented Nov 22, 2017

Great. :)

@AArnott
Copy link
Collaborator

AArnott commented Nov 23, 2017

@robmen @desmondgc This is shipped in v2.1.6-beta. Please let me know how it works for you.

@desmondgc
Copy link
Author

desmondgc commented Dec 5, 2017

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:

{
  "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
  "version": "5.0",
  "assemblyVersion": {
    "precision": "revision"
  },
  "publicReleaseRefSpec": [
    "^refs/heads/main/development$",
    "^refs/heads/main/integration$",
    "^refs/heads/main/release$"
  ]
}

... and I added a new version.json at $/Domain/Common/version.json, where the Domain.Common project is referenced in every solution:

{
  "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
  "inherit": true,
  "cloudBuild": {
    "setVersionVariables": true,
    "buildNumber": {
      "enabled": true
    }
  }
}

@AArnott
Copy link
Collaborator

AArnott commented Dec 6, 2017

Fantastic. Thanks for reporting back, @desmondgc. I'll get the feature documented (I missed that in the original PR) and ship a stable versioned package to nuget.org then.

AArnott added a commit that referenced this issue Dec 6, 2017
AArnott added a commit that referenced this issue Sep 5, 2022
Update .NET SDK to 6.0.200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants