public string ProjectFile(MonoIsland island, bool forVisualStudio)
        {
            ScriptingLanguage key = SolutionSynchronizer.SupportedExtensions[island.GetExtensionOfSourceFiles()];
            string            arg = (!forVisualStudio) ? string.Empty : this.vsstub;

            return(Path.Combine(this._projectDirectory, string.Format("{0}{1}{2}", Path.GetFileNameWithoutExtension(island._output), arg, SolutionSynchronizer.ProjectExtensions[key])));
        }
        protected void RunAPIUpdaterIfRequired(string responseFile)
        {
            if (!_runAPIUpdater)
            {
                return;
            }

            APIUpdaterHelper.UpdateScripts(responseFile, _island.GetExtensionOfSourceFiles());
        }
Пример #3
0
        protected void RunAPIUpdaterIfRequired(string responseFile, IList <string> pathMappings)
        {
            if (!_runAPIUpdater)
            {
                return;
            }

            var pathMappingsFilePath = Path.GetTempFileName();

            File.WriteAllLines(pathMappingsFilePath, pathMappings.ToArray());

            APIUpdaterHelper.UpdateScripts(responseFile, _island.GetExtensionOfSourceFiles(), PrepareFileName(pathMappingsFilePath));
        }
        private string ProjectHeader(MonoIsland island)
        {
            string            text     = "4.0";
            string            text2    = "10.0.20506";
            ScriptingLanguage language = SolutionSynchronizer.SupportedExtensions[island.GetExtensionOfSourceFiles()];

            if (this._settings.VisualStudioVersion == 9)
            {
                text  = "3.5";
                text2 = "9.0.21022";
            }
            return(string.Format(this._settings.GetProjectHeaderTemplate(language), new object[]
            {
                text,
                text2,
                this.ProjectGuid(island._output),
                this._settings.EngineAssemblyPath,
                this._settings.EditorAssemblyPath,
                string.Join(";", this._settings.Defines.Union(island._defines).ToArray <string>()),
                SolutionSynchronizer.MSBuildNamespaceUri,
                Path.GetFileNameWithoutExtension(island._output)
            }));
        }
Пример #5
0
 string SolutionGuid(MonoIsland island)
 {
     return(SolutionGuidGenerator.GuidForSolution(_projectName, island.GetExtensionOfSourceFiles()));
 }
Пример #6
0
        string ProjectText(MonoIsland island,
                           Mode mode,
                           Dictionary <string, string> allAssetsProjectParts,
                           IEnumerable <ResponseFileData> responseFilesData,
                           List <MonoIsland> allProjectIslands)
        {
            var   projectBuilder    = new StringBuilder(ProjectHeader(island, responseFilesData));
            var   references        = new List <string>();
            var   projectReferences = new List <Match>();
            Match match;
            bool  isBuildingEditorProject = island._editor;

            foreach (string file in island._files)
            {
                if (!ShouldFileBePartOfSolution(file))
                {
                    continue;
                }

                var extension = Path.GetExtension(file).ToLower();
                var fullFile  = EscapedRelativePathFor(file);
                if (".dll" != extension)
                {
                    var tagName = "Compile";
                    projectBuilder.Append("     <").Append(tagName).Append(" Include=\"").Append(fullFile).Append("\" />").Append(WindowsNewline);
                }
                else
                {
                    references.Add(fullFile);
                }
            }

            string additionalAssetsForProject;
            var    assemblyName = Utility.FileNameWithoutExtension(island._output);

            // Append additional non-script files that should be included in project generation.
            if (allAssetsProjectParts.TryGetValue(assemblyName, out additionalAssetsForProject))
            {
                projectBuilder.Append(additionalAssetsForProject);
            }

            var allAdditionalReferenceFilenames = new List <string>();
            var islandRefs = references.Union(island._references);

            foreach (string reference in islandRefs)
            {
                if (reference.EndsWith("/UnityEditor.dll", StringComparison.Ordinal) ||
                    reference.EndsWith("/UnityEngine.dll", StringComparison.Ordinal) ||
                    reference.EndsWith("\\UnityEditor.dll", StringComparison.Ordinal) ||
                    reference.EndsWith("\\UnityEngine.dll", StringComparison.Ordinal))
                {
                    continue;
                }

                match = scriptReferenceExpression.Match(reference);
                if (match.Success)
                {
                    var language       = ScriptCompilers.GetLanguageFromExtension(island.GetExtensionOfSourceFiles());
                    var targetLanguage = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), language.GetLanguageName(), true);
                    if (mode == Mode.UnityScriptAsUnityProj || ScriptingLanguage.CSharp == targetLanguage)
                    {
                        // Add a reference to a project except if it's a reference to a script assembly
                        // that we are not generating a project for. This will be the case for assemblies
                        // coming from .assembly.json files in non-internalized packages.
                        var dllName = match.Groups["dllname"].Value;
                        if (allProjectIslands.Any(i => Path.GetFileName(i._output) == dllName))
                        {
                            projectReferences.Add(match);
                            continue;
                        }
                    }
                }

                string fullReference = Path.IsPathRooted(reference) ? reference : Path.Combine(_projectDirectory, reference);
                if (!AssemblyHelper.IsManagedAssembly(fullReference))
                {
                    continue;
                }
                if (AssemblyHelper.IsInternalAssembly(fullReference))
                {
                    if (!IsAdditionalInternalAssemblyReference(isBuildingEditorProject, fullReference))
                    {
                        continue;
                    }
                    var referenceName = Path.GetFileName(fullReference);
                    if (allAdditionalReferenceFilenames.Contains(referenceName))
                    {
                        continue;
                    }
                    allAdditionalReferenceFilenames.Add(referenceName);
                }

                AppendReference(fullReference, projectBuilder);
            }

            var responseRefs = responseFilesData.SelectMany(x => x.FullPathReferences);

            foreach (var reference in responseRefs)
            {
                AppendReference(reference, projectBuilder);
            }

            if (0 < projectReferences.Count)
            {
                string referencedProject;
                projectBuilder.AppendLine("  </ItemGroup>");
                projectBuilder.AppendLine("  <ItemGroup>");
                foreach (Match reference in projectReferences)
                {
                    var targetAssembly = EditorCompilationInterface.Instance.GetTargetAssemblyDetails(reference.Groups["dllname"].Value);
                    ScriptingLanguage targetLanguage = ScriptingLanguage.None;
                    if (targetAssembly != null)
                    {
                        targetLanguage = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), targetAssembly.Language.GetLanguageName(), true);
                    }
                    referencedProject = reference.Groups["project"].Value;
                    projectBuilder.Append("    <ProjectReference Include=\"").Append(referencedProject).Append(GetProjectExtension(targetLanguage)).Append("\">").Append(WindowsNewline);
                    projectBuilder.Append("      <Project>{").Append(ProjectGuid(Path.Combine("Temp", reference.Groups["project"].Value + ".dll"))).Append("}</Project>").Append(WindowsNewline);
                    projectBuilder.Append("      <Name>").Append(referencedProject).Append("</Name>").Append(WindowsNewline);
                    projectBuilder.AppendLine("    </ProjectReference>");
                }
            }

            projectBuilder.Append(ProjectFooter(island));
            return(projectBuilder.ToString());
        }
Пример #7
0
 private static ScriptingLanguage ScriptingLanguageFor(MonoIsland island)
 {
     return(ScriptingLanguageFor(island.GetExtensionOfSourceFiles()));
 }
        private string ProjectFooter(MonoIsland island)
        {
            ScriptingLanguage language = SolutionSynchronizer.SupportedExtensions[island.GetExtensionOfSourceFiles()];

            return(string.Format(this._settings.GetProjectFooterTemplate(language), this.ReadExistingMonoDevelopProjectProperties(island)));
        }
Пример #9
0
        private string ProjectText(MonoIsland island, SolutionSynchronizer.Mode mode, Dictionary <string, string> allAssetsProjectParts, string[] additionalDefines, List <MonoIsland> allProjectIslands)
        {
            StringBuilder stringBuilder           = new StringBuilder(this.ProjectHeader(island, additionalDefines));
            List <string> list                    = new List <string>();
            List <Match>  list2                   = new List <Match>();
            bool          isBuildingEditorProject = island._output.EndsWith("-Editor.dll");

            string[] files = island._files;
            for (int j = 0; j < files.Length; j++)
            {
                string text = files[j];
                if (this.ShouldFileBePartOfSolution(text))
                {
                    string b     = Path.GetExtension(text).ToLower();
                    string text2 = (!Path.IsPathRooted(text)) ? Path.Combine(this._projectDirectory, text) : text;
                    if (".dll" != b)
                    {
                        string arg = "Compile";
                        stringBuilder.AppendFormat("     <{0} Include=\"{1}\" />{2}", arg, this.EscapedRelativePathFor(text2), SolutionSynchronizer.WindowsNewline);
                    }
                    else
                    {
                        list.Add(text2);
                    }
                }
            }
            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(island._output);
            string value;

            if (allAssetsProjectParts.TryGetValue(fileNameWithoutExtension, out value))
            {
                stringBuilder.Append(value);
            }
            List <string> list3 = new List <string>();

            foreach (string current in list.Union(island._references))
            {
                if (!current.EndsWith("/UnityEditor.dll") && !current.EndsWith("/UnityEngine.dll") && !current.EndsWith("\\UnityEditor.dll") && !current.EndsWith("\\UnityEngine.dll"))
                {
                    Match match = SolutionSynchronizer.scriptReferenceExpression.Match(current);
                    if (match.Success)
                    {
                        SupportedLanguage languageFromExtension = ScriptCompilers.GetLanguageFromExtension(island.GetExtensionOfSourceFiles());
                        ScriptingLanguage scriptingLanguage     = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), languageFromExtension.GetLanguageName(), true);
                        if (mode == SolutionSynchronizer.Mode.UnityScriptAsUnityProj || scriptingLanguage == ScriptingLanguage.CSharp)
                        {
                            string dllName = match.Groups["dllname"].Value;
                            if (allProjectIslands.Any((MonoIsland i) => Path.GetFileName(i._output) == dllName))
                            {
                                list2.Add(match);
                                continue;
                            }
                        }
                    }
                    string text3 = (!Path.IsPathRooted(current)) ? Path.Combine(this._projectDirectory, current) : current;
                    if (AssemblyHelper.IsManagedAssembly(text3))
                    {
                        if (AssemblyHelper.IsInternalAssembly(text3))
                        {
                            if (!SolutionSynchronizer.IsAdditionalInternalAssemblyReference(isBuildingEditorProject, text3))
                            {
                                continue;
                            }
                            string fileName = Path.GetFileName(text3);
                            if (list3.Contains(fileName))
                            {
                                continue;
                            }
                            list3.Add(fileName);
                        }
                        text3 = text3.Replace("\\", "/");
                        text3 = text3.Replace("\\\\", "/");
                        stringBuilder.AppendFormat(" <Reference Include=\"{0}\">{1}", Path.GetFileNameWithoutExtension(text3), SolutionSynchronizer.WindowsNewline);
                        stringBuilder.AppendFormat(" <HintPath>{0}</HintPath>{1}", text3, SolutionSynchronizer.WindowsNewline);
                        stringBuilder.AppendFormat(" </Reference>{0}", SolutionSynchronizer.WindowsNewline);
                    }
                }
            }
            if (0 < list2.Count)
            {
                stringBuilder.AppendLine("  </ItemGroup>");
                stringBuilder.AppendLine("  <ItemGroup>");
                foreach (Match current2 in list2)
                {
                    EditorBuildRules.TargetAssembly targetAssemblyDetails = EditorCompilationInterface.Instance.GetTargetAssemblyDetails(current2.Groups["dllname"].Value);
                    ScriptingLanguage language = ScriptingLanguage.None;
                    if (targetAssemblyDetails != null)
                    {
                        language = (ScriptingLanguage)Enum.Parse(typeof(ScriptingLanguage), targetAssemblyDetails.Language.GetLanguageName(), true);
                    }
                    string value2 = current2.Groups["project"].Value;
                    stringBuilder.AppendFormat("    <ProjectReference Include=\"{0}{1}\">{2}", value2, SolutionSynchronizer.GetProjectExtension(language), SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendFormat("      <Project>{{{0}}}</Project>", this.ProjectGuid(Path.Combine("Temp", current2.Groups["project"].Value + ".dll")), SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendFormat("      <Name>{0}</Name>", value2, SolutionSynchronizer.WindowsNewline);
                    stringBuilder.AppendLine("    </ProjectReference>");
                }
            }
            stringBuilder.Append(this.ProjectFooter(island));
            return(stringBuilder.ToString());
        }