diff --git a/docs/usage/msbuild-task.md b/docs/usage/msbuild-task.md index 4b99a536f8..d5d5d15995 100644 --- a/docs/usage/msbuild-task.md +++ b/docs/usage/msbuild-task.md @@ -4,6 +4,8 @@ The MSBuild Task for GitVersion — **GitVersionTask** — is a simple solution you want to version your assemblies without writing any command line scripts or modifying your build process. +It currently works with desktop `MSBuild`. Support for CoreCLR with `dotnet build` is coming soon. + ## TL;DR ### Install the MSTask targets @@ -16,6 +18,14 @@ From the Package Manager Console: Install-Package GitVersionTask ``` +If you're using `PackageReference` style NuGet dependencies (VS 2017+), add `all` to prevent the task from becoming a dependency of your package: + +``` xml + + All + +``` + ### Remove AssemblyInfo attributes The next thing you need to do is to remove the `Assembly*Version` attributes from @@ -115,6 +125,17 @@ 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. +In addition, the following MSBuild properties are set when `UpdateVersionProperties` is true (the default): +`Version`, `VersionPrefix`, `VersionSuffix`, `PackageVersion`, `InformationalVersion`, `AssemblyVersion` and `FileVersion`. These are used by the built-in tasks for generating AssemblyInfo's and NuGet package versions. + + +### NuGet packages +The new SDK-style projects available for .NET Standard libraries (and multi-targeting), have the ability +to create NuGet packages directly by using the `pack` target: `msbuild /t:pack`. The version is controled by the MSBuild properties described above. + +GitVersionTask has the option to generate SemVer 2.0 compliant NuGet package versions by setting `UseFullSemVerForNuGet` to true in your project (this is off by default for compatibility). Some hosts, like MyGet, support SemVer 2.0 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 @@ -136,7 +157,7 @@ Build Server log in a format that the current Build Server can consume. See ## Conditional control tasks -Properties `WriteVersionInfoToBuildLog`, `UpdateAssemblyInfo` and `GetVersion` +Properties `WriteVersionInfoToBuildLog`, `UpdateAssemblyInfo`, `UseFullSemVerForNuGet`, `UpdateVersionProperties` and `GetVersion` are checked before running these tasks. You can disable `GitVersionTask.UpdateAssemblyInfo` by setting @@ -150,6 +171,7 @@ this: ... ``` +For SDK-style projects, `UpdateVersionProperties` controls setting the default variables: `Version`, `VersionPrefix`, `VersionSuffix`, `PackageVersion`, `InformationalVersion`, `AssemblyVersion` and `FileVersion`. ## My Git repository requires authentication. What should I do? diff --git a/src/GitVersionTask/GitVersionTask.csproj b/src/GitVersionTask/GitVersionTask.csproj index 08819d98f1..ab0797f3b7 100644 --- a/src/GitVersionTask/GitVersionTask.csproj +++ b/src/GitVersionTask/GitVersionTask.csproj @@ -79,9 +79,8 @@ - - Designer - + + Designer @@ -127,7 +126,8 @@ - + + diff --git a/src/GitVersionTask/NugetAssets/GitVersionTask.targets b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets similarity index 72% rename from src/GitVersionTask/NugetAssets/GitVersionTask.targets rename to src/GitVersionTask/NugetAssets/build/GitVersionTask.targets index e0fc3cbc36..fbdc9169f4 100644 --- a/src/GitVersionTask/NugetAssets/GitVersionTask.targets +++ b/src/GitVersionTask/NugetAssets/build/GitVersionTask.targets @@ -8,8 +8,13 @@ true - + + false true + + + true + false true @@ -27,7 +32,7 @@ TaskName="GitVersionTask.WriteVersionInfoToBuildLog" AssemblyFile="$(GitVersionTaskLibrary)GitVersionTask.dll" /> - + @@ -49,7 +54,7 @@ - + @@ -77,6 +82,18 @@ + + + $(GitVersion_FullSemVer) + $(GitVersion_MajorMinorPatch) + $(GitVersion_NuGetPreReleaseTag) + $(GitVersion_PreReleaseTag) + $(GitVersion_NuGetVersion) + $(GitVersion_FullSemVer) + $(GitVersion_InformationalVersion) + $(GitVersion_AssemblySemVer) + $(GitVersion_MajorMinorPatch).$(GitVersion_CommitsSinceVersionSource) + @@ -93,6 +110,4 @@ - - - + \ No newline at end of file diff --git a/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets b/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets new file mode 100644 index 0000000000..d6def32a59 --- /dev/null +++ b/src/GitVersionTask/NugetAssets/buildMultiTargeting/GitVersionTask.targets @@ -0,0 +1,79 @@ + + + + $(MSBuildProjectDirectory)\..\ + false + + + true + + + false + true + + true + + + true + false + + $(MSBuildThisFileDirectory)..\build\ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(GitVersion_FullSemVer) + $(GitVersion_MajorMinorPatch) + $(GitVersion_NuGetPreReleaseTag) + $(GitVersion_PreReleaseTag) + $(GitVersion_NuGetVersion) + $(GitVersion_FullSemVer) + $(GitVersion_InformationalVersion) + $(GitVersion_AssemblySemVer) + $(GitVersion_MajorMinorPatch).$(GitVersion_CommitsSinceVersionSource) + + + + \ No newline at end of file