Exemplo n.º 1
0
        private static void UpgradeProjectFile(string projectFile)
        {
            RiderPlugin.Log(string.Format("Post-processing {0}", projectFile));
            var        doc = XDocument.Load(projectFile);
            var        projectContentElement = doc.Root;
            XNamespace xmlns = projectContentElement.Name.NamespaceName; // do not use var

            FixTargetFrameworkVersion(projectContentElement, xmlns);
            SetLangVersion(projectContentElement, xmlns);

            SetXCodeDllReference("UnityEditor.iOS.Extensions.Xcode.dll", xmlns, projectContentElement);
            SetXCodeDllReference("UnityEditor.iOS.Extensions.Common.dll", xmlns, projectContentElement);

            doc.Save(projectFile);
        }
Exemplo n.º 2
0
        public static void OnGeneratedCSProjectFiles()
        {
            if (!RiderPlugin.Enabled)
            {
                return;
            }
            var currentDirectory = Directory.GetCurrentDirectory();
            var projectFiles     = Directory.GetFiles(currentDirectory, "*.csproj");

            foreach (var file in projectFiles)
            {
                UpgradeProjectFile(file);
            }

            var slnFile = Directory.GetFiles(currentDirectory, "*.sln").First();

            RiderPlugin.Log(string.Format("Post-processing {0}", slnFile));
            string content = File.ReadAllText(slnFile);
            var    lines   = content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            var    sb      = new StringBuilder();

            foreach (var line in lines)
            {
                if (line.StartsWith("Project("))
                {
                    MatchCollection mc = Regex.Matches(line, "\"([^\"]*)\"");
                    RiderPlugin.Log(mc[2].Value);
                    sb.Append(line.Replace(mc[1].Value, GetFileNameWithoutExtension(mc[2].Value) + "\""));
                }
                else
                {
                    sb.Append(line);
                }
                sb.Append(Environment.NewLine);
            }
            File.WriteAllText(slnFile, sb.ToString());
        }