diff --git a/build.cake b/build.cake index 67efa08..69701c9 100644 --- a/build.cake +++ b/build.cake @@ -1,7 +1,8 @@ #tool "nuget:?package=GitVersion.CommandLine" -#load "changelog.cake" +#load "scripts\utils.cake" using System.Xml.Linq; +using System.IO; ////////////////////////////////////////////////////////////////////// // ARGUMENTS @@ -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 }); + } +}); + ////////////////////////////////////////////////////////////////////// @@ -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 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); - }); -} diff --git a/bootstrap/LocalOracleDockerDb.ps1 b/scripts/LocalOracleDockerDb.ps1 similarity index 100% rename from bootstrap/LocalOracleDockerDb.ps1 rename to scripts/LocalOracleDockerDb.ps1 diff --git a/bootstrap/db_env.dat b/scripts/db_env.dat similarity index 100% rename from bootstrap/db_env.dat rename to scripts/db_env.dat diff --git a/changelog.cake b/scripts/utils.cake similarity index 78% rename from changelog.cake rename to scripts/utils.cake index c50bb22..a257588 100644 --- a/changelog.cake +++ b/scripts/utils.cake @@ -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 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 diff --git a/src/Tests.Dapper.Oracle/IntegrationTests/DatabaseFixture.cs b/src/Tests.Dapper.Oracle/IntegrationTests/DatabaseFixture.cs index 098a016..6e359ce 100644 --- a/src/Tests.Dapper.Oracle/IntegrationTests/DatabaseFixture.cs +++ b/src/Tests.Dapper.Oracle/IntegrationTests/DatabaseFixture.cs @@ -76,19 +76,20 @@ public Task DisposeAsync() private static string GetBootstrapFolder() { + Func 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"); } }