Skip to content

Commit 0762cb5

Browse files
authored
Merge pull request #171 from clcrutch/feature/cake.addin
Cake Addin for getting Nerdbank.GitVersioning VersionOracle.
2 parents c518c03 + 8fa3615 commit 0762cb5

File tree

9 files changed

+125
-2
lines changed

9 files changed

+125
-2
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "wiki"]
2+
path = wiki
3+
url = https://github.com/AArnott/Nerdbank.GitVersioning.wiki.git

doc/cake.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Cake Build
2+
Add `#addin Cake.GitVersioning` to the top of your Cake Build script. See [here](Cake/GitVersioning/GitVersioningAliases.md) for usage. See [here](Nerdbank/GitVersioning/VersionOracle.md) for the VersionOracle usage.
3+
4+
## Example
5+
~~~~csharp
6+
Task("GetVersion")
7+
.Does(() =>
8+
{
9+
Information(GetVersioningGetVersion().SemVer2)
10+
});
11+
~~~~

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ You can install Nerdbank.GitVersioning into your projects via NuGet or NPM.
2828
* Use the [nbgv .NET Core CLI tool](doc/nbgv-cli.md) (recommended)
2929
* [NuGet installation instructions](doc/nuget-acquisition.md)
3030
* [NPM installation instructions](doc/npm-acquisition.md)
31+
* [Cake Build installation instructions](doc/cake.md)
3132

3233
You must also create [a version.json file](doc/versionJson.md) in your repo. See [migration notes](doc/migrating.md) if your repo already has a version.txt or version.json file from using another system.
3334

@@ -49,6 +50,7 @@ for these build systems:
4950
* [gulp](doc/gulp.md)
5051
* [DNX](doc/dotnet-cli.md)
5152
* [dotnet CLI](doc/dotnet-cli.md)
53+
* [Cake Build](doc/cake.md)
5254

5355
Also some special [cloud build considerations](doc/cloudbuild.md).
5456

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net461</TargetFramework>
5+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<Authors>Chris Crutchfield, Andrew Arnott</Authors>
7+
<Company>andarno</Company>
8+
<Description>Cake wrapper for Nerdbank.GitVersioning. Stamps your assemblies with semver 2.0 compliant git commit specific version information and provides NuGet versioning information as well.</Description>
9+
<Copyright>Copyright © Andrew Arnott</Copyright>
10+
<PackageTags>git commit versioning version assemblyinfo</PackageTags>
11+
<PackageProjectUrl>http://github.com/aarnott/Nerdbank.GitVersioning</PackageProjectUrl>
12+
<SignAssembly>false</SignAssembly>
13+
<!-- We include the whole OutputPath in this tools package. -->
14+
<IncludeBuildOutput>false</IncludeBuildOutput>
15+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);PackBuildOutputs</TargetsForTfmSpecificContentInPackage>
16+
</PropertyGroup>
17+
18+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
19+
<DocumentationFile>C:\git\Nerdbank.GitVersioning\src\..\bin\Cake.GitVersioning\Debug\net461\Cake.GitVersioning.xml</DocumentationFile>
20+
</PropertyGroup>
21+
22+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
23+
<DocumentationFile>C:\git\Nerdbank.GitVersioning\src\..\bin\Cake.GitVersioning\Release\net461\Cake.GitVersioning.xml</DocumentationFile>
24+
</PropertyGroup>
25+
26+
<!-- This is a tools package and should express no dependencies. -->
27+
<ItemDefinitionGroup>
28+
<ProjectReference>
29+
<PrivateAssets>all</PrivateAssets>
30+
</ProjectReference>
31+
<PackageReference>
32+
<PrivateAssets>all</PrivateAssets>
33+
</PackageReference>
34+
</ItemDefinitionGroup>
35+
36+
<ItemGroup>
37+
<PackageReference Include="Cake.Core" Version="0.26.0" />
38+
<PackageReference Include="DotNetMDDocs" Version="0.111.0" Condition=" '$(GenerateMarkdownApiDocs)' == 'true' " />
39+
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />
40+
</ItemGroup>
41+
42+
<ItemGroup>
43+
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
44+
</ItemGroup>
45+
46+
<Target Name="PackBuildOutputs" DependsOnTargets="SatelliteDllsProjectOutputGroup;DebugSymbolsProjectOutputGroup">
47+
<ItemGroup>
48+
<TfmSpecificPackageFile Include="$(OutputPath)\**\*" Exclude="$(OutputPath)\**\*.xml;$(OutputPath)\**\*.pdb;$(OutputPath)\**\Cake.Core.dll">
49+
<PackagePath>lib\$(TargetFramework)\</PackagePath>
50+
</TfmSpecificPackageFile>
51+
</ItemGroup>
52+
</Target>
53+
54+
<Target Name="SetNuSpecProperties" BeforeTargets="GenerateNuspec" DependsOnTargets="GetBuildVersion">
55+
<PropertyGroup>
56+
<PackageLicenseUrl>https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/$(GitCommitIdShort)/LICENSE.txt</PackageLicenseUrl>
57+
</PropertyGroup>
58+
</Target>
59+
</Project>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.IO;
2+
using System.Reflection;
3+
using Cake.Core;
4+
using Cake.Core.Annotations;
5+
using Nerdbank.GitVersioning;
6+
7+
namespace Cake.GitVersioning
8+
{
9+
/// <summary>
10+
/// Contains functionality for using Nerdbank.GitVersioning.
11+
/// </summary>
12+
[CakeAliasCategory("Git Versioning")]
13+
public static class GitVersioningAliases
14+
{
15+
/// <summary>
16+
/// Gets the Git Versioning version from the current repo.
17+
/// </summary>
18+
/// <example>
19+
/// Task("GetVersion")
20+
/// .Does(() =>
21+
/// {
22+
/// Information(GetVersioningGetVersion().SemVer2)
23+
/// });
24+
/// </example>
25+
/// <param name="context">The context.</param>
26+
/// <param name="projectDirectory">Directory to start the search for version.json.</param>
27+
/// <returns>The version information from Git Versioning.</returns>
28+
[CakeMethodAlias]
29+
public static VersionOracle GitVersioningGetVersion(this ICakeContext context, string projectDirectory = ".")
30+
{
31+
var fullProjectDirectory = (new DirectoryInfo(projectDirectory)).FullName;
32+
33+
GitExtensions.HelpFindLibGit2NativeBinaries(Path.GetDirectoryName(Assembly.GetAssembly(typeof(GitVersioningAliases)).Location));
34+
35+
return VersionOracle.Create(fullProjectDirectory, null, CloudBuild.Active);
36+
}
37+
}
38+
}

src/Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
44
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
55
<OutputPath>$(MSBuildThisFileDirectory)..\bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
6+
<DocumentationRootFolder>$(MSBuildThisFileDirectory)..\wiki\api</DocumentationRootFolder>
7+
68
<SignAssembly>true</SignAssembly>
79
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)strongname.snk</AssemblyOriginatorKeyFile>
810

src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
<PackageId>Nerdbank.GitVersioning.Core</PackageId>
88
</PropertyGroup>
99
<ItemGroup>
10+
<PackageReference Include="DotNetMDDocs" Version="0.111.0" PrivateAssets="all" Condition=" '$(GenerateMarkdownApiDocs)' == 'true' " />
1011
<PackageReference Include="LibGit2Sharp" Version="0.24.7-g9fca61fdda" PrivateAssets="None" />
11-
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
12+
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
1213
<PackageReference Include="System.Diagnostics.Process" Version="4.3.0" Condition=" '$(TargetFramework)' == 'netstandard1.3' " />
1314
<PackageReference Include="Validation" Version="2.3.7" />
1415
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />

src/Nerdbank.GitVersioning.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26228.9
4+
VisualStudioVersion = 15.0.27130.2010
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{4BD1A7CD-6F52-4F5A-825B-50E4D8C3ECFF}"
77
ProjectSection(SolutionItems) = preProject
@@ -28,6 +28,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSBuildExtensionTask", "MSB
2828
EndProject
2929
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nbgv", "nbgv\nbgv.csproj", "{EF4DAF23-6CE9-48C5-84C5-80AC80D3D07D}"
3030
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.GitVersioning", "Cake.GitVersioning\Cake.GitVersioning.csproj", "{1F267A97-DFE3-4166-83B1-9D236B7A09BD}"
32+
EndProject
3133
Global
3234
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3335
Debug|Any CPU = Debug|Any CPU
@@ -56,6 +58,10 @@ Global
5658
{EF4DAF23-6CE9-48C5-84C5-80AC80D3D07D}.Debug|Any CPU.Build.0 = Debug|Any CPU
5759
{EF4DAF23-6CE9-48C5-84C5-80AC80D3D07D}.Release|Any CPU.ActiveCfg = Release|Any CPU
5860
{EF4DAF23-6CE9-48C5-84C5-80AC80D3D07D}.Release|Any CPU.Build.0 = Release|Any CPU
61+
{1F267A97-DFE3-4166-83B1-9D236B7A09BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
62+
{1F267A97-DFE3-4166-83B1-9D236B7A09BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
63+
{1F267A97-DFE3-4166-83B1-9D236B7A09BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
64+
{1F267A97-DFE3-4166-83B1-9D236B7A09BD}.Release|Any CPU.Build.0 = Release|Any CPU
5965
EndGlobalSection
6066
GlobalSection(SolutionProperties) = preSolution
6167
HideSolutionNode = FALSE

wiki

Submodule wiki added at 45e4943

0 commit comments

Comments
 (0)