Skip to content

Commit

Permalink
Update build
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgunn committed Apr 23, 2018
1 parent 0f56291 commit 3527979
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 30 deletions.
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for:
only:
- master

version: 0.1.6
version: 0.1.7

deploy:
- provider: Environment
Expand All @@ -38,4 +38,4 @@ for:
except:
- master

version: 0.1.6.{build}-{branch}
version: 0.1.7.{build}-{branch}
82 changes: 54 additions & 28 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,100 @@ var target = Argument("target", "Default");
var configuration = Argument("configuration", EnvironmentVariable("CONFIGURATION") ?? "Release");
var artifactsDirectory = @".\artifacts";
var version = EnvironmentVariable("APPVEYOR_BUILD_VERSION") ?? "0.0.0";
const string errorMessage = "Process returned an error (exit code {0}).";

Task("Clean")
.Does(() =>
{
CleanDirectories(artifactsDirectory);
StartAndReturnProcess("dotnet", new ProcessSettings
{
Arguments = "clean"
})
.WaitForExit();
var exitCode = StartProcess("dotnet", new ProcessSettings
{
Arguments = "clean"
});
if (exitCode != 0)
{
throw new CakeException();
}
});

Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore();
var exitCode = StartProcess("dotnet", new ProcessSettings
{
Arguments = "restore"
});
if (exitCode != 0)
{
throw new CakeException();
}
});

Task("Build")
.IsDependentOn("Restore")
.Does(() =>
{
StartAndReturnProcess("dotnet", new ProcessSettings
{
Arguments = $"build --configuration {configuration} --no-restore"
})
.WaitForExit();
var exitCode = StartProcess("dotnet", new ProcessSettings
{
Arguments = $"build --configuration {configuration} --no-restore"
});
if (exitCode != 0)
{
throw new CakeException(string.Format(System.Globalization.CultureInfo.InvariantCulture, errorMessage, exitCode));
}
});

Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var exitCode = 0;
foreach (var filePath in GetFiles(@".\test\**\*.csproj"))
{
if (AppVeyor.IsRunningOnAppVeyor)
{
StartAndReturnProcess("dotnet", new ProcessSettings
{
Arguments = $"test {filePath} --configuration {configuration} --logger:AppVeyor --no-build --no-restore"
})
.WaitForExit();
exitCode += StartProcess("dotnet", new ProcessSettings
{
Arguments = $"test {filePath} --configuration {configuration} --logger:AppVeyor --no-build --no-restore"
});
}
else
{
StartAndReturnProcess("dotnet", new ProcessSettings
{
Arguments = $"test {filePath} --configuration {configuration} --no-build --no-restore"
})
.WaitForExit();
exitCode += StartProcess("dotnet", new ProcessSettings
{
Arguments = $"test {filePath} --configuration {configuration} --no-build --no-restore"
});
}
}
if (exitCode != 0)
{
throw new CakeException(string.Format(System.Globalization.CultureInfo.InvariantCulture, errorMessage, exitCode));
}
});

Task("Publish")
.IsDependentOn("Test")
.Does(() =>
{
StartAndReturnProcess("dotnet", new ProcessSettings
{
Arguments = $@"pack src\Gunnsoft.IdentityServer.Stores.MongoDB --configuration {configuration} --no-restore /p:Version={version}"
})
.WaitForExit();
var exitCode = StartProcess("dotnet", new ProcessSettings
{
Arguments = $@"pack src\Gunnsoft.IdentityServer.Stores.MongoDB --configuration {configuration} --no-restore /p:Version={version}"
});
if (exitCode != 0)
{
throw new CakeException(string.Format(System.Globalization.CultureInfo.InvariantCulture, errorMessage, exitCode));
}
});

Task("Pack")
Task("Copy")
.IsDependentOn("Publish")
.Does(() =>
{
Expand All @@ -90,6 +116,6 @@ Task("Pack")
});

Task("Default")
.IsDependentOn("Pack");
.IsDependentOn("Copy");

RunTarget(target);

0 comments on commit 3527979

Please sign in to comment.