Пример #1
0
        private static void ComposeStorePath(DotNetCliInfo info)
        {
            var    dir            = new DirectoryInfo(info.BasePath);
            var    tmpDir         = dir;
            string dotnetRootPath = null;

            while (tmpDir.Parent != null && tmpDir.Parent.FullName != tmpDir.FullName)
            {
                if (tmpDir.Name.Equals("dotnet", StringComparison.OrdinalIgnoreCase))
                {
                    dotnetRootPath = tmpDir.FullName;
                    break;
                }
                tmpDir = tmpDir.Parent;
            }

            var x64 = Path.Combine(dotnetRootPath, "store\\x64");
            var x86 = Path.Combine(dotnetRootPath, "store\\x64");

            if (Directory.Exists(x64))
            {
                info.Store = x64;
            }
            else if (Directory.Exists(x86))
            {
                info.Store = x86;
            }
        }
Пример #2
0
        private static DotNetCliInfo ParseInfo(List <string> output)
        {
            var info = new DotNetCliInfo();

            output = output.Where(s => !string.IsNullOrWhiteSpace(s)).ToList();

            foreach (var line in output)
            {
                ParseLine(line.Trim(), "OS Platform", value => { info.OSPlatform = value; });
                ParseLine(line.Trim(), "OS Name", value => { info.OSName = value; });
                ParseLine(line.Trim(), "RID", value => { info.RuntimeIdentifier = value; });
                ParseLine(line.Trim(), "Base Path", value => { info.BasePath = value; });
                ParseLine(line.Trim(), "Version", value => { info.Version = value; });
                ParseLine(line.Trim(), "Build", value => { info.Build = value; });
            }

            ComposeStorePath(info);


            return(info);
        }