mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
SetProcessAppUserModelId should not throw (#60)
This commit is contained in:
@@ -190,15 +190,27 @@ namespace Squirrel
|
||||
/// <inheritdoc/>
|
||||
public void SetProcessAppUserModelId()
|
||||
{
|
||||
var releases = Utility.LoadLocalReleases(Utility.LocalReleaseFileForAppDir(AppDirectory));
|
||||
var thisRelease = Utility.FindCurrentVersion(releases);
|
||||
|
||||
var zf = new ZipPackage(Path.Combine(
|
||||
Utility.PackageDirectoryForAppDir(AppDirectory),
|
||||
thisRelease.Filename));
|
||||
if (_applicationIdOverride == null && !IsInstalledApp) {
|
||||
// can't set model id if we don't know the package id.
|
||||
return;
|
||||
}
|
||||
|
||||
var exeName = Path.GetFileName(AssemblyRuntimeInfo.EntryExePath);
|
||||
var appUserModelId = Utility.GetAppUserModelId(zf.Id, exeName);
|
||||
|
||||
string appUserModelId;
|
||||
if (_applicationIdOverride != null) {
|
||||
appUserModelId = Utility.GetAppUserModelId(_applicationIdOverride, exeName);
|
||||
} else {
|
||||
var releases = Utility.LoadLocalReleases(Utility.LocalReleaseFileForAppDir(AppDirectory));
|
||||
var thisRelease = Utility.FindCurrentVersion(releases);
|
||||
|
||||
var zf = new ZipPackage(Path.Combine(
|
||||
Utility.PackageDirectoryForAppDir(AppDirectory),
|
||||
thisRelease.Filename));
|
||||
|
||||
appUserModelId = Utility.GetAppUserModelId(zf.Id, exeName);
|
||||
}
|
||||
|
||||
NativeMethods.SetCurrentProcessExplicitAppUserModelID(appUserModelId);
|
||||
}
|
||||
|
||||
|
||||
@@ -341,6 +341,16 @@ namespace Squirrel.Tests
|
||||
Assert.False(fixture.IsInstalledApp);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetModelIdDoesNotThrow()
|
||||
{
|
||||
using (var fixture = new UpdateManager(null))
|
||||
fixture.SetProcessAppUserModelId();
|
||||
|
||||
using (var fixture2 = new UpdateManager(null, "TestASD"))
|
||||
fixture2.SetProcessAppUserModelId();
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(0, 0, 25, 0)]
|
||||
[InlineData(12, 0, 25, 3)]
|
||||
|
||||
Reference in New Issue
Block a user