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

Commit

Permalink
Rename 'AssemblyRuntimeInfo' to 'SquirrelRuntimeInfo' so it's more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
caesay committed Mar 18, 2022
1 parent 2088297 commit 7a15378
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/Squirrel/IUpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ await This.ErrorIfThrows(() =>
public static void CreateShortcutForThisExe(this IAppTools This, ShortcutLocation location = ShortcutLocation.Desktop | ShortcutLocation.StartMenu)
{
This.CreateShortcutsForExecutable(
Path.GetFileName(AssemblyRuntimeInfo.EntryExePath),
Path.GetFileName(SquirrelRuntimeInfo.EntryExePath),
location,
Environment.CommandLine.Contains("squirrel-install") == false,
null, // shortcut arguments
Expand All @@ -266,7 +266,7 @@ public static void CreateShortcutForThisExe(this IAppTools This, ShortcutLocatio
public static void RemoveShortcutForThisExe(this IAppTools This, ShortcutLocation location = ShortcutLocation.Desktop | ShortcutLocation.StartMenu)
{
This.RemoveShortcutsForExecutable(
Path.GetFileName(AssemblyRuntimeInfo.EntryExePath),
Path.GetFileName(SquirrelRuntimeInfo.EntryExePath),
location);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Squirrel/Internal/HelperExe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ internal static class HelperExe
static HelperExe()
{
#if DEBUG
AddSearchPath(AssemblyRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "publish");
AddSearchPath(AssemblyRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor");
AddSearchPath(AssemblyRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "7zip");
AddSearchPath(AssemblyRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "wix");
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "build", "publish");
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor");
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "7zip");
AddSearchPath(SquirrelRuntimeInfo.BaseDirectory, "..", "..", "..", "vendor", "wix");
#else
AddSearchPath(AssemblyRuntimeInfo.BaseDirectory, "bin");
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/Internal/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ private static void DeleteFsiTree(FileSystemInfo fileSystemInfo)
private static void DeleteFsiVeryHard(FileSystemInfo fileSystemInfo)
{
// don't try to delete the running process
if (fileSystemInfo.FullName.Equals(AssemblyRuntimeInfo.EntryExePath, StringComparison.InvariantCultureIgnoreCase))
if (fileSystemInfo.FullName.Equals(SquirrelRuntimeInfo.EntryExePath, StringComparison.InvariantCultureIgnoreCase))
return;

// try to remove "ReadOnly" attributes
Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/SimpleSplat/PlatformModeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class PlatformModeDetector : IModeDetector
"XDESPROC.EXE",
};

var exeName = (new FileInfo(AssemblyRuntimeInfo.EntryExePath)).Name.ToUpperInvariant();
var exeName = (new FileInfo(SquirrelRuntimeInfo.EntryExePath)).Name.ToUpperInvariant();

if (designEnvironments.Any(x => x.Contains(exeName))) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/Sources/HttpClientFileDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class HttpClientFileDownloader : IFileDownloader
/// <summary>
/// The User-Agent sent with Squirrel requests
/// </summary>
public static ProductInfoHeaderValue UserAgent => new("Squirrel", AssemblyRuntimeInfo.ExecutingAssemblyName.Version.ToString());
public static ProductInfoHeaderValue UserAgent => new("Squirrel", SquirrelRuntimeInfo.ExecutingAssemblyName.Version.ToString());

/// <inheritdoc />
public virtual async Task DownloadFile(string url, string targetFile, Action<int> progress, string authorization, string accept)
Expand Down
4 changes: 2 additions & 2 deletions src/Squirrel/Sources/SimpleWebSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public virtual async Task<ReleaseEntry[]> GetReleaseFeed(Guid? stagingId = null,

var args = new Dictionary<string, string>();

if (AssemblyRuntimeInfo.SystemArchitecture != RuntimeCpu.Unknown) {
args.Add("arch", AssemblyRuntimeInfo.SystemArchitecture.ToString().ToLower());
if (SquirrelRuntimeInfo.SystemArchitecture != RuntimeCpu.Unknown) {
args.Add("arch", SquirrelRuntimeInfo.SystemArchitecture.ToString().ToLower());
}

if (latestLocalRelease != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public enum RuntimeCpu : ushort
/// Convenience class which provides runtime information about the current executing process,
/// in a way that is safe in older and newer versions of the framework.
/// </summary>
public static class AssemblyRuntimeInfo
public static class SquirrelRuntimeInfo
{
/// <summary> The path on disk of the entry assembly. </summary>
public static string EntryExePath { get; }
Expand All @@ -47,7 +47,7 @@ public static class AssemblyRuntimeInfo
/// <summary> The name of the current OS - eg. 'windows', 'linux', or 'osx'. </summary>
public static string SystemOsName { get; private set; }

static AssemblyRuntimeInfo()
static SquirrelRuntimeInfo()
{
EntryExePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
BaseDirectory = AppContext.BaseDirectory;
Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/UpdateManager.ApplyReleases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void executeSelfUpdate(SemanticVersion currentVersion)
// If we're running in the context of Update.exe, we can't
// update ourselves. Instead, ask the new Update.exe to do it
// once we exit
var ourLocation = AssemblyRuntimeInfo.EntryExePath;
var ourLocation = SquirrelRuntimeInfo.EntryExePath;
if (ourLocation != null && Path.GetFileName(ourLocation).Equals("update.exe", StringComparison.OrdinalIgnoreCase)) {
var appName = targetDir.Parent.Name;

Expand Down
2 changes: 1 addition & 1 deletion src/Squirrel/UpdateManager.InstallHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Task<RegistryKey> CreateUninstallerRegistryEntry(string uninstallCmd, str

public void KillAllProcessesBelongingToPackage()
{
var ourExePath = AssemblyRuntimeInfo.EntryExePath;
var ourExePath = SquirrelRuntimeInfo.EntryExePath;

Utility.EnumerateProcesses()
.Where(x => {
Expand Down
22 changes: 11 additions & 11 deletions src/Squirrel/UpdateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public partial class UpdateManager : IUpdateManager
public string AppDirectory => Path.Combine(_localAppDataDirectoryOverride ?? GetLocalAppDataDirectory(), AppId);

/// <summary>True if the current executable is inside the target <see cref="AppDirectory"/>.</summary>
public bool IsInstalledApp => isUpdateExeAvailable() ? Utility.IsFileInDirectory(AssemblyRuntimeInfo.EntryExePath, AppDirectory) : false;
public bool IsInstalledApp => isUpdateExeAvailable() ? Utility.IsFileInDirectory(SquirrelRuntimeInfo.EntryExePath, AppDirectory) : false;

/// <summary>The directory packages and temp files are stored in.</summary>
protected string PackagesDirectory => Utility.PackageDirectoryForAppDir(AppDirectory);
Expand Down Expand Up @@ -185,7 +185,7 @@ public void RemoveShortcutsForExecutable(string exeName, ShortcutLocation locati
public SemanticVersion CurrentlyInstalledVersion(string executable = null)
{
try {
executable = executable ?? AssemblyRuntimeInfo.EntryExePath;
executable = executable ?? SquirrelRuntimeInfo.EntryExePath;

if (!Utility.IsFileInDirectory(executable, AppDirectory))
return null;
Expand All @@ -209,7 +209,7 @@ public void SetProcessAppUserModelId()
return;
}

var exeName = Path.GetFileName(AssemblyRuntimeInfo.EntryExePath);
var exeName = Path.GetFileName(SquirrelRuntimeInfo.EntryExePath);

string appUserModelId;
if (_applicationIdOverride != null) {
Expand Down Expand Up @@ -272,7 +272,7 @@ public static void RestartApp(string exeToStart = null, string arguments = null)
// launching a different version than we started with (this is why
// we take the app's *name* rather than a full path)

exeToStart = exeToStart ?? Path.GetFileName(AssemblyRuntimeInfo.EntryExePath);
exeToStart = exeToStart ?? Path.GetFileName(SquirrelRuntimeInfo.EntryExePath);
var argsArg = arguments != null ?
String.Format("-a \"{0}\"", arguments) : "";

Expand Down Expand Up @@ -306,7 +306,7 @@ public static async Task<Process> RestartAppWhenExited(string exeToStart = null,
// launching a different version than we started with (this is why
// we take the app's *name* rather than a full path)

exeToStart = exeToStart ?? Path.GetFileName(AssemblyRuntimeInfo.EntryExePath);
exeToStart = exeToStart ?? Path.GetFileName(SquirrelRuntimeInfo.EntryExePath);
var argsArg = arguments != null ?
String.Format("-a \"{0}\"", arguments) : "";

Expand All @@ -326,14 +326,14 @@ internal Dictionary<ShortcutLocation, ShellLink> GetShortcutsForExecutable(strin
private static string GetLocalAppDataDirectory(string assemblyLocation = null)
{
// if we're installed and running as update.exe in the app folder, the app directory root is one folder up
if (AssemblyRuntimeInfo.IsSingleFile && Path.GetFileName(AssemblyRuntimeInfo.EntryExePath).Equals("Update.exe", StringComparison.OrdinalIgnoreCase)) {
var oneFolderUpFromAppFolder = Path.Combine(Path.GetDirectoryName(AssemblyRuntimeInfo.EntryExePath), "..");
if (SquirrelRuntimeInfo.IsSingleFile && Path.GetFileName(SquirrelRuntimeInfo.EntryExePath).Equals("Update.exe", StringComparison.OrdinalIgnoreCase)) {
var oneFolderUpFromAppFolder = Path.Combine(Path.GetDirectoryName(SquirrelRuntimeInfo.EntryExePath), "..");
return Path.GetFullPath(oneFolderUpFromAppFolder);
}

// if update exists above us, we're running from within a version directory, and the appdata folder is two above us
if (File.Exists(Path.Combine(AssemblyRuntimeInfo.BaseDirectory, "..", "Update.exe"))) {
var twoFoldersUpFromAppFolder = Path.Combine(Path.GetDirectoryName(AssemblyRuntimeInfo.EntryExePath), "..\\..");
if (File.Exists(Path.Combine(SquirrelRuntimeInfo.BaseDirectory, "..", "Update.exe"))) {
var twoFoldersUpFromAppFolder = Path.Combine(Path.GetDirectoryName(SquirrelRuntimeInfo.EntryExePath), "..\\..");
return Path.GetFullPath(twoFoldersUpFromAppFolder);
}

Expand Down Expand Up @@ -421,7 +421,7 @@ private static bool isUpdateExeAvailable()

private static string getUpdateExe()
{
var ourPath = AssemblyRuntimeInfo.EntryExePath;
var ourPath = SquirrelRuntimeInfo.EntryExePath;

// Are we update.exe?
if (ourPath != null &&
Expand All @@ -431,7 +431,7 @@ private static string getUpdateExe()
return Path.GetFullPath(ourPath);
}

var updateDotExe = Path.Combine(AssemblyRuntimeInfo.BaseDirectory, "..\\Update.exe");
var updateDotExe = Path.Combine(SquirrelRuntimeInfo.BaseDirectory, "..\\Update.exe");
var target = new FileInfo(updateDotExe);

if (!target.Exists)
Expand Down
2 changes: 1 addition & 1 deletion src/SquirrelCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static int Main(string[] args)
{ "verbose", "Print extra diagnostic logging", _ => verbose = true },
};

var exeName = Path.GetFileName(AssemblyRuntimeInfo.EntryExePath);
var exeName = Path.GetFileName(SquirrelRuntimeInfo.EntryExePath);
string sqUsage =
$"Squirrel {DisplayVersion}, tool for creating and deploying Squirrel releases" + Environment.NewLine +
$"Usage: {exeName} [verb] [--option:value]";
Expand Down
2 changes: 1 addition & 1 deletion src/Update/Logging.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public SetupLogLogger(bool saveInTemp, UpdateAction action)
{
var dir = saveInTemp ?
Utility.GetTempDirectory(null).FullName :
AssemblyRuntimeInfo.BaseDirectory;
SquirrelRuntimeInfo.BaseDirectory;

string name, archivename;
if (saveInTemp || action == UpdateAction.Unset) {
Expand Down
18 changes: 9 additions & 9 deletions src/Update/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static async Task Setup(string setupPath, bool silentInstall, bool checkInstall)
ISplashWindow splash = new ComposedWindow(appname, silentInstall, zp.SetupIconBytes, zp.SetupSplashBytes);

// verify that this package can be installed on this cpu architecture
if (AssemblyRuntimeInfo.SystemArchitecture == RuntimeCpu.x86 && zp.MachineArchitecture == RuntimeCpu.amd64) {
if (SquirrelRuntimeInfo.SystemArchitecture == RuntimeCpu.x86 && zp.MachineArchitecture == RuntimeCpu.amd64) {
splash.ShowErrorDialog("Incompatible System", "The current operating system uses the x86 cpu architecture, but this package requires an x64 system.");
return;
}
Expand Down Expand Up @@ -246,7 +246,7 @@ static async Task Setup(string setupPath, bool silentInstall, bool checkInstall)

static async Task Install(bool silentInstall, ProgressSource progressSource, string sourceDirectory = null)
{
sourceDirectory = sourceDirectory ?? AssemblyRuntimeInfo.BaseDirectory;
sourceDirectory = sourceDirectory ?? SquirrelRuntimeInfo.BaseDirectory;
var releasesPath = Path.Combine(sourceDirectory, "RELEASES");

Log.Info("Starting install, writing to {0}", sourceDirectory);
Expand Down Expand Up @@ -288,7 +288,7 @@ static async Task Install(bool silentInstall, ProgressSource progressSource, str
Directory.CreateDirectory(mgr.AppDirectory);

var updateTarget = Path.Combine(mgr.AppDirectory, "Update.exe");
Log.ErrorIfThrows(() => File.Copy(AssemblyRuntimeInfo.EntryExePath, updateTarget, true),
Log.ErrorIfThrows(() => File.Copy(SquirrelRuntimeInfo.EntryExePath, updateTarget, true),
"Failed to copy Update.exe to " + updateTarget);

await mgr.FullInstall(silentInstall, progressSource.Raise);
Expand Down Expand Up @@ -340,7 +340,7 @@ await Log.ErrorIfThrows(() =>
static async Task UpdateSelf()
{
waitForParentToExit();
var src = AssemblyRuntimeInfo.EntryExePath;
var src = SquirrelRuntimeInfo.EntryExePath;
var updateDotExeForOurPackage = Path.Combine(
Path.GetDirectoryName(src),
"..", "Update.exe");
Expand Down Expand Up @@ -406,9 +406,9 @@ static async Task Uninstall(string appName = null)
mgr.RemoveUninstallerRegistryEntry();

// if this exe is in the app directory, starts a process that will wait 3 seconds and then delete this exe
if (Utility.IsFileInDirectory(AssemblyRuntimeInfo.EntryExePath, mgr.AppDirectory)) {
if (Utility.IsFileInDirectory(SquirrelRuntimeInfo.EntryExePath, mgr.AppDirectory)) {
Process.Start(new ProcessStartInfo() {
Arguments = "/C choice /C Y /N /D Y /T 3 & Del \"" + AssemblyRuntimeInfo.EntryExePath + "\"",
Arguments = "/C choice /C Y /N /D Y /T 3 & Del \"" + SquirrelRuntimeInfo.EntryExePath + "\"",
WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, FileName = "cmd.exe"
});
}
Expand Down Expand Up @@ -455,7 +455,7 @@ static void ProcessStart(string exeName, string arguments, bool shouldWait)
}

// Find the latest installed version's app dir
var appDir = AssemblyRuntimeInfo.BaseDirectory;
var appDir = SquirrelRuntimeInfo.BaseDirectory;
var releases = ReleaseEntry.ParseReleaseFile(
File.ReadAllText(Utility.LocalReleaseFileForAppDir(appDir), Encoding.UTF8));

Expand Down Expand Up @@ -489,7 +489,7 @@ static void ProcessStart(string exeName, string arguments, bool shouldWait)

// Do not run an unsigned EXE if we ourselves are signed.
// Maybe TODO: check that it's signed with the same certificate as us?
if (AuthenticodeTools.IsTrusted(AssemblyRuntimeInfo.EntryExePath) && !AuthenticodeTools.IsTrusted(targetExe.FullName)) {
if (AuthenticodeTools.IsTrusted(SquirrelRuntimeInfo.EntryExePath) && !AuthenticodeTools.IsTrusted(targetExe.FullName)) {
Log.Error("File {0} is not trusted, and will not be run from a trusted context.", targetExe);
throw new ArgumentException();
}
Expand Down Expand Up @@ -532,7 +532,7 @@ static void waitForParentToExit()

static string getAppNameFromDirectory(string path = null)
{
path = path ?? AssemblyRuntimeInfo.BaseDirectory;
path = path ?? SquirrelRuntimeInfo.BaseDirectory;
return (new DirectoryInfo(path)).Name;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Update/StartupOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public StartupOption(string[] args)

private OptionSet Parse(string[] args)
{
var exeName = Path.GetFileName(AssemblyRuntimeInfo.EntryExePath);
var exeName = Path.GetFileName(SquirrelRuntimeInfo.EntryExePath);
var opts = new OptionSet() {
"",
#pragma warning disable CS0436 // Type conflicts with imported type
Expand Down

0 comments on commit 7a15378

Please sign in to comment.