Skip to content

Commit

Permalink
Merge branch 'release/0.22.0'
Browse files Browse the repository at this point in the history
* release/0.22.0:
  (#106) Rename and upload unsigned msi
  (#106) Upload MSI following signing step
  (#105) Allow local build to upload artifacts
  • Loading branch information
gep13 committed Mar 28, 2023
2 parents 206526a + a546a39 commit 3584c19
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
31 changes: 28 additions & 3 deletions Chocolatey.Cake.Recipe/Content/build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ BuildParameters.Tasks.BuildMsiTask = Task("Build-MSI")
.Does(() => RequireTool(ToolSettings.WixTool, () => RequireTool(ToolSettings.MSBuildExtensionPackTool, () => {
Information("Building MSI from the following solution: {0}", BuildParameters.SolutionFilePath);

var msbuildLogFile = BuildParameters.Paths.Directories.Build + "/MSBuild.msi.log";
var msbuildSettings = new MSBuildSettings
{
ToolPath = ToolSettings.MSBuildToolPath
Expand All @@ -467,11 +468,35 @@ BuildParameters.Tasks.BuildMsiTask = Task("Build-MSI")
Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath,
"XmlFileLogger",
string.Format(
"logfile=\"{0}\";invalidCharReplacement=_;verbosity=Detailed;encoding=UTF-8",
BuildParameters.Paths.Directories.Build + "/MSBuild.msi.log")
"logfile=\"{0}\";invalidCharReplacement=_;verbosity=Detailed;encoding=UTF-8", msbuildLogFile
)
);

MSBuild(BuildParameters.SolutionFilePath, msbuildSettings);

if (FileExists(msbuildLogFile)) {
BuildParameters.BuildProvider.UploadArtifact(msbuildLogFile);
}

if (BuildSystem.IsLocalBuild && BuildParameters.GetMsisToSign != null)
{
foreach (var msiToUpload in BuildParameters.GetMsisToSign())
{
if (FileExists(msiToUpload))
{
var msiDirectory = msiToUpload.GetDirectory();
var unsignedMsiToUpload = msiDirectory.CombineWithFilePath(msiToUpload.GetFilenameWithoutExtension() + "-unsigned" + msiToUpload.GetExtension());
// Copy the MSI to upload the unsigned variant. This ensures the original file is in place for the Sign step.
CopyFile(msiToUpload, unsignedMsiToUpload);
BuildParameters.BuildProvider.UploadArtifact(unsignedMsiToUpload);
DeleteFile(unsignedMsiToUpload);
}
else
{
Warning("The MSI expected ({0}) was not found for upload.", msiToUpload);
}
}
}
})
));

Expand Down Expand Up @@ -604,4 +629,4 @@ public class Builder
BuildParameters.Tasks.PublishAwsLambdasTask.IsDependentOn("DotNetBuild");
}
}
}
}
6 changes: 4 additions & 2 deletions Chocolatey.Cake.Recipe/Content/localbuild.cake
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ public class LocalBuildBuildProvider : IBuildProvider
public void UploadArtifact(FilePath file)
{
_context.Information("Uploading artifact from path: {0}", file.FullPath);
_context.Information("Unable to upload artifacts as running local build");
var destinationFile = BuildParameters.Paths.Directories.Build.Combine("Artifacts").CombineWithFilePath(file.GetFilename());
_context.EnsureDirectoryExists(destinationFile.GetDirectory());
_context.CopyFile(file, destinationFile);
}
}
}
7 changes: 6 additions & 1 deletion Chocolatey.Cake.Recipe/Content/sign.cake
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,15 @@ BuildParameters.Tasks.SignMsisTask = Task("Sign-Msis")
TimeStampDigestAlgorithm = (SignToolDigestAlgorithm)Enum.Parse(typeof(SignToolDigestAlgorithm), BuildParameters.CertificateAlgorithm, true)
});
}

if (FileExists(msiToSign))
{
BuildParameters.BuildProvider.UploadArtifact(msiToSign);
}
}
}
else
{
Information("There are no msi's defined to be signed.");
}
});
});

0 comments on commit 3584c19

Please sign in to comment.