Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 61 additions & 70 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#tool "nuget:?package=GitVersion.CommandLine"
#load "changelog.cake"
#load "scripts\utils.cake"

using System.Xml.Linq;
using System.IO;

//////////////////////////////////////////////////////////////////////
// ARGUMENTS
Expand Down Expand Up @@ -58,23 +59,79 @@ Task("test")
{
DotNetCoreTest(solutionFile, new DotNetCoreTestSettings
{
Configuration = configuration
Configuration = configuration,
NoBuild = true,
NoRestore = true
});
});

Task("signassemblies")
.IsDependentOn("build")
.Does(()=>
{
var thumbPrint = EnvironmentVariable("DIPSCodeSigningThumbPrint");
if(string.IsNullOrEmpty(thumbPrint))
{
Information("Skipping codesigning because environment variable for certificate not set.");
return;
}
var dir = Directory("./bin/release");

foreach (var item in System.IO.Directory.GetFiles(dir.Path.FullPath,"Dapper.Oracle*.dll",SearchOption.AllDirectories))
{
Sign(item, new SignToolSignSettings {
//TimeStampUri = new Uri("http://sha256timestamp.ws.symantec.com/sha256/timestamp"), TODO: Returns error, unsure as to why...
DigestAlgorithm = SignToolDigestAlgorithm.Sha256,
CertThumbprint = thumbPrint
});
}
});

Task("pack")
.IsDependentOn("test")
.IsDependentOn("signassemblies")
.Does(()=>
{
var settings = new DotNetCorePackSettings
{
Configuration = "Release",
OutputDirectory = "./artifacts/"
Configuration = configuration,
OutputDirectory = "./artifacts/",
NoBuild = true,
NoRestore = true
};

DotNetCorePack(solutionFile, settings);
});

Task("signnuget")
.IsDependentOn("pack")
.Does(()=>
{

FilePath nugetPath = Context.Tools.Resolve("nuget.exe");
Verbose($"Using nuget.exe from {nugetPath.FullPath}");

var thumbPrint = EnvironmentVariable("DIPSCodeSigningThumbPrint");
if(string.IsNullOrEmpty(thumbPrint))
{
Error("Unable to find thumbprint for codesigning");
return;
}
var dir = Directory("./artifacts");

foreach (var item in System.IO.Directory.GetFiles(dir.Path.FullPath,"*.nupkg"))
{
var arguments = new ProcessArgumentBuilder()
.Append("sign")
.Append(item)
.Append($"-CertificateFingerprint {thumbPrint}")
.Append($"-Timestamper http://sha256timestamp.ws.symantec.com/sha256/timestamp");

Verbose($"executing nuget.exe {arguments.Render()}");
StartProcess(nugetPath, new ProcessSettings { Arguments = arguments });
}
});



//////////////////////////////////////////////////////////////////////
Expand All @@ -95,73 +152,7 @@ RunTarget(target);



private void WriteImportOfVersionInfoToMsBuildFile()
{
WriteToMsBuildXml("./src/directory.build.props", root => {
root.AddFirst(
new XElement("Import",
new XAttribute("Project", "$(MSBuildThisFileDirectory)versioninfo.props"),
new XAttribute("Condition", "exists('$(MSBuildThisFileDirectory)versioninfo.props')")));
});
}

private void WriteToMsBuildXml(FilePath file, Action<XElement> add)
{
XElement root;

if (!FileExists(file))
{
Information("File not found, creating new");
root = new XElement(ns + "Project");
}
else
{
Information("Using existing file");
root = XElement.Load(file.FullPath);
}

add(root);
root.Save(file.FullPath, SaveOptions.None);
}


private FilePath GetVersionInfoFile()
{
return File("./src/versioninfo.props");
}

private void WriteVersionInformationToMsBuildFile(GitVersion version, FilePath changelogFile)
{
var log = ChangeLog.Parse(changelogFile.FullPath);
var releaseNotes = log?.GetVersion(version.MajorMinorPatch)?.Body;

// Ignore if version is prerelease
if (string.IsNullOrEmpty(releaseNotes))
{
if (string.IsNullOrEmpty(version.PreReleaseTag))
{
throw new Exception($"Release notes for version {version.MajorMinorPatch} is missing");
}

Warning($"Missing release notes for version {version.MajorMinorPatch} but ignoring it because this is a prelease version");
}

var file = GetVersionInfoFile();

WriteToMsBuildXml(file, root => {
Information($"Writing version information [{version.NuGetVersionV2}] to {file}");

root.Descendants(ns+"PropertyGroup").Remove();
var pg = new XElement(ns + "PropertyGroup");
pg.Add(new XElement(ns + "Version", version.AssemblySemFileVer));
pg.Add(new XElement(ns + "FileVersion", version.AssemblySemFileVer));
pg.Add(new XElement(ns + "AssemblyVersion", version.AssemblySemVer));
pg.Add(new XElement(ns + "InformationalVersion", version.InformationalVersion));
pg.Add(new XElement(ns + "PackageReleaseNotes", releaseNotes));

root.Add(pg);
});
}



Expand Down
File renamed without changes.
File renamed without changes.
68 changes: 68 additions & 0 deletions changelog.cake → scripts/utils.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,73 @@
using System.Text.RegularExpressions;

private void WriteImportOfVersionInfoToMsBuildFile()
{
WriteToMsBuildXml("./src/directory.build.props", root => {
root.AddFirst(
new XElement("Import",
new XAttribute("Project", "$(MSBuildThisFileDirectory)versioninfo.props"),
new XAttribute("Condition", "exists('$(MSBuildThisFileDirectory)versioninfo.props')")));
});
}

private void WriteToMsBuildXml(FilePath file, Action<XElement> add)
{
XElement root;

if (!FileExists(file))
{
Information("File not found, creating new");
root = new XElement(ns + "Project");
}
else
{
Information("Using existing file");
root = XElement.Load(file.FullPath);
}

add(root);
root.Save(file.FullPath, SaveOptions.None);
}


private FilePath GetVersionInfoFile()
{
return File("./src/versioninfo.props");
}

private void WriteVersionInformationToMsBuildFile(GitVersion version, FilePath changelogFile)
{
var log = ChangeLog.Parse(changelogFile.FullPath);
var releaseNotes = log?.GetVersion(version.MajorMinorPatch)?.Body;

// Ignore if version is prerelease
if (string.IsNullOrEmpty(releaseNotes))
{
if (string.IsNullOrEmpty(version.PreReleaseTag))
{
throw new Exception($"Release notes for version {version.MajorMinorPatch} is missing");
}

Warning($"Missing release notes for version {version.MajorMinorPatch} but ignoring it because this is a prelease version");
}

var file = GetVersionInfoFile();

WriteToMsBuildXml(file, root => {
Information($"Writing version information [{version.NuGetVersionV2}] to {file}");

root.Descendants(ns+"PropertyGroup").Remove();
var pg = new XElement(ns + "PropertyGroup");
pg.Add(new XElement(ns + "Version", version.AssemblySemFileVer));
pg.Add(new XElement(ns + "FileVersion", version.AssemblySemFileVer));
pg.Add(new XElement(ns + "AssemblyVersion", version.AssemblySemVer));
pg.Add(new XElement(ns + "InformationalVersion", version.InformationalVersion));
pg.Add(new XElement(ns + "PackageReleaseNotes", releaseNotes));

root.Add(pg);
});
}

private class ChangeLog
{
// patterns
Expand Down
11 changes: 6 additions & 5 deletions src/Tests.Dapper.Oracle/IntegrationTests/DatabaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,20 @@ public Task DisposeAsync()

private static string GetBootstrapFolder()
{
Func<string, bool> folderPredicate = (s) => File.Exists(Path.Combine(s, "scripts", "LocalOracleDockerDb.ps1"));

var folder = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
while (folder.Parent != null &&
!File.Exists(Path.Combine(folder.FullName, "bootstrap", "LocalOracleDockerDb.ps1")))
while (folder.Parent != null && !folderPredicate(folder.FullName))
{
folder = folder.Parent;
}

if (!File.Exists(Path.Combine(folder.FullName, "bootstrap", "LocalOracleDockerDb.ps1")))
if (!folderPredicate(folder.FullName))
{
throw new ApplicationException("Unable to find bootstrap folder, please verify repository contents");
throw new ApplicationException("Unable to find scripts folder, please verify repository contents");
}

return Path.Combine(folder.FullName, "bootstrap");
return Path.Combine(folder.FullName, "scripts");

}
}
Expand Down