public static AppDeployInfo GetCurrentInfo() { var result = new AppDeployInfo(); if (ApplicationDeployment.IsNetworkDeployed) { var deployment = ApplicationDeployment.CurrentDeployment; var manifest = GetManifest(); try { var uri = deployment.UpdateLocation; result = GetRemoteInfo(uri); } catch (Exception e) { var activationUri = deployment.ActivationUri; result.ProductName = manifest.Product; result.PublisherName = manifest.Publisher; result.CurrentVersion = deployment.CurrentVersion; result.HasUpdateVersion = result.UpdateVersion > result.CurrentVersion; result.UpdatedApplicationFullName = deployment.UpdatedApplicationFullName; result.UpdateLocation = deployment.UpdateLocation; result.UpdateVersion = deployment.UpdatedVersion; result.Arguments = GetArgs(); result.DesktopShortcutPath = GetDesktopShortcutPath(manifest.Product); result.StartMenuShortcutPath = GetStartMenuShortcutPath(manifest.Publisher, manifest.Product); result.ActivationLocation = activationUri == null ? Application.ExecutablePath : activationUri.ToString(); } } else { var assembly = Assembly.GetEntryAssembly(); var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); result.ProductName = fileVersionInfo.ProductName; result.CurrentVersion = new Version(fileVersionInfo.ProductVersion); result.ActivationLocation = assembly.Location; } return(result); }
private static AppDeployInfo Migration(assembly source) { var desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var startMenuPath = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu); var result = new AppDeployInfo { ProductName = source.description.product, PublisherName = source.description.publisher }; result.DesktopShortcutPath = $"{desktopPath}\\{source.description.product}{s_extendName}"; result.StartMenuShortcutPath = $"{startMenuPath}\\Programs\\{result.PublisherName}\\{result.ProductName}{s_extendName}"; result.UpdateVersion = new Version(source.assemblyIdentity.version); result.Name = source.assemblyIdentity.name; result.Language = source.assemblyIdentity.language; if (ApplicationDeployment.IsNetworkDeployed) { var deployment = ApplicationDeployment.CurrentDeployment; var activationUri = deployment.ActivationUri; result.ActivationLocation = activationUri == null ? Application.ExecutablePath : activationUri.ToString(); result.CurrentVersion = deployment.CurrentVersion; result.HasUpdateVersion = result.UpdateVersion > result.CurrentVersion; result.UpdatedApplicationFullName = deployment.UpdatedApplicationFullName; result.UpdateLocation = deployment.UpdateLocation; result.Arguments = GetArgs(); } else { result.ActivationLocation = Application.ExecutablePath; result.CurrentVersion = new Version(Application.ProductVersion); result.HasUpdateVersion = false; result.UpdatedApplicationFullName = null; result.UpdateLocation = null; } return(result); }