Last active
September 9, 2018 22:01
-
-
Save PaulWild/e6dafdd8800928238fd489b70bacc52f to your computer and use it in GitHub Desktop.
Basic Cake File for .net core and xunit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var target = Argument<string>("target", "Default"); | |
var configuration = Argument<string>("configuration", "Debug"); | |
var solution = "./PitchForkApiClient.sln"; | |
Task("Clean") | |
.Description("Cleans all directories that are used during the build process.") | |
.Does(() => | |
{ | |
CleanDirectories("./**/bin/" + configuration); | |
CleanDirectories("./**/obj/" + configuration); | |
}); | |
Task("Restore") | |
.Description("Restores all the NuGet packages that are used by the specified solution.") | |
.Does(() => | |
{ | |
Information("Restoring {0}...", solution); | |
NuGetRestore(solution); | |
}); | |
Task("Build") | |
.Description("Builds all the different parts of the project.") | |
.IsDependentOn("Clean") | |
.IsDependentOn("Restore") | |
.Does(() => | |
{ | |
Information("Building {0}", solution); | |
var buildSettings = new DotNetCoreBuildSettings | |
{ | |
Configuration = configuration, | |
NoRestore = true, | |
}; | |
DotNetCoreBuild(solution, buildSettings); | |
}); | |
Task("Run-Unit-Tests") | |
.IsDependentOn("Build") | |
.Does(() => | |
{ | |
var projects = GetFiles("./**/*.Tests.csproj"); | |
foreach(var project in projects) | |
{ | |
DotNetCoreTool(project, "xunit", "--no-build -noshadow -configuration " + configuration); | |
} | |
}); | |
Task("Default") | |
.Description("This is the default task which will be ran if no specific target is passed in.") | |
.IsDependentOn("Run-Unit-Tests"); | |
RunTarget(target); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment