in sdk/Sdk/Tasks/ZipDeploy/CreateZipFileTask.cs [57:83]
internal static void CreateZipFileFromDirectory(string directoryToZip, string destinationArchiveFileName)
{
System.IO.Compression.ZipFile.CreateFromDirectory(directoryToZip, destinationArchiveFileName);
// We may need to modify permissions for Linux.
string configJson = File.ReadAllText(Path.Combine(directoryToZip, "worker.config.json"));
var configJsonDoc = JsonDocument.Parse(configJson);
if (configJsonDoc.RootElement.TryGetProperty("description", out JsonElement description) &&
description.TryGetProperty("defaultExecutablePath", out JsonElement defaultExecutablePath) &&
defaultExecutablePath.ValueKind == JsonValueKind.String)
{
string? executable = defaultExecutablePath.GetString();
// if the executable path contains "{WorkerRoot}", it means we'll be executing this file directly (as
// opposed to running with 'dotnet ...'). If so, we need to make the file executable for Linux.
if (executable != null && executable.Contains(WorkerRootReplacement))
{
executable = executable.Replace(WorkerRootReplacement, string.Empty);
if (!string.IsNullOrEmpty(executable))
{
ModifyUnixFilePermissions(destinationArchiveFileName, directoryToZip, executable);
}
}
}
}