Skip to content

Commit

Permalink
Ability to set the version when publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
lprichar committed Jan 24, 2018
1 parent a4bb736 commit 0b8e29a
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion build.cake
@@ -1,11 +1,14 @@
#tool nuget:?package=NUnit.ConsoleRunner&version=3.4.0
#addin "Cake.FileHelpers"

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
//////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var platform = Argument("platform", "x86");
string version = Argument("vers", "");

//////////////////////////////////////////////////////////////////////
// PREPARATION
Expand Down Expand Up @@ -69,8 +72,29 @@ Task("SignMsi")
});
});

Task("SetVersion")
.Does(() =>
{
if (string.IsNullOrEmpty(version)) {
throw new ArgumentNullException(nameof(version));
}
var versionRegex = "\"[1-9]+\\.[0-9]+\\.[0-9]+\"";
var newVersion = "\"" + version + "\"";
ReplaceRegexInFiles("./SirenOfShame/Properties/AssemblyInfo.cs", versionRegex, newVersion);
ReplaceRegexInFiles("./SirenOfShame.WixSetup/Product.wxs", versionRegex, newVersion);
});

// usage .\build.ps1 -t Publish -vers="2.4.12"
Task("Publish")
.IsDependentOn("SignMsi");
.IsDependentOn("SetVersion")
.IsDependentOn("SignMsi")
.Does(() =>
{
var versionWithDashes = version.Replace(".", "-");
MoveFile("./SirenOfShame.WixSetup/bin/Release/SirenOfShame.WixSetup.msi", $"./SirenOfShame.WixSetup/bin/Release/SirenOfShame-{versionWithDashes}.msi");
});

Task("Run-Unit-Tests")
.IsDependentOn("Build")
Expand Down

0 comments on commit 0b8e29a

Please sign in to comment.