本文整理汇总了C#中Squirrel.UpdateManager.CreateUninstallerRegistryEntry方法的典型用法代码示例。如果您正苦于以下问题:C# UpdateManager.CreateUninstallerRegistryEntry方法的具体用法?C# UpdateManager.CreateUninstallerRegistryEntry怎么用?C# UpdateManager.CreateUninstallerRegistryEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Squirrel.UpdateManager
的用法示例。
在下文中一共展示了UpdateManager.CreateUninstallerRegistryEntry方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallingMethodTwiceShouldUpdateInstaller
public async Task CallingMethodTwiceShouldUpdateInstaller()
{
string remotePkgPath;
string path;
using (Utility.WithTempDirectory(out path)) {
using (Utility.WithTempDirectory(out remotePkgPath))
using (var mgr = new UpdateManager(remotePkgPath, "theApp", path)) {
IntegrationTestHelper.CreateFakeInstalledApp("1.0.0.1", remotePkgPath);
await mgr.FullInstall();
}
using (var mgr = new UpdateManager("http://lol", "theApp", path)) {
await mgr.CreateUninstallerRegistryEntry();
var regKey = await mgr.CreateUninstallerRegistryEntry();
Assert.False(String.IsNullOrWhiteSpace((string)regKey.GetValue("DisplayName")));
mgr.RemoveUninstallerRegistryEntry();
}
// NB: Squirrel-Aware first-run might still be running, slow
// our roll before blowing away the temp path
Thread.Sleep(1000);
}
var key = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Default)
.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
using (key) {
Assert.False(key.GetSubKeyNames().Contains("theApp"));
}
}
示例2: OnAppUpdate
/// <summary>
/// Execute when app is updating
/// </summary>
/// <param name="version"><see cref="Version"/> version</param>
private static void OnAppUpdate(Version version)
{
using (var manager = new UpdateManager(Constants.UpdateServerUrl))
{
manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.Desktop, true);
manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.StartMenu, true);
manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.AppRoot, true);
manager.RemoveUninstallerRegistryEntry();
manager.CreateUninstallerRegistryEntry();
}
}
示例3: Update
public async Task Update(string updateUrl, string appName = null)
{
appName = appName ?? getAppNameFromDirectory();
this.Log().Info("Starting update, downloading from " + updateUrl);
using (var mgr = new UpdateManager(updateUrl, appName)) {
bool ignoreDeltaUpdates = false;
this.Log().Info("About to update to: " + mgr.RootAppDirectory);
retry:
try {
var updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: ignoreDeltaUpdates, progress: x => Console.WriteLine(x / 3));
await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));
await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3));
} catch (Exception ex) {
if (ignoreDeltaUpdates) {
this.Log().ErrorException("Really couldn't apply updates!", ex);
throw;
}
this.Log().WarnException("Failed to apply updates, falling back to full updates", ex);
ignoreDeltaUpdates = true;
goto retry;
}
var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe");
await this.ErrorIfThrows(() =>
mgr.CreateUninstallerRegistryEntry(),
"Failed to create uninstaller registry entry");
}
}
示例4: 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);
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");
}
}
示例5: Install
public async Task Install(bool silentInstall, 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, FrameworkVersion.Net45)) {
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);
await this.ErrorIfThrows(() =>
mgr.CreateUninstallerRegistryEntry(),
"Failed to create uninstaller registry entry");
}
}
示例6: SquirrelUpdate
private static async Task<bool> SquirrelUpdate(SplashScreenWindow splashScreenWindow, UpdateManager mgr, bool ignoreDelta = false)
{
try
{
Log.Info($"Checking for updates (ignoreDelta={ignoreDelta})");
splashScreenWindow.StartSkipTimer();
var updateInfo = await mgr.CheckForUpdate(ignoreDelta);
if(!updateInfo.ReleasesToApply.Any())
{
Log.Info("No new updated available");
return false;
}
var latest = updateInfo.ReleasesToApply.LastOrDefault()?.Version;
var current = mgr.CurrentlyInstalledVersion();
if(latest <= current)
{
Log.Info($"Installed version ({current}) is greater than latest release found ({latest}). Not downloading updates.");
return false;
}
if(IsRevisionIncrement(current?.Version, latest?.Version))
{
Log.Info($"Latest update ({latest}) is revision increment. Updating in background.");
splashScreenWindow.SkipUpdate = true;
}
Log.Info($"Downloading {updateInfo.ReleasesToApply.Count} {(ignoreDelta ? "" : "delta ")}releases, latest={latest?.Version}");
await mgr.DownloadReleases(updateInfo.ReleasesToApply, splashScreenWindow.Updating);
Log.Info("Applying releases");
await mgr.ApplyReleases(updateInfo, splashScreenWindow.Installing);
await mgr.CreateUninstallerRegistryEntry();
Log.Info("Done");
return true;
}
catch(Exception ex)
{
if(ignoreDelta)
return false;
if(ex is Win32Exception)
Log.Info("Not able to apply deltas, downloading full release");
return await SquirrelUpdate(splashScreenWindow, mgr, true);
}
}
示例7: Update
public async Task Update(string updateUrl, string appName = null)
{
appName = appName ?? getAppNameFromDirectory();
this.Log().Info("Starting update, downloading from " + updateUrl);
// NB: Always basing the rootAppDirectory relative to ours allows us to create Portable
// Applications
var ourDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "..");
using (var mgr = new UpdateManager(updateUrl, appName, FrameworkVersion.Net45, ourDir)) {
bool ignoreDeltaUpdates = false;
retry:
try {
var updateInfo = await mgr.CheckForUpdate(ignoreDeltaUpdates: ignoreDeltaUpdates, progress: x => Console.WriteLine(x / 3));
await mgr.DownloadReleases(updateInfo.ReleasesToApply, x => Console.WriteLine(33 + x / 3));
await mgr.ApplyReleases(updateInfo, x => Console.WriteLine(66 + x / 3));
} catch (Exception ex) {
if (ignoreDeltaUpdates) {
this.Log().ErrorException("Really couldn't apply updates!", ex);
throw;
}
this.Log().WarnException("Failed to apply updates, falling back to full updates", ex);
ignoreDeltaUpdates = true;
goto retry;
}
var updateTarget = Path.Combine(mgr.RootAppDirectory, "Update.exe");
await this.ErrorIfThrows(() =>
mgr.CreateUninstallerRegistryEntry(),
"Failed to create uninstaller registry entry");
}
}
示例8: OnInitialInstall
/// <summary>
/// Execute when app is installing
/// </summary>
/// <param name="version"><see cref="Version"/> version</param>
private static void OnInitialInstall(Version version)
{
using (var manager = new UpdateManager(Constants.UpdateServerUrl))
{
manager.CreateShortcutForThisExe();
manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.Desktop, false);
manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.StartMenu, false);
manager.CreateShortcutsForExecutable("Popcorn.exe", ShortcutLocation.AppRoot, false);
manager.CreateUninstallerRegistryEntry();
}
}
示例9: InstallEvent
public static void InstallEvent()
{
var exePath = Assembly.GetEntryAssembly().Location;
var appName = Path.GetFileName(exePath);
using (var mgr = new UpdateManager(@"https://releases.noelpush.com/", "NoelPush"))
{
mgr.CreateShortcutsForExecutable(appName, ShortcutLocation.StartMenu | ShortcutLocation.Startup, false);
mgr.CreateUninstallerRegistryEntry();
mgr.Dispose();
}
}