Enable building on linux without project file changes (#1930)

* Introduce 'NoFramework' switch

This enables building via cake on linux without requiring adjustments on
other platforms, fixes #1745

* Revert hardcoding NoFramework in build.sh

* Skip GitVersion query for NoFramework build

This implies that NoFramework is intended for local use only
Accordingly a warning message has been set up in the Lifetime of the Build

* Rename NoFramework switch to CoreOnly

* Skip tool installation and formatting step for CoreOnly builds

* Default CoreOnly to false on windows and true otherwise

* Add CoreOnly switch to build variable output

* Fix 'native' msbuild on windows for both platforms

'native' msbuild invocations do not automatically set CoreOnly according to the platform
they are running on. As such we set CoreOnly to False on Windows, unless CoreOnly has been
specified already.
This commit is contained in:
Clemens Lieb
2019-01-31 07:36:30 +02:00
committed by Ryan Gribble
parent 8cd893d6d4
commit 5e751a6c38
12 changed files with 51 additions and 16 deletions

View File

@@ -19,4 +19,5 @@ before_script:
script:
- git fetch --unshallow --tags
- ./build.sh --linksources=true --verbosity=verbose
# disengage core only switch because mono ships .NETFramework targets
- ./build.sh --coreonly=false --linksources=true --verbosity=verbose

View File

@@ -6,7 +6,9 @@
<Authors>GitHub</Authors>
<Version>0.0.0-dev</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
<CoreOnly Condition="$(CoreOnly) == '' and $([MSBuild]::IsOsPlatform('Windows'))">False</CoreOnly>
<TargetFrameworks>netstandard1.1</TargetFrameworks>
<TargetFrameworks Condition="$(CoreOnly) != '' and !$(CoreOnly)">$(TargetFrameworks);net45</TargetFrameworks>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<AssemblyName>Octokit.Reactive</AssemblyName>
<PackageId>Octokit.Reactive</PackageId>

View File

@@ -4,7 +4,9 @@
<Description>Convention-based tests for Octokit</Description>
<AssemblyTitle>Octokit.Tests.Conventions</AssemblyTitle>
<Authors>GitHub</Authors>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<CoreOnly Condition="$(CoreOnly) == '' and $([MSBuild]::IsOsPlatform('Windows'))">False</CoreOnly>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="$(CoreOnly) != '' and !$(CoreOnly)">$(TargetFrameworks);net452</TargetFrameworks>
<NoWarn>$(NoWarn);CS4014;CS1998</NoWarn>
<AssemblyName>Octokit.Tests.Conventions</AssemblyName>
<PackageId>Octokit.Tests.Conventions</PackageId>

View File

@@ -4,7 +4,9 @@
<Description>Integration tests for Octokit</Description>
<AssemblyTitle>Octokit.Tests.Integration</AssemblyTitle>
<Authors>GitHub</Authors>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<CoreOnly Condition="$(CoreOnly) == '' and $([MSBuild]::IsOsPlatform('Windows'))">False</CoreOnly>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="$(CoreOnly) != '' and !$(CoreOnly)">$(TargetFrameworks);net452</TargetFrameworks>
<NoWarn>$(NoWarn);CS4014;CS1998</NoWarn>
<AssemblyName>Octokit.Tests.Integration</AssemblyName>
<PackageId>Octokit.Tests.Integration</PackageId>

View File

@@ -4,7 +4,9 @@
<Description>Tests for Octokit</Description>
<AssemblyTitle>Octokit.Tests</AssemblyTitle>
<Authors>GitHub</Authors>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<CoreOnly Condition="$(CoreOnly) == '' and $([MSBuild]::IsOsPlatform('Windows'))">False</CoreOnly>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="$(CoreOnly) != '' and !$(CoreOnly)">$(TargetFrameworks);net452</TargetFrameworks>
<NoWarn>$(NoWarn);CS4014;CS1998</NoWarn>
<AssemblyName>Octokit.Tests</AssemblyName>
<PackageId>Octokit.Tests</PackageId>

View File

@@ -6,7 +6,9 @@
<Authors>GitHub</Authors>
<Version>0.0.0-dev</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TargetFrameworks>netstandard1.1;net45</TargetFrameworks>
<CoreOnly Condition="$(CoreOnly) == '' and $([MSBuild]::IsOsPlatform('Windows'))">False</CoreOnly>
<TargetFrameworks>netstandard1.1</TargetFrameworks>
<TargetFrameworks Condition="$(CoreOnly) != '' and !$(CoreOnly)">$(TargetFrameworks);net45</TargetFrameworks>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<AssemblyName>Octokit</AssemblyName>
<PackageId>Octokit</PackageId>

View File

@@ -24,6 +24,8 @@ public class Context : FrostingContext
public bool AppVeyor { get; set; }
public bool TravisCI { get; set; }
public bool CoreOnly { get; set; }
public Project[] Projects { get; set; }
public DotNetCoreTestSettings GetTestSettings()

View File

@@ -12,6 +12,7 @@ public class Lifetime : FrostingLifetime<Context>
context.Target = context.Argument("target", "Default");
context.Configuration = context.Argument("configuration", "Release");
context.LinkSources = context.Argument("linkSources", false);
context.CoreOnly = context.Argument("CoreOnly", !context.IsRunningOnWindows());
context.Artifacts = "./packaging/";
@@ -19,6 +20,11 @@ public class Lifetime : FrostingLifetime<Context>
var buildSystem = context.BuildSystem();
context.IsLocalBuild = buildSystem.IsLocalBuild;
if (context.CoreOnly && !context.IsLocalBuild)
{
context.Warning("CoreOnly was specified on a non-local build. Artifacts may be versioned incorrectly!");
}
context.AppVeyor = buildSystem.AppVeyor.IsRunningOnAppVeyor;
context.TravisCI = buildSystem.TravisCI.IsRunningOnTravisCI;
context.IsTagged = IsBuildTagged(buildSystem);
@@ -50,9 +56,16 @@ public class Lifetime : FrostingLifetime<Context>
};
// Install tools
context.Information("Installing tools...");
ToolInstaller.Install(context, "GitVersion.CommandLine", "3.6.2");
ToolInstaller.Install(context, "Octokit.CodeFormatter", "1.0.0-preview");
if (context.CoreOnly)
{
context.Information("Skipping tool installation for core-only build");
}
else
{
context.Information("Installing tools...");
ToolInstaller.Install(context, "GitVersion.CommandLine", "3.6.2");
ToolInstaller.Install(context, "Octokit.CodeFormatter", "1.0.0-preview");
}
// Calculate semantic version.
context.Version = BuildVersion.Calculate(context);
@@ -63,6 +76,7 @@ public class Lifetime : FrostingLifetime<Context>
context.Information("Version suffix: {0}", context.Version.Suffix);
context.Information("Configuration: {0}", context.Configuration);
context.Information("LinkSources: {0}", context.LinkSources);
context.Information("CoreOnly: {0}", context.CoreOnly);
context.Information("Target: {0}", context.Target);
context.Information("AppVeyor: {0}", context.AppVeyor);
context.Information("TravisCI: {0}", context.TravisCI);

View File

@@ -14,6 +14,7 @@ public class Build : FrostingTask<Context>
ArgumentCustomization = args => args
.Append("/p:Version={0}", context.Version.GetSemanticVersion())
.Append("/p:SourceLinkCreate={0}", context.LinkSources.ToString().ToLower())
.Append("/p:CoreOnly={0}", context.CoreOnly),
});
}
}

View File

@@ -40,7 +40,9 @@ public sealed class FormatCode : FrostingTask<Context>
public override bool ShouldRun(Context context)
{
return context.IsRunningOnWindows();
// Core only builds do not download the formatter exe
// Only windows is guaranteed to be able to run exe files in the first place
return context.IsRunningOnWindows() && !context.CoreOnly;
}
private static string CreateTempCsproj(Context context, string projectName)

View File

@@ -21,7 +21,9 @@ public sealed class Package : FrostingTask<Context>
Configuration = context.Configuration,
NoBuild = true,
OutputDirectory = context.Artifacts,
ArgumentCustomization = args => args.Append("/p:Version={0}", context.Version.GetSemanticVersion())
ArgumentCustomization = args => args
.Append("/p:Version={0}", context.Version.GetSemanticVersion())
.Append("/p:CoreOnly={0}", context.CoreOnly),
});
}
}

View File

@@ -29,10 +29,13 @@ public class BuildVersion
public static BuildVersion Calculate(Context context)
{
string version = null;
string semVersion = null;
context.Information("Calculating semantic version...");
if (context.CoreOnly)
{
context.Information("Skipping GitVersion query for local build");
return new BuildVersion("0.0.0", "dev");
}
if (!context.IsLocalBuild)
{
// Run to set the version properties inside the CI server
@@ -42,8 +45,8 @@ public class BuildVersion
// Run in interactive mode to get the properties for the rest of the script
var assertedversions = GitVersionRunner.Run(context, GitVersionOutput.Json);
version = assertedversions.MajorMinorPatch;
semVersion = assertedversions.LegacySemVerPadded;
var version = assertedversions.MajorMinorPatch;
var semVersion = assertedversions.LegacySemVerPadded;
if (string.IsNullOrWhiteSpace(version))
{