本文整理匯總了C#中Squirrel.UpdateManager.KillAllExecutablesBelongingToPackage方法的典型用法代碼示例。如果您正苦於以下問題:C# UpdateManager.KillAllExecutablesBelongingToPackage方法的具體用法?C# UpdateManager.KillAllExecutablesBelongingToPackage怎麽用?C# UpdateManager.KillAllExecutablesBelongingToPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Squirrel.UpdateManager
的用法示例。
在下文中一共展示了UpdateManager.KillAllExecutablesBelongingToPackage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Install
public async Task Install(bool silentInstall, ProgressSource progressSource, string sourceDirectory = null)
{
sourceDirectory = sourceDirectory ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var releasesPath = Path.Combine(sourceDirectory, "RELEASES");
this.Log().Info("Starting install, writing to {0}", sourceDirectory);
if (!File.Exists(releasesPath)) {
this.Log().Info("RELEASES doesn't exist, creating it at " + releasesPath);
var nupkgs = (new DirectoryInfo(sourceDirectory)).GetFiles()
.Where(x => x.Name.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase))
.Select(x => ReleaseEntry.GenerateFromFile(x.FullName));
ReleaseEntry.WriteReleaseFile(nupkgs, releasesPath);
}
var ourAppName = ReleaseEntry.ParseReleaseFile(File.ReadAllText(releasesPath, Encoding.UTF8))
.First().PackageName;
using (var mgr = new UpdateManager(sourceDirectory, ourAppName)) {
this.Log().Info("About to install to: " + mgr.RootAppDirectory);
if (Directory.Exists(mgr.RootAppDirectory)) {
this.Log().Warn("Install path {0} already exists, burning it to the ground", mgr.RootAppDirectory);
mgr.KillAllExecutablesBelongingToPackage();
await Task.Delay(500);
await this.ErrorIfThrows(() => Utility.DeleteDirectory(mgr.RootAppDirectory),
"Failed to remove existing directory on full install, is the app still running???");
this.ErrorIfThrows(() => Utility.Retry(() => Directory.CreateDirectory(mgr.RootAppDirectory), 3),
"Couldn't recreate app directory, perhaps Antivirus is blocking it");
}
Directory.CreateDirectory(mgr.RootAppDirectory);
var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe");
this.ErrorIfThrows(() => File.Copy(Assembly.GetExecutingAssembly().Location, updateTarget, true),
"Failed to copy Update.exe to " + updateTarget);
await mgr.FullInstall(silentInstall, progressSource.Raise);
await this.ErrorIfThrows(() => mgr.CreateUninstallerRegistryEntry(),
"Failed to create uninstaller registry entry");
}
}