Skip to content

Commit 7827ebe

Browse files
authored
Document setting cloud build number just once with nbgv
1 parent c353490 commit 7827ebe

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

doc/cloudbuild.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,30 @@ There are many more MSBuild variables that the build will set within the build.
9191

9292
Setting both of these fields to `true` means that a few variables will be defined in the cloud build server twice -- one set with the names in the table above and the other (full) set using the `NBGV_` prefix.
9393

94-
### Set cloud build variables from just one project
94+
### Set cloud build variables only once in a build
9595

9696
While each individual MSBuild project has its own version computed, the versions across projects are usually the same so long as you have one `version.json` file at the root of your repo. If you choose to enable setting of cloud build variables in that root version.json file, each project that builds will take a turn setting those cloud build variables. This is perhaps more work than is necessary, and when some projects compute versions differently it can lead to inconsistently defined cloud build variables, based on non-deterministic build ordering of your projects.
9797

98-
You can reduce log message noise and control for non-deterministic cloud build variables by *not* setting any of the `cloudBuild` options in your root version.json file, and instead defining an additional `version.json` file inside just *one* project directory that inherits from the base one, like this:
98+
You can reduce log message noise and control for non-deterministic cloud build variables by *not* setting any of the `cloudBuild` options in your root version.json file. Two options are described below to set the cloud build number and variables just once in your build.
99+
100+
#### Set the cloud build number as a build step
101+
102+
The [nbgv CLI tool](nbgv-cli.md) can be used to set the cloud build number and variables. Your CI build script should include these two commands:
103+
104+
```cmd
105+
dotnet tool install --tool-path . nbgv
106+
.\nbgv cloud
107+
```
108+
109+
The above will set just the cloud build number, but switches to the `nbgv cloud` command will cause other build variables to also be set.
110+
111+
See a working sample in [a VSTS YAML file](https://github.com/Humanizr/Humanizer/blob/604ebcc5ed0215aa8fb511ac5424239659f570a0/.vsts-shared.yml#L5-L15).
112+
113+
https://github.com/Humanizr/Humanizer/blob/604ebcc5ed0215aa8fb511ac5424239659f570a0/.vsts-shared.yml#L5-L15
114+
115+
#### Set them from just one project
116+
117+
After ensuring that your root version.json file does *not* set `cloudBuild.buildNumber.enabled=true`, define an additional `version.json` file inside just *one* project directory that inherits from the base one, like this:
99118

100119
```json
101120
{

0 commit comments

Comments
 (0)