예제 #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

            if (!RiderPlugin.IsDotNetFrameworkUsed)
            {
                // helps resolve System.Linq under mono 4
                var xNodes = projectContentElement.Elements().ToList();
                var targetFrameworkVersion =
                    xNodes.Elements().FirstOrDefault(childNode => childNode.Name.LocalName == "TargetFrameworkVersion");
                targetFrameworkVersion.SetValue("v4.5");
            }

            if (Environment.Version.Major < 4 && !CSharp60Support())
            {
                // C# 6 is not supported
                var group = projectContentElement.Elements().FirstOrDefault(childNode => childNode.Name.LocalName == "PropertyGroup");
                var lang  = group.Elements("LangVersion").FirstOrDefault();
                if (lang != null)
                {
                    lang.SetValue("5");
                }
                else
                {
                    var newLang = new XElement(xmlns + "LangVersion");
                    newLang.SetValue("5");
                    group.Add(newLang);
                }
            }

            doc.Save(projectFile);
        }
        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

            if (!RiderPlugin.IsWindows)
            {
                // helps resolve System.Linq under mono 4
                var xNodes = projectContentElement.Elements().ToList();
                var targetFrameworkVersion =
                    xNodes.Elements().FirstOrDefault(childNode => childNode.Name.LocalName == "TargetFrameworkVersion");
                targetFrameworkVersion.SetValue("v4.5");
            }

            if (Environment.Version.Major < 4 && !CSharp60Support())
            {
                // C# 6 is not supported
                var newLang = new XElement(xmlns + "LangVersion");
                newLang.SetValue("5");
                var propGroup = new XElement(xmlns + "PropertyGroup");
                propGroup.Add(newLang);
                projectContentElement.AddFirst(propGroup);
            }

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

            doc.Save(projectFile);
        }