Skip to content

Commit

Permalink
Merge pull request #2716 from fowl2/patch-1
Browse files Browse the repository at this point in the history
msbuild.md: update for rename to GitVersion.MsBuild from GitVersionTask
  • Loading branch information
asbjornu authored Jun 7, 2021
2 parents 32fe901 + a74d44d commit aea0c85
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ works out the [Semantic Version][semver] of the commit being built.
| **GitVersion.Portable** | [![Chocolatey][choco-badge]][choco] |
| **GitVersion.Tool** | [![NuGet][gvgt-badge]][gvgt] |
| **GitVersion.CommandLine** | [![NuGet][gvcl-badge]][gvcl] |
| **GitVersion.MsBuild** | [![NuGet][gvt-badge]][gvt] |
| **GitVersion.MsBuild** | [![NuGet][gvt-badge]][gvt] | Known as *[GitVersionTask](https://www.nuget.org/packages/GitVersionTask/)* before v5.6.0 |
| **Homebrew** | [![homebrew][brew-badge]][brew] |
| **Azure Pipeline Task** | [![Azure Pipeline Task][az-pipeline-task-badge]][az-pipeline-task] |
| **Github Action** | [![Github Action][gh-actions-badge]][gh-actions] |
Expand Down
32 changes: 18 additions & 14 deletions docs/input/docs/usage/msbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: |
CardIcon: collect.svg
---

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

Expand All @@ -17,38 +17,42 @@ version information that is compiled into the resulting artifact.
It currently works with desktop `MSBuild`. Support for CoreCLR with `dotnet build`
is coming soon.

> **Note**
The nuget package was "*[GitVersionTask](https://www.nuget.org/packages/GitVersionTask/)*" up until version 5.5.1.
From version 5.6.0 it has been called "*[GitVersion.MsBuild](https://www.nuget.org/packages/GitVersionTask/)*"

## TL;DR

### Install the MSTask targets

Add the [GitVersionTask](https://www.nuget.org/packages/GitVersionTask/) NuGet
Add the [GitVersion.MsBuild](https://www.nuget.org/packages/GitVersion.MsBuild/) NuGet
Package into the project you want to be versioned by GitVersion.

From the Package Manager Console:

```shell
Install-Package GitVersionTask
Install-Package GitVersion.MsBuild
```

If you're using `PackageReference` style NuGet dependencies (VS 2017+), add
`<PrivateAssets>all</PrivateAssets>` to prevent the task from becoming a
dependency of your package:

``` xml
<PackageReference Include="GitVersionTask" Version="4.0.0-beta*">
<PackageReference Include="GitVersion.MsBuild" Version="5.6.10*">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
```

### Remove AssemblyInfo attributes

The next thing you need to do is to remove the `Assembly*Version` attributes from
your `Properties\AssemblyInfo.cs` files. This puts GitVersionTask in charge of
your `Properties\AssemblyInfo.cs` files. This puts GitVersion.MsBuild in charge of
versioning your assemblies.

### Done!

The setup process is now complete and GitVersionTask should be working its magic,
The setup process is now complete and GitVersion.MsBuild should be working its magic,
versioning your assemblies like a champ. However, more can be done to further
customize the build process. Keep reading to find out how the version variables
are set and how you can use them in MSBuild tasks.
Expand All @@ -61,10 +65,10 @@ described below.

### Inject version metadata into the assembly

The sub-task named `GitVersionTask.UpdateAssemblyInfo` will inject version
metadata into the assembly where GitVersionTask has been added to. For each assembly
The sub-task named `GitVersion.MsBuild.UpdateAssemblyInfo` will inject version
metadata into the assembly where GitVersion.MsBuild has been added to. For each assembly
you want GitVersion to handle versioning, you will need to install
[GitVersionTask](https://www.nuget.org/packages/GitVersionTask/) into the corresponding
[GitVersion.MsBuild](https://www.nuget.org/packages/GitVersion.MsBuild/) into the corresponding
project via NuGet.

#### AssemblyInfo Attributes
Expand Down Expand Up @@ -152,11 +156,11 @@ else

### Populate some MSBuild properties with version metadata

The sub-task `GitVersionTask.GetVersion` will write all the derived
The sub-task `GitVersion.MsBuild.GetVersion` will write all the derived
[variables](/docs/reference/variables) to MSBuild properties so the information
can be used by other tooling in the build pipeline.

The class for `GitVersionTask.GetVersion` has a property for each variable.
The class for `GitVersion.MsBuild.GetVersion` has a property for each variable.
However at MSBuild time these properties are mapped to MSBuild properties that
are prefixed with `GitVersion_`. This prevents conflicts with other properties
in the pipeline.
Expand All @@ -182,7 +186,7 @@ package versions but older NuGet clients and nuget.org do not.

#### Accessing variables in MSBuild

Once `GitVersionTask.GetVersion` has been executed, the MSBuild properties can be
Once `GitVersion.MsBuild.GetVersion` has been executed, the MSBuild properties can be
used in the standard way. For example:

```xml
Expand All @@ -191,7 +195,7 @@ used in the standard way. For example:

### Communicate variables to current Build Server

The sub-task `GitVersionTask.WriteVersionInfoToBuildLog` will attempt to write
The sub-task `GitVersion.MsBuild.WriteVersionInfoToBuildLog` will attempt to write
the version information to the current Build Server log.

If, at build time, it is detected that the build is occurring inside a Build
Expand All @@ -205,7 +209,7 @@ Properties `WriteVersionInfoToBuildLog`, `UpdateAssemblyInfo`,
`UseFullSemVerForNuGet`, `UpdateVersionProperties` and `GetVersion` are checked
before running these tasks.

You can disable `GitVersionTask.UpdateAssemblyInfo` by setting
You can disable `GitVersion.MsBuild.UpdateAssemblyInfo` by setting
`UpdateAssemblyInfo` to `false` in your MSBuild script, like
this:

Expand Down

0 comments on commit aea0c85

Please sign in to comment.