-
-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow sharing version computation with a user-owned project
Quickbuild requires that every P2P be to a git-controlled project. This makes it incompatible with NB.GV's running the MSBuild task to one of its own .targets files. To workaround this, a quickbuild user will have to define their own project that does nothing but compute the version using NB.GV, and then set `NBGV_CachingProjectReference` to the full path to this custom project. Note that no actual *caching* occurs at this stage when under quickbuild because quickbuild uses a new top-level msbuild call for every project. We'll need to combine this with caching version info to a file on disk for this to be a perf improvement in quickbuild.
- Loading branch information
Showing
8 changed files
with
80 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
<Project Sdk="Microsoft.Build.NoTargets"> | ||
<PropertyGroup> | ||
<TargetFramework>net5.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
<SkipCopyBuildProduct>true</SkipCopyBuildProduct> | ||
<NBGV_CacheMode>VersionGenerationTarget</NBGV_CacheMode> | ||
</PropertyGroup> | ||
</Project> | ||
``` | ||
|
||
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 | ||
<PropertyGroup> | ||
<!-- This entire repo has just one version.json file, so compute the version once and share with all projects in a large build. --> | ||
<GitVersionBaseDirectory>$(MSBuildThisFileDirectory)</GitVersionBaseDirectory> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(QBuild)' == '1' "> | ||
<NBGV_CacheMode>MSBuildTargetCaching</NBGV_CacheMode> | ||
<NBGV_CachingProjectReference>$(MSBuildThisFileDirectory)VersionGeneration\VersionGeneration.msbuildproj</NBGV_CachingProjectReference> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.*" PrivateAssets="all" /> | ||
</ItemGroup> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
...erdbank.GitVersioning.Inner.Empty.targets → ...ioning.Tasks/build/PrivateP2PCaching.proj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters