Skip to content

Commit 85b3c5f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into release/4.0.0
2 parents f21c6cf + d6289ba commit 85b3c5f

File tree

141 files changed

+2563
-863
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+2563
-863
lines changed

.gitignore

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838
## If you have NuGet Package Restore enabled, uncomment this
3939
packages/
4040
ForSample/
41-
*NugetTaskBuild*
42-
*NugetRefBuild*
43-
*NugetExeBuild*
44-
*GitVersionVsoTaskBuild*
45-
*GemBuild*
4641

4742
# Visual Studio profiler
4843
*.psess
@@ -87,11 +82,8 @@ Thumbs.db
8782
Desktop.ini
8883

8984
_NCrunch_GitVersion
90-
NuGetCommandLineBuild/
9185
GitVersion.sln.ide/
9286
.vs/
93-
NuGetExeBuild/
94-
NuGetRefBuild/
9587
Packages/
96-
NuGetTaskBuild/
88+
build/
9789
site/
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo on
22

33
set framework=v4.0.30319
4-
set src=%~dp0..\src\
4+
set src=%~dp0src\
55

66
"%src%.nuget\nuget.exe" restore %src%
77

@@ -10,8 +10,8 @@ set src=%~dp0..\src\
1010
rmdir /s /q "%tmp%GitVersion"
1111
md "%tmp%GitVersion"
1212

13-
xcopy /E "%~dp0NuGetCommandLineBuild\tools" "%tmp%GitVersion"
13+
xcopy /E "%~dp0build\NuGetCommandLineBuild\tools" "%tmp%GitVersion"
1414

1515
"%tmp%GitVersion\GitVersion.exe" /l console /output buildserver /updateAssemblyInfo /proj "%src%GitVersion.sln"
1616

17-
rmdir /s /q "%tmp%GitVersion"
17+
rmdir /s /q "%tmp%GitVersion"

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ We love contributions to get started contributing you might need:
44
- [Get started with git](http://rogerdudler.github.io/git-guide)
55
- [How to create a pull request](https://help.github.com/articles/using-pull-requests)
66
- [An issue to work on](https://github.com/GitTools/GitVersion/labels/up-for-grabs) - We are on [Up for grabs](http://up-for-grabs.net/), our up for grabs issues are tagged `up-for-grabs`
7-
- An understanding of our [architecture](#architecture) and how [we write tests](#writing-tests)
7+
- An understanding of our [http://gitversion.readthedocs.org/en/latest/more-info/how-it-works/#architecture](#architecture) and how [we write tests](#writing-tests)
88

99
Once you know how to create a pull request and have an issue to work on, just post a comment saying you will work on it.
1010
If you end up not being able to complete the task, please post another comment so others can pick it up.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Versioning when using git, solved. GitVersion looks at your git history and work
1818
- [Documentation](http://gitversion.readthedocs.org/en/latest)
1919
- [Contributing](https://github.com/GitTools/GitVersion/blob/master/CONTRIBUTING.md)
2020
- [Why GitVersion](http://gitversion.readthedocs.org/en/latest/why)
21-
- [Usage](http://gitversion.readthedocs.org/en/latest/usage)
21+
- [Usage](http://gitversion.readthedocs.org/en/latest/usage/usage/)
2222
- [How it works](http://gitversion.readthedocs.org/en/latest/more-info/how-it-works/)
2323
- [FAQ](http://gitversion.readthedocs.org/en/latest/faq/)
2424
- [Who is using GitVersion](http://gitversion.readthedocs.org/en/latest/who/)

appveyor.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ build_script:
2424
- cmd: 7z a "GitVersion_%GitVersion_NuGetVersion%.zip" -r .\build\NuGetCommandLineBuild\Tools\*.*
2525
- cmd: appveyor PushArtifact "GitVersion_%GitVersion_NuGetVersion%.zip"
2626

27-
- ps: .\build\Update-GitVersionVsoTaskVersion.ps1 .\build\GitVersionVsoTaskBuild\task.json $env:GitVersion_Major $env:GitVersion_Minor $env:GitVersion_Patch
28-
- cmd: 7z a "GitVersionVsoBuildTask_%GitVersion_NuGetVersion%.zip" -r .\build\GitVersionVsoTaskBuild\*.*
29-
- cmd: appveyor PushArtifact "GitVersionVsoBuildTask_%GitVersion_NuGetVersion%.zip"
27+
- cmd: 7z a "GitVersionTfsBuildTask_%GitVersion_NuGetVersion%.zip" -r .\build\GitVersionTfsTaskBuild\*.*
28+
- cmd: appveyor PushArtifact "GitVersionTfsBuildTask_%GitVersion_NuGetVersion%.zip"
3029

3130
test_script:
3231
- nunit-console "src\GitVersionTask.Tests\bin\%CONFIGURATION%\GitVersionTask.Tests.dll" "src\GitVersionExe.Tests\bin\%CONFIGURATION%\GitVersionExe.Tests.dll" "src\GitVersionCore.Tests\bin\%CONFIGURATION%\GitVersionCore.Tests.dll" /noshadow

docs/build-server-support.md

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Build Server Support
2+
GitVersion has support for quite a few build servers out of the box. Currently we support:
3+
4+
- [AppVeyor](build-server/appveyor.md)
5+
- [Bamboo](build-server/bamboo.md)
6+
- [Continua CI](build-server/continua.md)
7+
- [Jenkins](build-server/jenkins.md)
8+
- [MyGet](build-server/myget.md)
9+
- [Octopus Deploy](build-server/octopus-deploy.md)
10+
- [TeamCity](build-server/teamcity.md)
11+
- [Team Build (TFS)](build-server/teambuild.md)
12+
- [TFS Build vNext](build-server/tfs-build-vnext.md)
13+
14+
When GitVersion.exe is run with the `/output buildserver` flag instead of outputting Json it will export variables to the current build server.
15+
For instance if you are running in TeamCity after you run `GitVersion /output buildserver` you will have the `%system.GitVersion.SemVer%` available for you to use
16+
17+
When running in MSBuild either from the [MSBuild Task](/usage/msbuild-task) or by using the `/proj myproject.sln` parameter, GitVersion will make the MSBuild variables available in the format `$(GitVersion_SemVer)`.

docs/more-info/build-server-setup/octopus-deploy.md renamed to docs/build-server-support/build-server/octopus-deploy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ The following shows an example with the corresponding git commands:
3434

3535
This approach works well with Semantic Versioning, as you will not be burning version numbers between releases (except if a build fails to get through UAT or something, then the burnt number means something!).
3636

37-
### Configure GitVersion to [increment per commit](../incrementing-per-commit.md)
37+
### Configure GitVersion to [increment per commit](../../more-info/incrementing-per-commit.md)
3838
As mentioned above, this means you will burn multiple versions per release. This might not be an issue for you, but can confuse consumers of your library as the version has semantic meaning.

docs/more-info/build-server-setup/teamcity.md renamed to docs/build-server-support/build-server/teamcity.md

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,28 @@ TeamCity has support for meta-runners which allow custom tasks. There is a GitVe
1717
- [Project Link](https://github.com/JetBrains/meta-runner-power-pack/tree/master/gitversion)
1818

1919
## Running inside TeamCity
20-
* Make sure to use **agent checkouts** (required, server checkouts do not copy the needed `.git` directory)
21-
- If you want to use *checkout on server*, see [dynamic repositories](../dynamic-repositories.md)
22-
* For the moment you need to promote the `%teamcity.build.vcs.branch.{configurationid}%` build parameter to an environment variable with the same name for pull requests to be handled correctly
20+
When running in TeamCIty you have two options, run using **agent checkout** or use dynamic repositories.
21+
22+
### Agent checkout
23+
For GitVersion to pick up pull requests properly you need to promote the `%teamcity.build.vcs.branch.{configurationid}%` variable to a system variable called `Git_Branch`
24+
25+
Just go to your build configuration, Parameters, click Add, Name should be `system.Git_Branch`, value should be `%teamcity.build.vcs.branch.{vcsid}%` where vcsid is your VCS root id. You should get auto completion for this.
26+
27+
### Dynamic repositories
28+
To use server side checkout, you must use the dynamic repositories feature of GitVersion. Server side checkout sends just the files to the agent and not the actual .git folder. Dynamic repositories will clone your repo into a temp folder and use it to calculate version information.
29+
30+
See [dynamic repositories](../../more-info/dynamic-repositories.md) for more info.
31+
32+
### Output
2333
* We update the TC build number to the GitVersion number automatically
24-
* We output the individual values of the GitVersion version as the build parameter: `GitVersion.*` (Eg: `GitVersion.Major`) if you need access to them in your build script
34+
* We output the individual values of the GitVersion version variables as build parameters with format `GitVersion.*` (Eg: `GitVersion.Major`) if you need access to them in your build script. Being system variables they will be passed as msbuild/environmental variables to other build steps
2535

2636
### NuGet in TeamCity
2737
* Add dummy [parameter](http://confluence.jetbrains.com/display/TCD8/Configuring+Build+Parameters) to
2838
the project called `GitVersion.NuGetVersion`. If many of your projects uses git-flow and SemVer you
29-
can add the parameter to the "root-project" (TeamCity 8.x+)
39+
can add the parameter to the "root-project" (TeamCity 8.x+). You need a dummy param because GitVersion creates the variables at runtime, and you cannot reference a paramter which is not available statically. GitVersion will overwrite the dummy value
3040
* Then setup you nuget pack build set the "version" to `%GitVersion.NuGetVersion%`
41+
* If you do your pack in a build script then you can just use environmental variables because teamcity will pass them through automatically.
3142

3243
### When TeamCity -> GitHub can't use https
3344
GitVersion requires the presence of master branch in order to determine the version number. If TeamCity uses https to clone git repos then GitVersion will pull down master branch for you during the build.
@@ -37,29 +48,5 @@ If however your TeamCity uses SSH to clone git repos and https is unavailable th
3748
> [GitVersionTask.UpdateAssemblyInfo] Error occurred: GitVersion.MissingBranchException: Could not fetch from '[email protected]:Xero/Bus.git' since LibGit2 does not support the transport. You have most likely cloned using SSH. If there is a remote branch named 'master' then fetch it manually, otherwise please create a local branch named 'master'. ---> LibGit2Sharp.LibGit2SharpException: An error was raised by libgit2. Category = Net (Error).
3849
This transport isn't implemented. Sorry
3950

40-
You need to create a TeamCity build step before your compile step which manually creates a local master branch which tracks remote master. Like so (in powershell):
41-
42-
```Powershell
43-
$branchBeingBuilt = . git symbolic-ref --short -q HEAD
44-
. git pull 2>&1 | write-host
45-
foreach ($remoteBranch in . git branch -r) {
46-
. git checkout $remoteBranch.Trim().Replace("origin/", "") 2>&1 | write-host
47-
. git pull 2>&1 | write-host
48-
}
49-
. git checkout $branchBeingBuilt 2>&1 | write-host
50-
exit 0
51-
```
52-
53-
you should get build output like
54-
55-
```
56-
[Step 1/1]: Ensure all branches are available for GitVersion (Powershell) (5s)
57-
[Step 1/1] From file:///C:/BuildAgent2/system/git/git-12345678
58-
[Step 1/1] * [new branch] master -> origin/master
59-
[Step 1/1] Switched to a new branch 'master'
60-
[Step 1/1] Branch master set up to track remote branch master from origin.
61-
[Step 1/1] Switched to branch 'develop'
62-
```
63-
6451
## Guides
6552
- [Continuous Delivery Setup in TeamCity](http://jake.ginnivan.net/blog/2014/07/09/my-typical-teamcity-build-setup)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Team Foundation Build (vNext) Setup
2+
## Basic Usage
3+
In Team Foundation Build (the web based build system) you can call GitVersion either using the Command Line build step or install a custom build step. The custom build step requires a one-time setup to import the GitVersion task into your TFS or VSO instance.
4+
5+
## Executing GitVersion
6+
### Using GitVersion with the MSBuild Task NuGet Package
7+
1. Add the [GitVersionTask](https://www.nuget.org/packages/GitVersionTask/) NuGet package to your projects.
8+
9+
See [MSBuild Task](/usage/msbuild-task) for further instructions how to use the MS Build Task.
10+
11+
### Using GitVersion with the Command Line build step
12+
1. Make sure to have GitVersion.exe under version control. There exists also a [Chocolatey package](https://chocolatey.org/packages/GitVersion.Portable) for installing GitVersion.exe on build agents.
13+
2. Add a Command Line build step to your build definition. You'll probably want to drag the task to be at or near the top to ensure it executes before your other build steps.
14+
3. Set the Tool parameter to `<pathToGitVersion>\GitVersion.exe`.
15+
4. Set the Arguments parameter to `/output buildserver /nofetch`.
16+
5. If you want the GitVersionTask to update AssemblyInfo files add `updateAssemblyInfo true` to the Arguments parameter.
17+
6. If you want to update the build number you need to send a [logging command](https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md) to TFS.
18+
19+
### Using the custom GitVersion build step
20+
#### Installing/updating the custom build step
21+
1. Install the `tfx` command line tool as shown [here](https://github.com/Microsoft/tfs-cli/blob/master/README.md#install).
22+
2. For TFS 2015 On-Prem configure Basic Authentication in TFS as shown [here](https://github.com/Microsoft/tfs-cli/blob/master/docs/configureBasicAuth.md).
23+
3. Download the GitVersion TFS build task from the latest release on the [GitVersion releases page](https://github.com/GitTools/GitVersion/releases) and unzip.
24+
4. Run `tfx login` as shown [here](https://github.com/Microsoft/tfs-cli/blob/master/README.md#login).
25+
5. From the directory outside of where you unzipped the task, run `tfx build tasks upload .\GitVersionTfsTask --overwrite` where GitVersionTfsTask is the directory containing the files.
26+
6. It should successfully install.
27+
28+
#### Using the GitVersion custom build step
29+
From a TFS build definition, select "Add a Step" and then in the Build category, choose GitVersion and click Add. You'll probably want to drag the task to be at or near the top to ensure it executes before your other build steps.
30+
31+
If you want the GitVersionTask to update AssemblyInfo files, check the box in the task configuration. For advanced usage, you can pass additional options to the GitVersion exe in the Additional arguments section.
32+
33+
The VSO build step can update your build number with GitVersion variables. See below for details.
34+
35+
36+
## Running inside TFS
37+
### Using the GitVersion Variables
38+
GitVersion passes variables in the form of `GitVersion.*` (Eg: `GitVersion.Major`) to TFS Build and also writes `GITVERSION_*` (Eg: `GITVERSION_MAJOR`) environment variables that are available for any subsequent build step.
39+
See [Variables](/more-info/variables/) for an overview of available variables.
40+
41+
42+
#### Using GitVersion variables in build name
43+
To use GitVersion's variables in the build name, just add them in the form `$(GITVERSION_FullSemVer)` into the Build definition's build number string. Then just ensure GitVersion is called with
44+
`/output buildserver` and it will replace those variables with the calculated version.
45+
The TFS GitVersion Build Step (above) handles this too, so if you're already using that, there's nothing extra to configure.
46+
47+
If you currently use `$(rev:.r)` in your build number, that won't work correctly if you
48+
use GitVersion variables as well due to the delayed expansion of the GitVersion vars. Instead,
49+
You might be able to use `$(GitVersion_BuildMetaData)` to achieve a similar result.
50+
See [Variables](/more-info/variables/) for more info on the variables.
51+
52+
53+
#### Known limitations
54+
* Due to [current limitations in TFS2015 On-Prem](https://github.com/Microsoft/vso-agent-tasks/issues/380) it's currently not possible to automatically set the build version in TFS2015 On-Prem. Instead a warning similar to `##[warning]Unable to process logging event:##vso[build.updatebuildnumber 1.0.0-unstable.1` is logged.
55+
* Due to a known limitation in TFS 2015 On-Prem it's currently not possible to use variables added during build in inputs of subsequent build tasks, since the variables are processed at the beginning of the build.
56+
As a workaround environment variables can be used in custom scripts.
57+
58+
## Create a NuGet package in TFS
59+
If you use a Command Line task to build your NuPkg, use `%GITVERSION_NUGETVERSION%` as the version parameter: `nuget.exe pack path\to\my.nuspec -version %GITVERSION_NUGETVERSION%`

0 commit comments

Comments
 (0)