Skip to content

Commit

Permalink
Updated build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
ravensorb committed Sep 26, 2018
1 parent 22c378f commit c14bed2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 15 deletions.
11 changes: 10 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,18 @@ Task("Build")
switch (settings.Build.BuildType)
{
case "dotnetcore":
var dotNetCoreBuildSettings = new DotNetCoreMSBuildSettings();
if (!string.IsNullOrEmpty(versionInfo.ToVersionPrefix()))
dotNetCoreBuildSettings.SetVersionPrefix(versionInfo.ToVersionPrefix());
if (!string.IsNullOrEmpty(versionInfo.ToVersionSuffix()))
dotNetCoreBuildSettings.SetVersionSuffix(versionInfo.ToVersionSuffix());
if (!string.IsNullOrEmpty(versionInfo.ToString()))
dotNetCoreBuildSettings.SetFileVersion(versionInfo.ToString(true));
DotNetCoreBuild(solution.ToString(), new DotNetCoreBuildSettings
{
Configuration = settings.Configuration
Configuration = settings.Configuration,
MSBuildSettings = dotNetCoreBuildSettings
}
);
break;
Expand Down
25 changes: 16 additions & 9 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ Specifies the amount of information to be displayed.
Shows description about tasks.
.PARAMETER DryRun
Performs a dry run.
.PARAMETER Experimental
Uses the nightly builds of the Roslyn script engine.
.PARAMETER Mono
Uses the Mono Compiler rather than the Roslyn script engine.
.PARAMETER SkipToolPackageRestore
Skips restoring of packages.
.PARAMETER ScriptArgs
Expand All @@ -49,13 +45,25 @@ Param(
[switch]$ShowDescription,
[Alias("WhatIf", "Noop")]
[switch]$DryRun,
[switch]$Experimental,
[switch]$Mono,
[switch]$SkipToolPackageRestore,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)

# Attempt to set highest encryption available for SecurityProtocol.
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
# will typically produce a message for PowerShell v2 (just an info
# message though)
try {
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
# installed (.NET 4.5 is an in-place upgrade).
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
} catch {
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
}

[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
function MD5HashFile([string] $filePath)
{
Expand Down Expand Up @@ -118,7 +126,8 @@ if (!(Test-Path $PACKAGES_CONFIG)) {
Write-Verbose -Message "Downloading packages.config..."
try {
$wc = GetProxyEnabledWebClient
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
} catch {
Throw "Could not download packages.config."
}
}
Expand Down Expand Up @@ -225,8 +234,6 @@ if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
if ($ShowDescription) { $cakeArguments += "-showdescription" }
if ($DryRun) { $cakeArguments += "-dryrun" }
if ($Experimental) { $cakeArguments += "-experimental" }
if ($Mono) { $cakeArguments += "-mono" }
$cakeArguments += $ScriptArgs

# Start Cake
Expand Down
2 changes: 1 addition & 1 deletion build.version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"Major":1,"Minor":1,"Build":5,"PreRelease":0,"ReleaseNotes":null,"Semantic":null,"Milestone":null,"CakeVersion":"0.30.0.0","IsPreRelease":false}
{"Major":1,"Minor":1,"Build":5,"PreRelease":0,"ReleaseNotes":null,"Semantic":null,"Milestone":null,"CakeVersion":"0.27.2.0","IsPreRelease":false}
Binary file modified tools/nuget.exe
Binary file not shown.
26 changes: 22 additions & 4 deletions tools/versionUtils.cake
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ public class VersionUtils
public class VersionInfo
{
[Newtonsoft.Json.JsonProperty("major")]
public int Major {get;set;}
public int? Major {get;set;}
[Newtonsoft.Json.JsonProperty("minor")]
public int Minor {get;set;}
public int? Minor {get;set;}
[Newtonsoft.Json.JsonProperty("build")]
public int Build {get;set;}
public int? Build {get;set;}
[Newtonsoft.Json.JsonProperty("preRelease")]
public int? PreRelease {get;set;}
[Newtonsoft.Json.JsonProperty("releaseNotes")]
Expand All @@ -213,14 +213,32 @@ public class VersionInfo
[Newtonsoft.Json.JsonIgnore]
public bool IsPreRelease { get { return PreRelease != null && PreRelease != 0; } }

public new string ToString(bool includePreRelease = true)
public string ToString(bool includePreRelease = true)
{
var str = string.Format("{0:#0}.{1:#0}.{2:#0}", Major, Minor, Build);
if (IsPreRelease && includePreRelease) str += string.Format("-pre{0:00}", PreRelease);

return str;
}

public string ToVersionPrefix()
{
if (Major == null || Major == 0) return string.Empty;

var str = string.Format("{0:#0}.{1:#0}.{2:#0}", Major, Minor, Build);

return str;
}

public string ToVersionSuffix()
{
if (!IsPreRelease) return string.Empty;

var str = string.Format("pre{0:00}", PreRelease);

return str;
}

public void Display(ICakeContext context)
{
context.Information("Version:");
Expand Down

0 comments on commit c14bed2

Please sign in to comment.