Exemplo n.º 1
0
 public static bool TryParse(string versionString, out SDKVersion version)
 {
     version = null;
     if (string.IsNullOrEmpty(versionString))
     {
         return(false);
     }
     string [] verNums = versionString.Split('.');
     if (verNums.Length != 3)
     {
         return(false);
     }
     if (!int.TryParse(verNums [0], out int maj))
     {
         return(false);
     }
     if (!int.TryParse(verNums [1], out int min))
     {
         return(false);
     }
     if (!int.TryParse(verNums [2], out int rev))
     {
         return(false);
     }
     version = new SDKVersion {
         major = maj, minor = min, revision = rev
     };
     return(true);
 }
Exemplo n.º 2
0
        static void configureDefaultSDKPathes()
        {
            sdkFolder = Configuration.Global.Get <string> ("SDKFolder");
            if (string.IsNullOrEmpty(sdkFolder))
            {
                switch (Environment.OSVersion.Platform)
                {
                case PlatformID.Win32S:
                case PlatformID.Win32Windows:
                case PlatformID.Win32NT:
                case PlatformID.WinCE:
                    throw new NotSupportedException();

                case PlatformID.Unix:
                    sdkFolder = "/usr/share/dotnet/sdk";
                    break;

                default:
                    throw new NotSupportedException();
                }
                Configuration.Global.Set("SDKFolder", sdkFolder);
            }
            msbuildFolder = Configuration.Global.Get <string> ("msbuildFolder");
            if (!string.IsNullOrEmpty(msbuildFolder) && Directory.Exists(msbuildFolder))
            {
                return;
            }
            List <SDKVersion> versions = new List <SDKVersion> ();

            foreach (string dir in Directory.EnumerateDirectories(sdkFolder))
            {
                string dirName = Path.GetFileName(dir);
                if (SDKVersion.TryParse(dirName, out SDKVersion vers))
                {
                    versions.Add(vers);
                }
            }
            versions.Sort((a, b) => a.ToInt.CompareTo(b.ToInt));
            msbuildFolder = versions.Last().ToString();
            Configuration.Global.Set("msbuildFolder", msbuildFolder);
        }