|
20 | 20 | using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; |
21 | 21 | using System; |
22 | 22 | using System.Collections.Concurrent; |
23 | | -using System.Collections.ObjectModel; |
24 | 23 | using System.Diagnostics; |
25 | 24 | using System.IO; |
26 | 25 | using System.Linq; |
27 | 26 | using System.Management.Automation; |
28 | | -using System.Management.Automation.Runspaces; |
29 | 27 | using System.Text; |
30 | 28 |
|
31 | 29 | namespace Microsoft.WindowsAzure.Commands.Utilities.Common |
@@ -870,40 +868,7 @@ public virtual bool IsTerminatingError(Exception ex) |
870 | 868 |
|
871 | 869 | protected string LoadAzVersion() |
872 | 870 | { |
873 | | - Version latestAz = new Version("0.0.0"); |
874 | | - string latestSuffix = ""; |
875 | | - using (var powershell = System.Management.Automation.PowerShell.Create()) |
876 | | - { |
877 | | - powershell.Runspace = RunspaceFactory.CreateRunspace(this.Host); |
878 | | - powershell.AddCommand("Get-Module"); |
879 | | - powershell.AddParameter("Name", "Az"); |
880 | | - powershell.AddParameter("ListAvailable", true); |
881 | | - powershell.Runspace.Open(); |
882 | | - Collection<PSObject> outputs = powershell.Invoke(); |
883 | | - foreach (PSObject obj in outputs) |
884 | | - { |
885 | | - string psVersion = obj.Properties["Version"].Value.ToString(); |
886 | | - int pos = psVersion.IndexOf('-'); |
887 | | - string currentSuffix = (pos == -1 || pos == psVersion.Length - 1) ? "" : psVersion.Substring(pos + 1); |
888 | | - Version currentAz = (pos == -1) ? new Version(psVersion) : new Version(psVersion.Substring(0, pos)); |
889 | | - if (currentAz > latestAz) |
890 | | - { |
891 | | - latestAz = currentAz; |
892 | | - latestSuffix = currentSuffix; |
893 | | - } |
894 | | - else if (currentAz == latestAz) |
895 | | - { |
896 | | - latestSuffix = String.Compare(latestSuffix, currentSuffix) > 0 ? latestSuffix : currentSuffix; |
897 | | - } |
898 | | - } |
899 | | - } |
900 | | - string ret = latestAz.ToString(); |
901 | | - if (!String.IsNullOrEmpty(latestSuffix)) |
902 | | - { |
903 | | - ret += "-" + latestSuffix; |
904 | | - } |
905 | | - WriteDebug(string.Format("Sought all Az modules and got latest version {0}", ret)); |
906 | | - return ret; |
| 871 | + return "1.0.0"; |
907 | 872 | } |
908 | 873 | } |
909 | 874 | } |
0 commit comments