diff --git a/docs/usage/msbuild-task.md b/docs/usage/msbuild-task.md index 4c7a71b64f..967777b5fc 100644 --- a/docs/usage/msbuild-task.md +++ b/docs/usage/msbuild-task.md @@ -1,8 +1,8 @@ # MSBuild Task -The MSBuild Task for GitVersion — **GitVersionTask** — a simple solution if you -want to version your assemblies without writing any command line scripts or -modifying your build process. +The MSBuild Task for GitVersion — **GitVersionTask** — is a simple solution if +you want to version your assemblies without writing any command line scripts or +modifying your build process. ## TL;DR @@ -10,15 +10,17 @@ modifying your build process. It works simply by installing the [GitVersionTask NuGet Package](https://www.nuget.org/packages/GitVersionTask/) into the project you -want to have versioned by GitVersion: +want to have versioned by GitVersion: - Install-Package GitVersionTask +```shell +Install-Package GitVersionTask +``` ### Remove attributes The next thing you need to do, is remove the `Assembly*Version` attributes from your `Properties\AssemblyInfo.cs` files, so GitVersionTask can be in charge of -versioning your assemblies. +versioning your assemblies. ### Done! @@ -32,7 +34,7 @@ described below. ## How does it work? -### Inject version metadata into the assembly +### Inject version metadata into the assembly The sub-task named `GitVersionTask.UpdateAssemblyInfo` will inject version 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 appropriate SemVer information. This will be included in the build pipeline. Sample default: -```c# +```csharp [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+Branch.master.Sha.722aad3217bd49a6576b6f82f60884e612f9ba58")] @@ -56,24 +58,24 @@ Now when you build: * `AssemblyVersion` will be set to the `AssemblySemVer` variable. * `AssemblyFileVersion` will be set to the `MajorMinorPatch` variable with a * appended `.0`. `AssemblyInformationalVersion` will be set to the -* `InformationalVersion` variable. +* `InformationalVersion` variable. #### Other injected Variables All other [variables](../more-info/variables.md) will be injected into an -internal static class: +internal static class: -```c# +```csharp namespace AssemblyName { - [CompilerGenerated] - internal static class GitVersionInformation - { - public static string Major = "1"; - public static string Minor = "1"; - public static string Patch = "0"; - ...All other variables - } + [CompilerGenerated] + internal static class GitVersionInformation + { + public static string Major = "1"; + public static string Minor = "1"; + public static string Patch = "0"; + ...All other variables + } } ``` @@ -81,7 +83,7 @@ namespace AssemblyName ##### All variables -```c# +```csharp var assemblyName = assembly.GetName().Name; var gitVersionInformationType = assembly.GetType(assemblyName + ".GitVersionInformation"); var fields = gitVersionInformationType.GetFields(); @@ -94,7 +96,7 @@ foreach (var field in fields) ##### Specific variable -```c# +```csharp var assemblyName = assembly.GetName().Name; var gitVersionInformationType = assembly.GetType(assemblyName + ".GitVersionInformation"); var versionField = gitVersionInformationType.GetField("Major"); @@ -118,7 +120,7 @@ After `GitVersionTask.GetVersion` has executed, the MSBuild properties can be used in the standard way. For example: ```xml - + ``` ### Communicate variables to current Build Server @@ -129,7 +131,7 @@ the version information to the current Build Server log. If, at build time, it is detected that the build is occurring inside a Build Server then the [variables](../more-info/variables.md) will be written to the Build Server log in a format that the current Build Server can consume. See -[Build Server Support](../build-server-support/build-server-support.md). +[Build Server Support](../build-server-support/build-server-support.md). ## Conditional control tasks @@ -147,7 +149,7 @@ this: ... ``` - + ## My Git repository requires authentication. What do I do? Set the environmental variables `GITVERSION_REMOTE_USERNAME` and