Skip to content

Commit

Permalink
Updated build.cake to support deploying symbol package
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansjones committed Aug 3, 2018
1 parent 952f595 commit bdbb579
Show file tree
Hide file tree
Showing 3 changed files with 247 additions and 70 deletions.
3 changes: 3 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### new in 1.0.6.1 (Release 2018/08/02)
* Change: Updated `build.cake` to support deploying symbol package

### new in 1.0.6 (Release 2018/08/02)
* Change: `Watch` and `WatchOnce` now use an _Infinite_ timeout

Expand Down
74 changes: 23 additions & 51 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ var solution = baseDir.GetFilePath(projectName + ".sln");
var solutionDir = solution.GetDirectory();
var packagingRoot = baseDir.Combine("publish");
var testResultsDir = baseDir.Combine("TestResults");
var nugetPackagingDir = packagingRoot.Combine(projectName);
var sourcesDir = solutionDir.Combine("source");
var testsDir = solutionDir.Combine("tests");
var metaDir = solutionDir.Combine("meta");

// Files
var solutionInfoCs = metaDir.GetFilePath("SolutionInfo.cs");
var nuspecFile = metaDir.GetFilePath(projectName + ".nuspec");
var licenseFile = solutionDir.GetFilePath("LICENSE.txt");
var readmeFile = solutionDir.GetFilePath("README.md");
var releaseNotesFile = solutionDir.GetFilePath("ReleaseNotes.md");

var appVeyorEnv = Context.AppVeyor().Environment;
Expand Down Expand Up @@ -62,9 +59,10 @@ Setup(context =>
{
CreateDirectory(testResultsDir);
}
if (!DirectoryExists(nugetPackagingDir))

if (DirectoryExists(packagingRoot))
{
CreateDirectory(nugetPackagingDir);
CleanDirectory(packagingRoot);
}
});

Expand Down Expand Up @@ -95,15 +93,13 @@ Task("Clean")
});

Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
Information("Restoring {0}", solution);
NuGetRestore(solution);
});

Task("AssemblyInfo")
.IsDependentOn("Restore")
.WithCriteria(() => !isReleaseBuild)
.Does(() =>
{
Expand All @@ -117,78 +113,52 @@ Task("AssemblyInfo")
});

Task("Build")
.IsDependentOn("Clean")
.IsDependentOn("Restore")
.IsDependentOn("AssemblyInfo")
.Does(() =>
{
Information("Building {0}", solution);
MSBuild(solution, settings =>
settings.SetConfiguration(configuration)
MSBuild(solution, settings => settings
.SetConfiguration(configuration)
.SetVerbosity(Context.Log.Verbosity)
.SetMaxCpuCount(System.Environment.ProcessorCount)
.SetNodeReuse(false)
.WithProperty("UseSharedCompilation", "false")
);
});

Task("UnitTests")
.IsDependentOn("Build")
.Does(() =>
{
Information("Running Tests in {0}", solution);

var testAssemblies = GetFiles(testsDir + "/**/bin/" + configuration + "/**/*.Tests*.dll").ToList();

testAssemblies.ForEach(x => Information("Test File: {0}", x.GetFilename()));

XUnit2(
testAssemblies,
new XUnit2Settings {
OutputDirectory = testResultsDir,
HtmlReport = true,
XmlReport = true
NUnitReport = true,
XmlReport = true,
}
);
});

Task("CopyNugetPackageFiles")
.IsDependentOn("UnitTests")
.Does(() =>
{

var baseBuildDir = sourcesDir.Combine(projectName).Combine("bin").Combine(configuration);

var net45BuildDir = baseBuildDir.Combine("Net45");
var net45PackageDir = nugetPackagingDir.Combine("lib/net45/");

var dirMap = new Dictionary<DirectoryPath, DirectoryPath> {
{ net45BuildDir, net45PackageDir }
};

CleanDirectories(dirMap.Values);

foreach (var dirPair in dirMap)
{
var files = GetFiles(dirPair.Key + "/" + projectName + "*");
CopyFiles(files, dirPair.Value);
}

var packageFiles = new FilePath[] {
licenseFile,
readmeFile,
releaseNotesFile
};

CopyFiles(packageFiles, nugetPackagingDir);
});

Task("CreateNugetPackage")
.IsDependentOn("CopyNugetPackageFiles")
.WithCriteria(() => isReleaseBuild || forcePackage)
.Does(() =>
{
NuGetPack(
nuspecFile,
new NuGetPackSettings {
Version = semVersion,
ReleaseNotes = releaseNotes.Notes.ToArray(),
BasePath = nugetPackagingDir,
BasePath = solutionDir,
OutputDirectory = packagingRoot,
Symbols = false,
Symbols = true,
NoPackageAnalysis = false
}
);
Expand All @@ -198,12 +168,14 @@ Task("CreateNugetPackage")
// TASK TARGETS
///////////////////////////////////////////////////////////////////////////////

Task("Package")
.IsDependentOn("CreateNugetPackage")
.WithCriteria(() => isReleaseBuild || forcePackage);
Task("Test")
.IsDependentOn("Build")
.IsDependentOn("UnitTests");

Task("Default")
.IsDependentOn("Package");
.IsDependentOn("Build")
.IsDependentOn("UnitTests")
.IsDependentOn("CreateNugetPackage");

///////////////////////////////////////////////////////////////////////////////
// EXECUTION
Expand Down
Loading

0 comments on commit bdbb579

Please sign in to comment.