Skip to content

Commit

Permalink
Use tag to determine version
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaslevesque committed Sep 23, 2018
1 parent e45c36e commit ba38095
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tools/build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Runtime.CompilerServices;
using McMaster.Extensions.CommandLineUtils;
using static Bullseye.Targets;
Expand All @@ -17,7 +18,7 @@ static void Main(string[] args) =>
public bool ShowHelp { get; } = false;

[Option("-v|--version", "The version to build", CommandOptionType.SingleValue)]
public string Version { get; } = "0.0.0";
public string Version { get; } = null;

[Option("-c|--configuration", "The configuration to build", CommandOptionType.SingleValue)]
public string Configuration { get; } = "Release";
Expand Down Expand Up @@ -46,6 +47,8 @@ public void OnExecute(CommandLineApplication app)
string libraryProject = "src/AspNetCore.AsyncInitialization/AspNetCore.AsyncInitialization.csproj";
string testProject = "tests/AspNetCore.AsyncInitialization.Tests/AspNetCore.AsyncInitialization.Tests.csproj";

string version = GetVersion();

Target(
"artifactDirectories",
() =>
Expand All @@ -60,7 +63,7 @@ public void OnExecute(CommandLineApplication app)
DependsOn("artifactDirectories"),
() => Run(
"dotnet",
$"build -c \"{Configuration}\" /p:Version=\"{Version}\" /bl:\"{buildLogFile}\" \"{solutionFile}\""));
$"build -c \"{Configuration}\" /p:Version=\"{version}\" /bl:\"{buildLogFile}\" \"{solutionFile}\""));

Target(
"test",
Expand All @@ -74,11 +77,23 @@ public void OnExecute(CommandLineApplication app)
DependsOn("artifactDirectories", "build"),
() => Run(
"dotnet",
$"pack -c \"{Configuration}\" --no-build /p:Version=\"{Version}\" -o \"{packagesDir}\" \"{libraryProject}\""));
$"pack -c \"{Configuration}\" --no-build /p:Version=\"{version}\" -o \"{packagesDir}\" \"{libraryProject}\""));

Target("default", DependsOn("test", "pack"));

RunTargets(RemainingArguments);

string GetVersion()
{
if (!string.IsNullOrEmpty(Version))
return Version;

var tag = Environment.GetEnvironmentVariable("APPVEYOR_REPO_TAG_NAME");
if (!string.IsNullOrEmpty(tag))
return tag;

return "0.0.0";
}
}

private static string GetSolutionDirectory() =>
Expand Down

0 comments on commit ba38095

Please sign in to comment.