Skip to content

Commit

Permalink
Include _net8 directories for sign steps. (#3690)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyju authored May 22, 2024
1 parent 2218890 commit a0fe7af
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions build/BuildSteps.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Build
{
public static class BuildSteps
{
private const string Net8ArtifactNameSuffix = "_net8";
private static readonly string _wwwroot = Environment.ExpandEnvironmentVariables(@"%HOME%\site\wwwroot");
private static IntegrationTestBuildManifest _integrationManifest;

Expand Down Expand Up @@ -139,7 +140,7 @@ private static string BuildNet8ArtifactFullPath(string runtime)
return Path.Combine(Settings.OutputDir, BuildNet8ArtifactDirectory(runtime));
}

private static string BuildNet8ArtifactDirectory(string runtime) => runtime + "_net8.0";
private static string BuildNet8ArtifactDirectory(string runtime) => $"{runtime}{Net8ArtifactNameSuffix}";

private static void ExecuteDotnetPublish(string outputPath, string rid, string targetFramework, bool skipLaunchingNet8ChildProcess)
{
Expand Down Expand Up @@ -355,7 +356,9 @@ public static void CopyBinariesToSign()
Directory.CreateDirectory(thirdPartyDirectory);
Directory.CreateDirectory(macDirectory);

foreach (var supportedRuntime in Settings.SignInfo.RuntimesToSign)
var combinedRuntimesToSign = GetAllRuntimesToSign();

foreach (var supportedRuntime in combinedRuntimesToSign)
{
var sourceDir = Path.Combine(Settings.OutputDir, supportedRuntime);
var dirName = $"Azure.Functions.Cli.{supportedRuntime}.{CurrentVersion}";
Expand Down Expand Up @@ -413,7 +416,9 @@ public static void TestPreSignedArtifacts()
{
var filterExtensionsSignSet = new HashSet<string>(Settings.SignInfo.FilterExtensionsSign);

foreach (var supportedRuntime in Settings.SignInfo.RuntimesToSign)
var combinedRuntimesToSign = GetAllRuntimesToSign();

foreach (var supportedRuntime in combinedRuntimesToSign)
{
if (supportedRuntime.StartsWith("osx"))
{
Expand Down Expand Up @@ -491,9 +496,12 @@ public static List<string> GetUnsignedBinaries(string targetDir)
{
// Download sigcheck.exe
var sigcheckPath = Path.Combine(Settings.OutputDir, "sigcheck.exe");
using (var client = new WebClient())
if (!File.Exists(sigcheckPath))
{
client.DownloadFile(Settings.SignInfo.SigcheckDownloadURL, sigcheckPath);
using (var client = new WebClient())
{
client.DownloadFile(Settings.SignInfo.SigcheckDownloadURL, sigcheckPath);
}
}

// https://peter.hahndorf.eu/blog/post/2010/03/07/WorkAroundSysinternalsLicensePopups
Expand Down Expand Up @@ -562,7 +570,7 @@ public static void Zip()

// Zip the .net8 version as well.
var net8Path = BuildNet8ArtifactFullPath(runtime);
var net8ZipPath = zipPath.Replace(".zip", "_net8.0.zip");
var net8ZipPath = Path.Combine(Settings.OutputDir, $"Azure.Functions.Cli.{runtime}{Net8ArtifactNameSuffix}.{version}.zip");
CreateZipFromArtifact(net8Path, net8ZipPath);


Expand All @@ -573,10 +581,11 @@ public static void Zip()
try
{
Directory.Delete(artifactPath, recursive: true);
Directory.Delete(net8Path, recursive: true);
}
catch (Exception ex)
{
ColoredConsole.Error.WriteLine($"Error deleting {artifactPath}. Exception: {ex}");
ColoredConsole.Error.WriteLine($"Error deleting artifact for runtime {runtime}. Exception: {ex}");
}
}

Expand Down Expand Up @@ -724,9 +733,29 @@ public static void LogIntoAzure()
}
}

/// <summary>
/// Returns all target runtimes and their net8.0 versions.
/// </summary>
private static IEnumerable<string> GetAllTargetRuntimes()
{
var targetRuntimes = Settings.TargetRuntimes;
var net8Runtimes = targetRuntimes.Select(r => BuildNet8ArtifactDirectory(r));

return targetRuntimes.Concat(net8Runtimes);
}

private static IEnumerable<string> GetAllRuntimesToSign()
{
var runtimeToSign = Settings.SignInfo.RuntimesToSign;
var net8Runtimes = runtimeToSign.Select(r => BuildNet8ArtifactDirectory(r));

return runtimeToSign.Concat(net8Runtimes);
}

public static void AddGoZip()
{
foreach (var runtime in Settings.TargetRuntimes)
var combinedRuntimesToSign = GetAllTargetRuntimes();
foreach (var runtime in combinedRuntimesToSign)
{
var outputPath = Path.Combine(Settings.OutputDir, runtime, "gozip");
Environment.SetEnvironmentVariable("GOARCH", "amd64");
Expand Down

0 comments on commit a0fe7af

Please sign in to comment.