This repository has been archived by the owner on Aug 5, 2019. It is now read-only.
SimpleGitVersion with CodeCake
Alexandre Da Silva edited this page Jan 7, 2016
·
3 revisions
Thanks to SimpleGitVersion.Cake, SimpleGitVersion can be used easily in CodeCake! It supports both MSBuild and DNX projects. For more informations on CodeCake, see: https://github.com/SimpleGitVersion/CodeCake/wiki
Simply add a reference to SimpleGitVersion.Core
and SimpleGitVersion.Cake
In project.json
, add a dependency to SimpleGitVersion.Cake
Here are some snippets to do classical tasks.
var gitInfo = Cake.GetSimpleRepositoryInfo();
var gitInfo = dnxSolution.RepositoryInfo;
string configuration = null;
Task( "Check-Repository" )
.Does( () =>
{
var gitInfo = Cake.GetSimpleRepositoryInfo();
if( !gitInfo.IsValid ) throw new Exception( "Repository is not ready to be published." );
configuration = gitInfo.IsValidRelease && gitInfo.PreReleaseName.Length == 0 ? "Release" : "Debug";
} );
string configuration = null;
Task( "Check-Repository" )
.Does( () =>
{
var gitInfo = dnxSolution.RepositoryInfo;
if( !gitInfo.IsValid ) throw new Exception( "Repository is not ready to be published." );
configuration = gitInfo.IsValidRelease && gitInfo.PreReleaseName.Length == 0 ? "Release" : "Debug";
} );
For example, it can be executed after the repository check.
Task( "Set-ProjectVersion" )
.IsDependentOn( "Check-Repository" )
.Does( () =>
{
if( dnxSolution.UpdateProjectFiles( true ) > 0 )
{
Cake.DNURestore( c =>
{
c.Quiet = true;
c.ProjectPaths.UnionWith( dnxSolution.Projects.Select( p => p.ProjectFilePath ) );
} );
}
} );
For example, if the version is a valid release, or a CI build.
Task( "Push-Packages" )
.Does( () =>
{
if( gitInfo.IsValid )
{
if( gitInfo.IsValidRelease )
{
PushToReleaseFeed();
}
else
{
Debug.Assert( gitInfo.IsValidCIBuild );
PushToCIFeed();
}
}
else
{
Cake.Information( "Push-Packages step is skipped since Git repository info is not valid." );
}
} );