You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: BREAKING CHANGES.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -3,4 +3,4 @@ v3.0.0
3
3
-`AssemblyFileSemVer` variable removed, AssemblyVersioningScheme configuration value makes this variable obsolete
4
4
- Variables `ClassicVersion` and `ClassicVersionWithTag` removed
5
5
- MSBuild task arguments (AssemblyVersioningScheme, DevelopBranchTag, ReleaseBranchTag, TagPrefix, NextVersion) have been removed, use GitVersionConfig.yaml instead
6
-
- GitVersionTask ReleaseDateAttribute no longer has OriginalReleaseDate
6
+
- GitVersionTask ReleaseDateAttribute no longer exists
Copy file name to clipboardExpand all lines: docs/more-info/variables.md
+6
Original file line number
Diff line number
Diff line change
@@ -24,3 +24,9 @@ For the `release/3.0.0` branch of GitVersion it shows:
24
24
"NuGetVersion":"3.0.0-beta0001"
25
25
}
26
26
```
27
+
28
+
29
+
#### Why is AssemblyVersion only set to Major.Minor?
30
+
31
+
This is a common approach that gives you the ability to roll out hot fixes to your assembly without breaking existing applications that may be referencing it. You are still able to get the full version number if you need to by looking at its file version number.
Copy file name to clipboardExpand all lines: docs/usage.md
+89-15
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,15 @@
1
1
# Usage
2
+
2
3
There are two main ways to consume GitVersion, the first is by running GitVersion.exe. The second is an MSBuild task. The MSBuild task is really easy to get up and running, simply install GitVersionTask from NuGet and it will integrate into your project and write out variables to your build server if it's running on one. The exe offers more options and works for not just .net projects.
3
4
4
5
-[A Command Line tool](#command-line)
5
6
-[An MSBuild Task](#msbuild-task)
6
7
-[A NuGet Library package](#nuget-library)
7
8
-[A Ruby Gem](#gem)
8
9
10
+
9
11
## Command Line
12
+
10
13
If you want a command line version installed on your machine then you can use [Chocolatey](http://chocolatey.org) to install GitVersion
11
14
12
15
Available on [Chocolatey](http://chocolatey.org) under [GitVersion.Portable](http://chocolatey.org/packages/GitVersion.Portable)
@@ -15,57 +18,128 @@ Available on [Chocolatey](http://chocolatey.org) under [GitVersion.Portable](htt
15
18
16
19
Switches are available with `GitVersion /?`
17
20
21
+
18
22
### Output
23
+
19
24
By default GitVersion returns a json object to stdout containing all the [variables](more-info/variables.md) which GitVersion generates. This works great if you want to get your build scripts to parse the json object then use the variables, but there is a simpler way.
20
25
21
26
`GitVersion.exe /output buildserver` will change the mode of GitVersion to write out the variables to whatever build server it is running in. You can then use those variables in your build scripts or run different tools to create versioned NuGet packages or whatever you would like to do. See [build servers](build-server-support.md) for more information about this.
22
27
23
28
24
29
## MSBuild Task
25
-
The MSBuild task will wire GitVersion into the MSBuild pipeline of a project and automatically stamp that assembly with the appropriate SemVer information
26
30
27
31
Available on [Nuget](https://www.nuget.org) under [GitVersionTask](https://www.nuget.org/packages/GitVersionTask/)
28
32
29
33
Install-Package GitVersionTask
30
34
31
-
Remove the `Assembly*Version` attributes from your `Properties\AssemblyInfo.cs` file. Sample default:
35
+
The MSBuild task will wire GitVersion into the MSBuild pipeline of a project and perform several actions.
36
+
37
+
### 1. Inject version metadata into the assembly
38
+
39
+
Task Name: `GitVersionTask.UpdateAssemblyInfo`
40
+
41
+
#### AssemblyInfo Attributes
42
+
43
+
At build time a temporary AssemblyInfo.cs will be created that contains the appropriate SemVer information. This will will be included in the build pipeline.
44
+
45
+
Ensure you remove the `Assembly*Version` attributes from your `Properties\AssemblyInfo.cs` file so as to not get duplicate attribute warnings. Sample default:
Make sure there is a tag somewhere on master named `v1.2.3` before `HEAD` (change the numbers as desired). Now when you build:
51
+
Now when you build:
38
52
39
-
* AssemblyVersion will be set to 1.2.0.0 (i.e Major.Minor.0.0)
40
-
* AssemblyFileVersion will be set to 1.2.3.0 (i.e Major.Minor.Patch)
41
-
* AssemblyInformationalVersion will be set to `1.2.4+<commitcount>.Branch.<branchname>.Sha.<commithash>` where:
42
-
*`<commitcount>` is the number of commits between the `v1.2.3` tag and `HEAD`.
43
-
*`<branchname>` is the name of the branch you are on.
44
-
*`<commithash>` is the commit hash of `HEAD`.
53
+
*`AssemblyVersion` will be set to the `AssemblySemVer` variable.
54
+
*`AssemblyFileVersion` will be set to the `MajorMinorPatch` variable with a appended `.0`.
55
+
*`AssemblyInformationalVersion` will be set to the `InformationalVersion` variable.
45
56
46
-
Continue working as usual and when you release/deploy, tag the branch/release `v1.2.4`.
47
57
48
-
If you want to bump up the major or minor version, create a `GitVersionConfig.yaml` file in the root of your repo and inside of it on a single line enter `next-version: <version you want>`, for example `next-version: 3.0.0`
58
+
#### Other injected Variables
49
59
50
-
### Why is AssemblyVersion only set to Major.Minor?
60
+
All other [variables](more-info/variables.md) will be injected into a internal static class.
61
+
62
+
```
63
+
namespace AssemblyName
64
+
{
65
+
[CompilerGenerated]
66
+
internal static class GitVersionInformation
67
+
{
68
+
public static string Major = "1";
69
+
public static string Minor = "1";
70
+
public static string Patch = "0";
71
+
...All other variables
72
+
}
73
+
}
74
+
```
75
+
76
+
77
+
#### Accessing injected Variables
78
+
79
+
**All variables**
80
+
81
+
```
82
+
var assemblyName = assembly.GetName().Name;
83
+
var gitVersionInformationType = assembly.GetType(assemblyName + ".GitVersionInformation");
84
+
var fields = gitVersionInformationType.GetFields();
var gitVersionInformationType = assembly.GetType(assemblyName + ".GitVersionInformation");
97
+
var versionField = gitVersionInformationType.GetField("Major");
98
+
Trace.WriteLine(versionField.GetValue(null));
99
+
```
100
+
101
+
102
+
### 2. Populate some MSBuild properties with version metadata
103
+
104
+
Task Name: `GitVersionTask.GetVersion`
105
+
106
+
At build time all the derived [variables](more-info/variables.md) will be written to MSBuild properties so the information can be used by other tooling in the build pipeline.
107
+
108
+
The class for `GitVersionTask.GetVersion` has a property for each variable. However at MSBuild time these properties a mapped to MSBuild properties that are prefixed with `GitVersion_`. This prevents conflicts with other properties in the pipeline.
109
+
110
+
#### Accessing variable in MSBuild
111
+
112
+
After `GitVersionTask.GetVersion` has executed the properties can be used in the standard way. For example:
If, at build time, it is detected that the build is occurring inside a Build Server server then the [variables](more-info/variables.md) will be written to the build log in a format that the current Build Server can consume. See [Build Server Support](build-server-support.md).
51
122
52
-
This is a common approach that gives you the ability to roll out hot fixes to your assembly without breaking existing applications that may be referencing it. You are still able to get the full version number if you need to by looking at its file version number.
53
123
54
124
### My Git repository requires authentication. What do I do?
55
125
56
126
Set the environmental variables `GITVERSION_REMOTE_USERNAME` and `GITVERSION_REMOTE_PASSWORD` before the build is initiated.
57
127
128
+
58
129
## NuGet Library
130
+
59
131
To use GitVersion from your own code.
60
132
61
133
**Warning, we are not semantically versioning this library and it should be considered unstable.**
62
134
63
135
It also is not currently documented. Please open an issue if you are consuming the library to let us know, and why you need to.
64
136
137
+
65
138
## Gem
139
+
66
140
Just a gem wrapper around the command line to make it easier to consume from Rake.
67
141
68
-
**NOTE** This is currenly not being pushed.. Please get in touch if you are using this
142
+
**NOTE** This is currently not being pushed.. Please get in touch if you are using this
69
143
70
144
If you want a Ruby gem version installed on your machine then you can use [Bundler](http://bundler.io/) or [Gem](http://rubygems.org/) to install the `gitversion` gem.
0 commit comments