dotnet/Nerdbank.GitVersioning

Hanging build when activing cloud build in Azure DevOps build pipeline

MarcoK80 opened this issue · 2 comments

We encountered an issue when we enable Nerdbank 3.6.133 with cloud build number enabled. The build process get stuck on a project and not recovers. The build get cancelled after one hour (normal build time is around 30 seconds without the setting). When we disable the buildnumber enabled and set Variables the build runs normal.

{
  "$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
  "version": "18.0",
  "versionHeightOffset": 0,
  "publicReleaseRefSpec": [
    "^refs/heads/master",
    "^refs/heads/releases/.*$"
  ],
  "cloudBuild": {
    "buildNumber": {
      "enabled": true
    },
    "setVersionVariables": true,
    "setAllVariables": true
  }
}

The log from the build shows that the task is started but not continued. After the build is cancelled the Async commands are visible.
We have around 40 different projects to be built with .net core 7.

We tried with gitversionbasedirectory but still encounter the issue. Sporadically the build succeed within of 30 seconds.

<!-- Required to reduce build times and timeout https://github.com/dotnet/Nerdbank.GitVersioning/blob/main/doc/msbuild.md#build-performance.-->
  <PropertyGroup>
    <GitVersionBaseDirectory>$(MSBuildThisFileDirectory)</GitVersionBaseDirectory>
  </PropertyGroup>
>     Done building target "GetBuildVersion" in project "Adapter.Hosting_uTests.csproj".
       Target "GetBuildVersion" skipped. Previously built successfully.
Target "SetCloudBuildVersionVars" in file "/home/vsts/.nuget/packages/nerdbank.gitversioning/3.6.133/build/Nerdbank.GitVersioning.targets" from project "/home/vsts/work/1/s/test/Adapter.Hosting_uTests/Adapter.Hosting_uTests.csproj" (target "GenerateAssemblyNBGVVersionInfo" depends on it):
       Using "Nerdbank.GitVersioning.Tasks.SetCloudBuildVariables" task from assembly "/home/vsts/.nuget/packages/nerdbank.gitversioning/3.6.133/build/MSBuildCore/Nerdbank.GitVersioning.Tasks.dll".
       Task "Nerdbank.GitVersioning.Tasks.SetCloudBuildVariables"
##[error]The operation was canceled.
Async Command Start: Update Build Number
Update build number to 18.0.20+f07c0c6b96 for build 1166016
Async Command End: Update Build Number

I haven't seen the behavior you describe myself, but I recommend you turn off that setting, and set your cloud build number using an explicit step as documented here.

I hope this helps.

We had the exact same problem. Setting

"setVersionVariables": false, "setAllVariables": false,

worked.