diff --git a/doc/quickbuild.md b/doc/quickbuild.md
new file mode 100644
index 00000000..0fc733b5
--- /dev/null
+++ b/doc/quickbuild.md
@@ -0,0 +1,55 @@
+# Microsoft's (internal) quickbuild
+
+Nerdbank.GitVersioning supports the Microsoft-internal quickbuild/cloudbuild tool.
+
+It works out of the box, but each project will recompute the version, which may accumulate to a significant increase in overall build time.
+
+🚧 A future version of Nerdbank.GitVersioning will cache version information as a file so that the following instructions will be effective. 🚧
+
+To calculate the version just once for an entire build, a few manual steps are required.
+
+1. Create this project in your repo. The suggested location is `VersionGeneration/VersionGeneration.msbuildproj`.
+
+ ```xml
+
+
+ net5.0
+ false
+ true
+ VersionGenerationTarget
+
+
+ ```
+
+ The `TargetFramework` property value is not important as no assemblies are built by this project,
+ but a value is nonetheless required for NuGet to be willing to consume the Nerdbank.GitVersioning package reference
+ (which is referenced in Directory.Build.props as described later).
+
+1. Add the SDK version to your repo-root level `global.json` file, if it is not already present.
+ The [latest available version from nuget.org](https://www.nuget.org/packages/microsoft.build.notargets) is recommended.
+
+ ```json
+ {
+ "msbuild-sdks": {
+ "Microsoft.Build.NoTargets": "3.1.0"
+ }
+ }
+ ```
+
+1. Modify your repo-root level `Directory.Build.props` file to contain these elements:
+
+ ```xml
+
+
+ $(MSBuildThisFileDirectory)
+
+
+
+ MSBuildTargetCaching
+ $(MSBuildThisFileDirectory)VersionGeneration\VersionGeneration.msbuildproj
+
+
+
+
+
+ ```
diff --git a/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs b/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs
index 3b4e00ea..57727e10 100644
--- a/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs
+++ b/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs
@@ -39,6 +39,25 @@ protected override void ApplyGlobalProperties(IDictionary global
=> globalProperties["NBGV_GitEngine"] = "Managed";
}
+[Trait("Engine", "Managed")]
+[Collection("Build")] // msbuild sets current directory in the process, so we can't have it be concurrent with other build tests.
+public class BuildIntegrationInProjectManagedTests : BuildIntegrationTests
+{
+ public BuildIntegrationInProjectManagedTests(ITestOutputHelper logger)
+ : base(logger)
+ {
+ }
+
+ protected override GitContext CreateGitContext(string path, string committish = null)
+ => GitContext.Create(path, committish, writable: false);
+
+ protected override void ApplyGlobalProperties(IDictionary globalProperties)
+ {
+ globalProperties["NBGV_GitEngine"] = "Managed";
+ globalProperties["NBGV_CacheMode"] = "None";
+ }
+}
+
[Trait("Engine", "LibGit2")]
[Collection("Build")] // msbuild sets current directory in the process, so we can't have it be concurrent with other build tests.
public class BuildIntegrationLibGit2Tests : BuildIntegrationTests
@@ -57,6 +76,7 @@ protected override void ApplyGlobalProperties(IDictionary global
public abstract class BuildIntegrationTests : RepoTestBase, IClassFixture
{
+ private const string GitVersioningPropsFileName = "NerdBank.GitVersioning.props";
private const string GitVersioningTargetsFileName = "NerdBank.GitVersioning.targets";
private const string UnitTestCloudBuildPrefix = "UnitTest: ";
private static readonly string[] ToxicEnvironmentVariablePrefixes = new string[]
@@ -1175,6 +1195,7 @@ private ProjectRootElement CreateNativeProjectRootElement(string projectDirector
{
var pre = ProjectRootElement.Create(reader, this.projectCollection);
pre.FullPath = Path.Combine(projectDirectory, projectName);
+ pre.InsertAfterChild(pre.CreateImportElement(Path.Combine(this.RepoPath, GitVersioningPropsFileName)), null);
pre.AddImport(Path.Combine(this.RepoPath, GitVersioningTargetsFileName));
return pre;
}
@@ -1186,6 +1207,7 @@ private ProjectRootElement CreateProjectRootElement(string projectDirectory, str
{
var pre = ProjectRootElement.Create(reader, this.projectCollection);
pre.FullPath = Path.Combine(projectDirectory, projectName);
+ pre.InsertAfterChild(pre.CreateImportElement(Path.Combine(this.RepoPath, GitVersioningPropsFileName)), null);
pre.AddImport(Path.Combine(this.RepoPath, GitVersioningTargetsFileName));
return pre;
}
diff --git a/src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj b/src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj
index 9e4bd7ef..1e9f8e11 100644
--- a/src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj
+++ b/src/NerdBank.GitVersioning.Tests/NerdBank.GitVersioning.Tests.csproj
@@ -12,7 +12,7 @@
-
+
false
Targets\%(FileName)%(Extension)
diff --git a/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.nuspec b/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.nuspec
index 47223cac..668b210e 100644
--- a/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.nuspec
+++ b/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.nuspec
@@ -48,9 +48,13 @@ IMPORTANT: The 3.x release may produce a different version height than prior maj
-
+
+
+
+
+
diff --git a/src/Nerdbank.GitVersioning.Tasks/build/InProjectVersionComputation.targets b/src/Nerdbank.GitVersioning.Tasks/build/InProjectVersionComputation.targets
new file mode 100644
index 00000000..349fff64
--- /dev/null
+++ b/src/Nerdbank.GitVersioning.Tasks/build/InProjectVersionComputation.targets
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ @(BuildMetadata, ',')
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Nerdbank.GitVersioning.Tasks/build/MSBuildTargetCaching.targets b/src/Nerdbank.GitVersioning.Tasks/build/MSBuildTargetCaching.targets
new file mode 100644
index 00000000..7e2b97ca
--- /dev/null
+++ b/src/Nerdbank.GitVersioning.Tasks/build/MSBuildTargetCaching.targets
@@ -0,0 +1,69 @@
+
+
+ $(NBGV_InnerGlobalProperties)GitRepoRoot=$(GitRepoRoot);
+ $(NBGV_InnerGlobalProperties)PublicRelease=$(PublicRelease);
+ $(NBGV_InnerGlobalProperties)_NBGV_BuildingRef=$(_NBGV_BuildingRef);
+ $(NBGV_InnerGlobalProperties)ProjectPathRelativeToGitRepoRoot=$(ProjectPathRelativeToGitRepoRoot);
+ $(NBGV_InnerGlobalProperties)GitVersionBaseDirectory=$(GitVersionBaseDirectory);
+ $(NBGV_InnerGlobalProperties)OverrideBuildNumberOffset=$(OverrideBuildNumberOffset);
+
+
+
+
+
+
+
+ <_BuildMetadataSnapped Include="@(BuildMetadata)" />
+
+
+
+
+ $(NBGV_InnerGlobalProperties)Configuration=Release;
+ $(NBGV_InnerGlobalProperties)Platform=AnyCPU;
+
+
+
+
+
+
+
+
+
+ GetBuildVersion_Properties;GetBuildVersion_CloudBuildVersionVars
+ $(NBGV_InnerGlobalProperties)BuildMetadata=@(BuildMetadata, ',');
+ @(NBGV_GlobalPropertiesToRemove)
+
+
+ false
+ false
+ true
+ false
+ true
+ all
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Common.targets b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Common.targets
index 047e2420..a360732f 100644
--- a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Common.targets
+++ b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Common.targets
@@ -1,6 +1,7 @@

+ <_NBGV_Common_Targets_Imported>true
<_NBGV_PlatformSuffix Condition=" '$(_NBGV_PlatformSuffix)' == '' and '$(MSBuildRuntimeType)' == 'Core' ">MSBuildCore/
<_NBGV_PlatformSuffix Condition=" '$(_NBGV_PlatformSuffix)' == '' ">MSBuildFull/
$(MSBuildThisFileDirectory)$(_NBGV_PlatformSuffix)
diff --git a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Inner.targets b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Inner.targets
index 8075fb21..ac037a13 100644
--- a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Inner.targets
+++ b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.Inner.targets
@@ -1,7 +1,7 @@

-
+
@@ -18,7 +18,7 @@
BuildingRef="$(_NBGV_BuildingRef)"
BuildMetadata="$(BuildMetadata.Replace(',',';'))"
DefaultPublicRelease="$(PublicRelease)"
- ProjectDirectory="$(ProjectDirectory)"
+ ProjectDirectory="$(GitVersionBaseDirectory)"
GitRepoRoot="$(GitRepoRoot)"
ProjectPathRelativeToGitRepoRoot="$(ProjectPathRelativeToGitRepoRoot)"
OverrideBuildNumberOffset="$(OverrideBuildNumberOffset)"
@@ -42,11 +42,5 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.props b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.props
new file mode 100644
index 00000000..0c994a77
--- /dev/null
+++ b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.props
@@ -0,0 +1,20 @@
+
+
+
+ None
+ MSBuildTargetCaching
+
+
+ $(MSBuildThisFileDirectory)PrivateP2PCaching.proj
+
+
diff --git a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets
index 33a2910f..232ee06b 100644
--- a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets
+++ b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets
@@ -25,7 +25,7 @@
false
-
+
@@ -37,7 +37,8 @@
- false
+ false
+ false
@@ -64,54 +65,9 @@
<_NBGV_BuildingRef Condition=" '$(_NBGV_BuildingRef)' == '' ">$(_NBGV_BuildingBranch)
$(MSBuildProjectDirectory)
- $(NBGV_InnerGlobalProperties)GitRepoRoot=$(GitRepoRoot);
- $(NBGV_InnerGlobalProperties)PublicRelease=$(PublicRelease);
- $(NBGV_InnerGlobalProperties)_NBGV_BuildingRef=$(_NBGV_BuildingRef);
- $(NBGV_InnerGlobalProperties)ProjectPathRelativeToGitRepoRoot=$(ProjectPathRelativeToGitRepoRoot);
- $(NBGV_InnerGlobalProperties)ProjectDirectory=$(GitVersionBaseDirectory);
- $(NBGV_InnerGlobalProperties)OverrideBuildNumberOffset=$(OverrideBuildNumberOffset);
- $(MSBuildThisFileDirectory)Nerdbank.GitVersioning.Inner.targets
-
-
-
-
-
-
-
- <_BuildMetadataSnapped Include="@(BuildMetadata)" />
-
-
-
-
-
- GetBuildVersion_Properties;GetBuildVersion_CloudBuildVersionVars
- $(NBGV_InnerGlobalProperties)BuildMetadata=@(BuildMetadata, ',');
- @(NBGV_GlobalPropertiesToRemove)
-
-
- false
- false
- true
- false
- true
-
-
-
-
-
-
-
-
-
-
-
+
%(Value)
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Nerdbank.GitVersioning.Tasks/buildCrossTargeting/Nerdbank.GitVersioning.props b/src/Nerdbank.GitVersioning.Tasks/buildCrossTargeting/Nerdbank.GitVersioning.props
new file mode 100644
index 00000000..6eb00eea
--- /dev/null
+++ b/src/Nerdbank.GitVersioning.Tasks/buildCrossTargeting/Nerdbank.GitVersioning.props
@@ -0,0 +1,4 @@
+
+
+
+