Skip to content

Commit 9cc2430

Browse files
committed
Merge pull request #793 from okb/feature/msbuild-task-documentation
Fixed problems in MSBuild Task documentation
2 parents 68adb68 + c23efa9 commit 9cc2430

File tree

1 file changed

+26
-24
lines changed

1 file changed

+26
-24
lines changed

docs/usage/msbuild-task.md

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
# MSBuild Task
22

3-
The MSBuild Task for GitVersion — **GitVersionTask** — a simple solution if you
4-
want to version your assemblies without writing any command line scripts or
5-
modifying your build process.
3+
The MSBuild Task for GitVersion — **GitVersionTask**is a simple solution if
4+
you want to version your assemblies without writing any command line scripts or
5+
modifying your build process.
66

77
## TL;DR
88

99
### Install
1010

1111
It works simply by installing the [GitVersionTask NuGet
1212
Package](https://www.nuget.org/packages/GitVersionTask/) into the project you
13-
want to have versioned by GitVersion:
13+
want to have versioned by GitVersion:
1414

15-
Install-Package GitVersionTask
15+
```shell
16+
Install-Package GitVersionTask
17+
```
1618

1719
### Remove attributes
1820

1921
The next thing you need to do, is remove the `Assembly*Version` attributes from
2022
your `Properties\AssemblyInfo.cs` files, so GitVersionTask can be in charge of
21-
versioning your assemblies.
23+
versioning your assemblies.
2224

2325
### Done!
2426

@@ -32,7 +34,7 @@ described below.
3234

3335
## How does it work?
3436

35-
### Inject version metadata into the assembly
37+
### Inject version metadata into the assembly
3638

3739
The sub-task named `GitVersionTask.UpdateAssemblyInfo` will inject version
3840
metadata into the assembly which GitVersionTask is added to. For each assembly
@@ -45,7 +47,7 @@ At build time a temporary `AssemblyInfo.cs` will be created that contains the
4547
appropriate SemVer information. This will be included in the build pipeline.
4648
Sample default:
4749

48-
```c#
50+
```csharp
4951
[assembly: AssemblyVersion("1.0.0.0")]
5052
[assembly: AssemblyFileVersion("1.0.0.0")]
5153
[assembly: AssemblyInformationalVersion("1.1.0+Branch.master.Sha.722aad3217bd49a6576b6f82f60884e612f9ba58")]
@@ -56,32 +58,32 @@ Now when you build:
5658
* `AssemblyVersion` will be set to the `AssemblySemVer` variable.
5759
* `AssemblyFileVersion` will be set to the `MajorMinorPatch` variable with a
5860
* appended `.0`. `AssemblyInformationalVersion` will be set to the
59-
* `InformationalVersion` variable.
61+
* `InformationalVersion` variable.
6062

6163
#### Other injected Variables
6264

6365
All other [variables](../more-info/variables.md) will be injected into an
64-
internal static class:
66+
internal static class:
6567

66-
```c#
68+
```csharp
6769
namespace AssemblyName
6870
{
69-
[CompilerGenerated]
70-
internal static class GitVersionInformation
71-
{
72-
public static string Major = "1";
73-
public static string Minor = "1";
74-
public static string Patch = "0";
75-
...All other variables
76-
}
71+
[CompilerGenerated]
72+
internal static class GitVersionInformation
73+
{
74+
public static string Major = "1";
75+
public static string Minor = "1";
76+
public static string Patch = "0";
77+
...All other variables
78+
}
7779
}
7880
```
7981

8082
#### Accessing injected Variables
8183

8284
##### All variables
8385

84-
```c#
86+
```csharp
8587
var assemblyName = assembly.GetName().Name;
8688
var gitVersionInformationType = assembly.GetType(assemblyName + ".GitVersionInformation");
8789
var fields = gitVersionInformationType.GetFields();
@@ -94,7 +96,7 @@ foreach (var field in fields)
9496

9597
##### Specific variable
9698

97-
```c#
99+
```csharp
98100
var assemblyName = assembly.GetName().Name;
99101
var gitVersionInformationType = assembly.GetType(assemblyName + ".GitVersionInformation");
100102
var versionField = gitVersionInformationType.GetField("Major");
@@ -118,7 +120,7 @@ After `GitVersionTask.GetVersion` has executed, the MSBuild properties can be
118120
used in the standard way. For example:
119121

120122
```xml
121-
<Message Text="GitVersion_InformationalVersion: $(GitVersion_InformationalVersion)"/>
123+
<Message Text="GitVersion_InformationalVersion: $(GitVersion_InformationalVersion)"/>
122124
```
123125

124126
### Communicate variables to current Build Server
@@ -129,7 +131,7 @@ the version information to the current Build Server log.
129131
If, at build time, it is detected that the build is occurring inside a Build
130132
Server then the [variables](../more-info/variables.md) will be written to the
131133
Build Server log in a format that the current Build Server can consume. See
132-
[Build Server Support](../build-server-support/build-server-support.md).
134+
[Build Server Support](../build-server-support/build-server-support.md).
133135

134136
## Conditional control tasks
135137

@@ -147,7 +149,7 @@ this:
147149
...
148150
</PropertyGroup>
149151
```
150-
152+
151153
## My Git repository requires authentication. What do I do?
152154

153155
Set the environmental variables `GITVERSION_REMOTE_USERNAME` and

0 commit comments

Comments
 (0)