Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
Changing cake file to skip versioning on non-Windows (#2637)
Browse files Browse the repository at this point in the history
Changing cake file to skip versioning on non-Windows
  • Loading branch information
leastprivilege committed Sep 22, 2018
1 parent e60d524 commit f587504
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 32 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.


# User-specific files
*.suo
*.user
Expand Down
85 changes: 53 additions & 32 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -36,45 +36,55 @@ class VersionInfo

Setup(context =>
{
var gitVersions = Context.GitVersion();

versions = new VersionInfo
// only calculate versions if on Windows
// due to problems with GitVersion in the current setup - but also since Windows is our release platform anyways
if (isWindows)
{
InformationalVersion = gitVersions.InformationalVersion,
BranchName = gitVersions.BranchName,
PreReleaseLabel = gitVersions.PreReleaseLabel
};
var gitVersions = Context.GitVersion();

versions = new VersionInfo
{
InformationalVersion = gitVersions.InformationalVersion,
BranchName = gitVersions.BranchName,
PreReleaseLabel = gitVersions.PreReleaseLabel
};

// explicit version has been passed in as argument
if (!string.IsNullOrEmpty(versionOverride))
{
versions.AssemblyVersion = versionOverride;
versions.FileVersion = versionOverride;
// explicit version has been passed in as argument
if (!string.IsNullOrEmpty(versionOverride))
{
versions.AssemblyVersion = versionOverride;
versions.FileVersion = versionOverride;

if (!string.IsNullOrEmpty(suffixOverride))
if (!string.IsNullOrEmpty(suffixOverride))
{
versions.VersionSuffix = suffixOverride;
}
}
else
{
versions.VersionSuffix = suffixOverride;
versions.AssemblyVersion = gitVersions.AssemblySemVer;
versions.FileVersion = gitVersions.AssemblySemVer;

if (!string.IsNullOrEmpty(versions.PreReleaseLabel))
{
versions.VersionSuffix = gitVersions.PreReleaseLabel + gitVersions.CommitsSinceVersionSourcePadded;
}

}

Information("branch : " + versions.BranchName);
Information("pre-release label : " + versions.PreReleaseLabel);
Information("version : " + versions.AssemblyVersion);
Information("version suffix : " + versions.VersionSuffix);
Information("informational : " + versions.InformationalVersion);

msBuildSettings = GetMSBuildSettings();
}
else
{
versions.AssemblyVersion = gitVersions.AssemblySemVer;
versions.FileVersion = gitVersions.AssemblySemVer;

if (!string.IsNullOrEmpty(versions.PreReleaseLabel))
{
versions.VersionSuffix = gitVersions.PreReleaseLabel + gitVersions.CommitsSinceVersionSourcePadded;
}

Information("Skipping version calculation because not on Windows.");
msBuildSettings = null;
}

Information("branch : " + versions.BranchName);
Information("pre-release label : " + versions.PreReleaseLabel);
Information("version : " + versions.AssemblyVersion);
Information("version suffix : " + versions.VersionSuffix);
Information("informational : " + versions.InformationalVersion);

msBuildSettings = GetMSBuildSettings();
});

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -99,13 +109,18 @@ Task("Build")
MSBuildSettings = msBuildSettings
};
var projects = GetFiles("./src/**/*.csproj");
foreach(var project in projects)
{
DotNetCoreBuild(project.GetDirectory().FullPath, settings);
}
if (!isWindows)
{
Information("Not running on Windows - skipping building tests for .NET Framework");
settings.Framework = "netcoreapp2.1";
}
var tests = GetFiles("./test/**/*.csproj");
foreach(var test in tests)
{
Expand All @@ -130,7 +145,7 @@ Task("Test")
if (!isWindows)
{
Information("Not running on Windows - skipping tests for .NET Framework");
settings.Framework = "netcoreapp2.0";
settings.Framework = "netcoreapp2.1";
}
var projects = GetFiles("./test/**/*.csproj");
Expand Down Expand Up @@ -163,6 +178,12 @@ Task("Pack")

private bool SkipPack()
{
if (!isWindows)
{
Information("Skipping pack because not on Windows.");
return true;
}

if (String.IsNullOrEmpty(versions.PreReleaseLabel) && versions.BranchName != "master")
{
Information("Skipping pack of release version, because not on master.");
Expand Down

0 comments on commit f587504

Please sign in to comment.