Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
More aggressively retry when creating stub executables, and do not st…
Browse files Browse the repository at this point in the history
…op the release if this fails.
  • Loading branch information
caesay committed Feb 27, 2022
1 parent 5535487 commit dfc5b53
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/SquirrelCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ static void Releasify(ReleasifyOptions options)
.Where(x => !x.Name.Contains("squirrel.exe", StringComparison.InvariantCultureIgnoreCase))
.Where(x => Utility.IsFileTopLevelInPackage(x.FullName, pkgPath))
.Where(x => Utility.ExecutableUsesWin32Subsystem(x.FullName))
.ForEachAsync(x => createExecutableStubForExe(x.FullName))
.Wait();
.ForEach(x => createExecutableStubForExe(x.FullName));
// sign all exe's in this package
new DirectoryInfo(pkgPath).GetAllFilesRecursively()
Expand Down Expand Up @@ -376,17 +375,23 @@ static async Task<string> createMsiPackage(string setupExe, IPackage package, bo
}
}

static async Task createExecutableStubForExe(string exeToCopy)
static void createExecutableStubForExe(string exeToCopy)
{
var target = Path.Combine(
Path.GetDirectoryName(exeToCopy),
Path.GetFileNameWithoutExtension(exeToCopy) + "_ExecutionStub.exe");
try {
var target = Path.Combine(
Path.GetDirectoryName(exeToCopy),
Path.GetFileNameWithoutExtension(exeToCopy) + "_ExecutionStub.exe");

await Utility.CopyToAsync(HelperExe.StubExecutablePath, target);
Utility.Retry(() => File.Copy(HelperExe.StubExecutablePath, target, true));

using var writer = new Microsoft.NET.HostModel.ResourceUpdater(target, true);
writer.AddResourcesFromPEImage(exeToCopy);
writer.Update();
Utility.Retry(() => {
using var writer = new Microsoft.NET.HostModel.ResourceUpdater(target, true);
writer.AddResourcesFromPEImage(exeToCopy);
writer.Update();
});
} catch (Exception ex) {
Log.ErrorException($"Error creating StubExecutable and copying resources for '{exeToCopy}'. This stub may or may not work properly.", ex);
}
}
}

Expand Down

0 comments on commit dfc5b53

Please sign in to comment.