diff --git a/docs/input/docs/usage/msbuild.md b/docs/input/docs/usage/msbuild.md index f5ff401e5a..badf8b99a6 100644 --- a/docs/input/docs/usage/msbuild.md +++ b/docs/input/docs/usage/msbuild.md @@ -36,7 +36,7 @@ If you're using `PackageReference` style NuGet dependencies (VS 2017+), add dependency of your package: ```xml - + 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 - - - false - false - false - -``` - -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 - - - true - -``` - -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, @@ -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 + + ... + net8.0 + ... + +``` + ### 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 `` is set that value will be used, otherwise the name of the project file is used. diff --git a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props index e1f335e940..52048425f1 100644 --- a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props +++ b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props @@ -16,6 +16,11 @@ $(GitVersion_ToolArgments) -nofetch $(GitVersion_ToolArgments) -nonormalize $(GitVersion_ToolArgments) -nocache + + $(TargetFramework) + + dotnet --roll-forward Major "$([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(GitVersionTargetFramework)))gitversion.dll" + $([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(GitVersionTargetFramework)))GitVersion.MsBuild.dll diff --git a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets index 0b86b436b9..d5c6f70729 100644 --- a/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets +++ b/src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.targets @@ -7,9 +7,6 @@ true true - - dotnet --roll-forward Major "$([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(TargetFramework)))gitversion.dll" - $([MSBuild]::EnsureTrailingSlash($(MSBuildThisFileDirectory)$(TargetFramework)))GitVersion.MsBuild.dll