Skip to content

Commit

Permalink
GitTools#4093 - updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Jul 23, 2024
1 parent ff4fe72 commit bc259ba
Showing 1 changed file with 13 additions and 34 deletions.
47 changes: 13 additions & 34 deletions docs/input/docs/usage/msbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ If you're using `PackageReference` style NuGet dependencies (VS 2017+), add
dependency of your package:

```xml
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<PackageReference Include="GitVersion.MsBuild" Version="6.0.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
```
Expand All @@ -47,39 +47,6 @@ The next thing you need to do is to remove the `Assembly*Version` attributes fro
your `Properties\AssemblyInfo.cs` files. This puts GitVersion.MsBuild in charge of
versioning your assemblies.

### WPF specific concerns

One further step needs to be taken for SDK-style WPF projects.

Building projects with .NET Core SDK with a version lower than v5.0.200
requires turning off automatic generation of the different versioning attributes.
GitVersion usually controls these properties but cannot during WPF specific
targets that generate a temporary project.

```xml
<PropertyGroup>
<!-- Wpf workaround: GitVersion and .NET SDK < v5.0.200 -->
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
</PropertyGroup>
```

For .NET Core SDK v5.0.200 to v6.0.0-preview.1, a opt-in flag was introduced to
allow package references to be imported to the temporary project.
You can now remove the previous versioning attributes and replace them with
a single property.

```xml
<PropertyGroup>
<!-- WPF workaround: GitVersion and .NET SDK between v5.0.200 and v6.0.0-preview.2 -->
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
</PropertyGroup>
```

You can remove all workarounds if you are building with .NET Core SDK
v6.0.0-preview.2 or later as the flag is now opt-out.

### Done!

The setup process is now complete and GitVersion.MsBuild should be working its magic,
Expand Down Expand Up @@ -260,6 +227,18 @@ For SDK-style projects, `UpdateVersionProperties` controls setting the default
variables: `Version`, `VersionPrefix`, `VersionSuffix`, `PackageVersion`,
`InformationalVersion`, `AssemblyVersion` and `FileVersion`.

## Overriding Target Framework

If you want to override the target framework that GitVersion uses to determine the version, you can set the `GitVersionTargetFramework` property in your MSBuild script, like this:

```xml
<PropertyGroup>
...
<GitVersionTargetFramework>net8.0-android</GitVersionTargetFramework>
...
</PropertyGroup>
```

### Namespace generation

You can configure GitVersion to generate the `GitVersionInformation` class in a namespace that matches the current assembly. By default this class is created in the global namespace. If `UseProjectNamespaceForGitVersionInformation` is set to true, the `GitVersionInfomation` class will instead be generated in a namespace matching the current project. If the property `<RootNamespace>` is set that value will be used, otherwise the name of the project file is used.
Expand Down

0 comments on commit bc259ba

Please sign in to comment.