Skip to content

Commit

Permalink
Code-sign assemblies
Browse files Browse the repository at this point in the history
  • Loading branch information
GeertvanHorrik committed May 17, 2018
1 parent fe81a0d commit 7a0d623
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
4 changes: 4 additions & 0 deletions cake.config
@@ -0,0 +1,4 @@
; The configuration file for Cake.

[Settings]
SkipVerification=true
66 changes: 52 additions & 14 deletions deployment/cake/tasks.cake
@@ -1,3 +1,5 @@
#addin "nuget:?package=MagicChunks"

Information("Running target '{0}'", target);
Information("Using output directory '{0}'", outputRootDirectory);

Expand Down Expand Up @@ -83,6 +85,18 @@ Task("UpdateInfo")
};
CreateAssemblyInfo(solutionAssemblyInfoFileName, assemblyInfo);
foreach (var projectToPackage in projectsToPackage)
{
Information("Updating version for package '{0}'", projectToPackage);
var projectFileName = string.Format("./src/{0}/{0}.csproj", projectToPackage);
TransformConfig(projectFileName, new TransformationCollection
{
{ "Project/PropertyGroup/PackageVersion", versionNuGet }
});
}
});

//-------------------------------------------------------------
Expand All @@ -107,29 +121,53 @@ Task("Build")

//-------------------------------------------------------------

Task("CodeSign")
.IsDependentOn("Build")
.ContinueOnError()
.Does(() =>
{
var exeSignFilesSearchPattern = outputRootDirectory + string.Format("/**/*{0}*.exe", codeSignWildCard);
var dllSignFilesSearchPattern = outputRootDirectory + string.Format("/**/*{0}*.dll", codeSignWildCard);
List<FilePath> filesToSign = new List<FilePath>();
Information("Searching for files to code sign using '{0}'", exeSignFilesSearchPattern);
filesToSign.AddRange(GetFiles(exeSignFilesSearchPattern));
Information("Searching for files to code sign using '{0}'", dllSignFilesSearchPattern);
filesToSign.AddRange(GetFiles(dllSignFilesSearchPattern));
Information("Found '{0}' files to code sign", filesToSign.Count);
Sign(filesToSign, new SignToolSignSettings
{
AppendSignature = false,
TimeStampUri = new Uri(codeSignTimeStampUri),
CertSubjectName = codeSignCertificateSubjectName
});
});

//-------------------------------------------------------------

Task("Package")
.IsDependentOn("Build")
.IsDependentOn("CodeSign")
.Does(() =>
{
foreach (var projectToPackage in projectsToPackage)
{
Information("Packaging '{0}'", projectToPackage);
var msBuildSettings = new MSBuildSettings {
Verbosity = Verbosity.Minimal, // Verbosity.Diagnostic
ToolVersion = MSBuildToolVersion.VS2017,
Configuration = configurationName,
MSBuildPlatform = MSBuildPlatform.x86, // Always require x86, see platform for actual target platform
PlatformTarget = PlatformTarget.MSIL
};
msBuildSettings.Properties["ConfigurationName"] = new List<string>(new [] { configurationName });
msBuildSettings.Properties["PackageVersion"] = new List<string>(new [] { versionNuGet });
var projectFileName = string.Format("./src/{0}/{0}.csproj", projectToPackage);
msBuildSettings = msBuildSettings.WithTarget("pack");
var packSettings = new DotNetCorePackSettings
{
Configuration = configurationName,
NoBuild = true,
};
var projectFileName = string.Format("./src/{0}/{0}.csproj", projectToPackage);
MSBuild(projectFileName, msBuildSettings);
DotNetCorePack(projectFileName, packSettings);
}
});

Expand Down
3 changes: 3 additions & 0 deletions deployment/cake/variables.cake
Expand Up @@ -9,6 +9,9 @@ var versionNuGet = GetContinuaCIVariable("GitVersion_NuGetVersion", "3.0.0-alpha
var solutionName = GetContinuaCIVariable("SolutionName", string.Format("{0}.sln", projectName));
var configurationName = GetContinuaCIVariable("ConfigurationName", "Release");
var outputRootDirectory = GetContinuaCIVariable("OutputRootDirectory", string.Format("./output/{0}", configurationName));
var codeSignWildCard = GetContinuaCIVariable("CodeSignWildcard", projectName);
var codeSignCertificateSubjectName = GetContinuaCIVariable("CodeSignCertificateSubjectName", company);
var codeSignTimeStampUri = GetContinuaCIVariable("CodeSignTimeStampUri", "http://timestamp.comodoca.com/authenticode");

var nuGetPackageSources = GetContinuaCIVariable("NuGetPackageSources", string.Empty);
var repositoryUrl = GetContinuaCIVariable("RepositoryUrl", defaultRepositoryUrl);
Expand Down

0 comments on commit 7a0d623

Please sign in to comment.