// Static Constructor. static PSVersionInfo() { s_psVersionTable = new PSVersionHashTable(StringComparer.OrdinalIgnoreCase); Assembly currentAssembly = typeof(PSVersionInfo).Assembly; ProductVersion = currentAssembly.GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion; // Get 'GitCommitId' and 'PSVersion' from the 'productVersion' assembly attribute. // // The strings can be one of the following format examples: // when powershell is built from a commit: // productVersion = '6.0.0-beta.7 Commits: 29 SHA: 52c6b...' convert to GitCommitId = 'v6.0.0-beta.7-29-g52c6b...' // PSVersion = '6.0.0-beta.7' // when powershell is built from a release tag: // productVersion = '6.0.0-beta.7 SHA: f1ec9...' convert to GitCommitId = 'v6.0.0-beta.7' // PSVersion = '6.0.0-beta.7' // when powershell is built from a release tag for RTM: // productVersion = '6.0.0 SHA: f1ec9...' convert to GitCommitId = 'v6.0.0' // PSVersion = '6.0.0' string rawGitCommitId; string mainVersion = ProductVersion.Substring(0, ProductVersion.IndexOf(' ')); if (ProductVersion.Contains(" Commits: ")) { rawGitCommitId = ProductVersion.Replace(" Commits: ", "-").Replace(" SHA: ", "-g"); } else { rawGitCommitId = mainVersion; } s_psSemVersion = new SemanticVersion(mainVersion); s_psVersion = (Version)s_psSemVersion; s_psVersionTable[PSVersionInfo.PSVersionName] = s_psSemVersion; s_psVersionTable[PSVersionInfo.PSEditionName] = PSEditionValue; s_psVersionTable[PSGitCommitIdName] = rawGitCommitId; s_psVersionTable[PSCompatibleVersionsName] = new Version[] { s_psV1Version, s_psV2Version, s_psV3Version, s_psV4Version, s_psV5Version, s_psV51Version, s_psV6Version, s_psV61Version, s_psV62Version, s_psV7Version, s_psV71Version, s_psVersion }; s_psVersionTable[PSVersionInfo.SerializationVersionName] = new Version(InternalSerializer.DefaultVersion); s_psVersionTable[PSVersionInfo.PSRemotingProtocolVersionName] = RemotingConstants.ProtocolVersion; s_psVersionTable[PSVersionInfo.WSManStackVersionName] = GetWSManStackVersion(); s_psVersionTable[PSPlatformName] = Environment.OSVersion.Platform.ToString(); s_psVersionTable[PSOSName] = Runtime.InteropServices.RuntimeInformation.OSDescription; }
private void Build() { if (SetupFilename == null) { //SetupFilename = Path.Combine(TempDir, "SharpKitSetup_" + ProductVersion.Replace('.', '_') + ".exe"); SetupFilename = Path.Combine(GitRoot, "contrib", "SharpKitSetup_" + ProductVersion.Replace('.', '_') + ".exe"); } var builder = new SetupBuilder { TempBinDir = TempBinDir, SourceFilesDir = TempZipDir, ProductVersion = ProductVersion, InstallerProjectDir = InstallerProjectDir, OutputFilename = SetupFilename, GitRoot = GitRoot }; builder.build(); }
public void DoCheckForUpdates() { if (WebInstallUrl.IsNullOrEmpty()) { return; } Log("Checking for new version"); if (!WebInstallUrl.EndsWith("/")) { WebInstallUrl += "/"; } try { using (var wc = new System.Net.WebClient()) { var config = wc.DownloadString(WebInstallUrl + "Config.xml"); var hash = XmlToHash(config); int onlineVersion = GetVersionInteger(hash["ProductVersion"]); int localVersion = GetVersionInteger(ProductVersion); if (onlineVersion > localVersion) { int InstallerOnlineVersion = GetVersionInteger(hash["InstallerNeedsMinVersion"]); int InstallerLocalVersion = GetVersionInteger(InstallerNeedsMinVersion); SetConfig(hash); Log("Found new version " + ProductVersion); Log("Downloading installation files"); if (InstallerOnlineVersion > InstallerLocalVersion) { var fileName = "SharpKitSetup_" + ProductVersion.Replace("v", "").Replace(".", "_") + ".exe"; var tempFile = Path.GetTempPath() + fileName; Utils.UIDeleteFile(tempFile); wc.DownloadFile(WebInstallUrl + fileName, tempFile); Log("Starting new setup file"); if (Utils.IsUnix) { Process.Start("mono", tempFile); } else { Process.Start(tempFile); } System.Diagnostics.Process.GetCurrentProcess().Kill(); } else { var data = wc.DownloadData(WebInstallUrl + "Files.zip"); Log("Downloading finisehd"); WebMemorystram = new MemoryStream(data); //at the moment, sharpkit install files are not very large. When becomes > 100MB, it should be saved to disk. } } else if (onlineVersion == localVersion) { Log("No new version available."); } else { Log("Local version are newer than online version."); } } } catch (Exception ex) { Log("Error while checking for updates. Continue installing offline files. " + ex); } }