Пример #1
0
        public void ExportProjects(IUnityProjectExporter unityProjectExporter, DirectoryInfo generatedProjectFolder)
        {
            foreach (KeyValuePair <string, CSProjectInfo> project in CSProjects)
            {
                bool isGenerated = project.Value.AssemblyDefinitionInfo.AssetLocation != AssetLocation.Package && project.Value.AssemblyDefinitionInfo.AssetLocation != AssetLocation.Project;

                ICSharpProjectExporter exporter = unityProjectExporter.CreateCSharpProjectExporter(MSBuildUnityProjectExporter.GetProjectPath(project.Value, generatedProjectFolder), generatedProjectFolder, isGenerated);
                exporter.DefaultPlatform = CurrentPlayerPlatform.Name;
                exporter.LanguageVersion = MSBuildTools.CSharpVersion;
                exporter.IsGenerated     = isGenerated;
                foreach (CompilationPlatformInfo platform in AvailablePlatforms)
                {
                    exporter.SupportedPlatforms.Add(platform.Name);
                }

                project.Value.Export(exporter, generatedProjectFolder);
                exporter.Write();
            }
        }
Пример #2
0
        public void Export(ICSharpProjectExporter exporter, DirectoryInfo generatedProjectDirectory)
        {
            exporter.Guid                = Guid;
            exporter.AllowUnsafe         = AssemblyDefinitionInfo.allowUnsafeCode;
            exporter.IsEditorOnlyProject = ProjectType == ProjectType.EditorAsmDef || ProjectType == ProjectType.PredefinedEditorAssembly;
            exporter.ProjectName         = Name;
            exporter.SourceIncludePath   = AssemblyDefinitionInfo.Directory;

            foreach (AssemblyDefinitionInfo nestedAsmDef in AssemblyDefinitionInfo.NestedAssemblyDefinitionFiles)
            {
                exporter.SourceExcludePaths.Add(nestedAsmDef.Directory);
            }

            // Set all of the references
            ProcessDepedencies(exporter.PluginReferences, PluginDependencies, exporter.AssemblySearchPaths, (i, c) => new PluginReference(i.Name, i.ReferencePath, c), i => i.ReferencePath.LocalPath);
            ProcessDepedencies(exporter.PluginReferences, WinMDDependencies, exporter.AssemblySearchPaths, (i, c) => new PluginReference(i.Name, i.ReferencePath, c), i => i.ReferencePath.LocalPath);
            ProcessDepedencies(exporter.ProjectReferences, ProjectDependencies, exporter.AssemblySearchPaths, (i, c) => new ProjectReference(new Uri(MSBuildUnityProjectExporter.GetProjectPath(i, generatedProjectDirectory).FullName), c, true));

            AddSupportedBuildPlatformPair(exporter, UnityConfigurationType.InEditor, InEditorPlatforms);
            AddSupportedBuildPlatformPair(exporter, UnityConfigurationType.Player, PlayerPlatforms);
        }
Пример #3
0
        public void ExportSolution(IUnityProjectExporter unityProjectExporter, FileInfo solutionFilePath, DirectoryInfo generatedProjectsFolder)
        {
            SolutionFileInfo  solutionFileInfo = TextSolutionFileParser.ParseExistingSolutionFile(logger, solutionFilePath.FullName);
            ISolutionExporter exporter         = unityProjectExporter.CreateSolutionExporter(logger, solutionFilePath);

            //TODO we need to figure out how to handle existing projects

            // Remove known folders
            solutionFileInfo.Projects.Remove(config.BuiltInPackagesFolderGuid);
            solutionFileInfo.Projects.Remove(config.ImportedPackagesFolderGuid);
            solutionFileInfo.Projects.Remove(config.ExternalPackagesFolderGuid);

            // Process generated projects
            foreach (KeyValuePair <string, CSProjectInfo> projectPair in CSProjects)
            {
                Uri relativePath = Utilities.GetRelativeUri(solutionFilePath.Directory.FullName, MSBuildUnityProjectExporter.GetProjectPath(projectPair.Value, generatedProjectsFolder).FullName);
                exporter.AddProject(CreateSolutionProjectEntry(projectPair.Value, relativePath, solutionFileInfo), isGenerated: true);
            }

            // Add dependency project
            string dependencyProjectName = $"{UnityProjectName}.Dependencies.msb4u";

            exporter.AddProject(GetDependencyProjectReference(dependencyProjectName, $"{dependencyProjectName}.csproj"), isGenerated: true);

            // Process existing projects
            foreach (KeyValuePair <Guid, Project> projectPair in solutionFileInfo.Projects)
            {
                if (!exporter.Projects.ContainsKey(projectPair.Key) &&
                    !solutionFileInfo.MSB4UGeneratedItems.Contains(projectPair.Key) &&
                    projectPair.Value.TypeGuid != SolutionProject.FolderTypeGuid)
                {
                    exporter.AddProject(GetSolutionProjectEntryFrom(projectPair.Value, solutionFileInfo));
                }
            }

            // Bring forward the properties, then set the one we care about
            exporter.Properties.AddRange(solutionFileInfo.Properties);
            exporter.Properties["HideSolutionNode"] = "FALSE";

            // Bring forward the extensibility globals, then set the one we care about
            exporter.ExtensibilityGlobals.AddRange(solutionFileInfo.ExtensibilityGlobals);
            exporter.ExtensibilityGlobals["SolutionGuid"] = "{" + config.SolutionGuid.ToString().ToUpper() + "}";

            // Bring forward the pairs, and then set the platforms we know of
            exporter.ConfigurationPlatforms.AddRange(solutionFileInfo.ConfigPlatformPairs);
            foreach (CompilationPlatformInfo platform in AvailablePlatforms)
            {
                exporter.ConfigurationPlatforms.Add(new ConfigurationPlatformPair(UnityConfigurationType.InEditor, platform.Name));
                exporter.ConfigurationPlatforms.Add(new ConfigurationPlatformPair(UnityConfigurationType.Player, platform.Name));
            }

            // Set the folders by scanning for "projects" with folder type in old projects
            foreach (KeyValuePair <Guid, Project> folderPair in solutionFileInfo.Projects.Where(t => t.Value.TypeGuid == SolutionProject.FolderTypeGuid))
            {
                exporter.GetOrAddFolder(folderPair.Key, folderPair.Value.Name)
                .Children.AddRange(solutionFileInfo.ChildToParentNestedMappings.Where(t => t.Value == folderPair.Key).Select(t => t.Key));
            }

            Dictionary <AssetLocation, Tuple <Guid, string> > knownFolderMapping = GetKnownFolderMapping();

            // Confiure known folders for generated projects
            ProcessSetForKnownFolders(exporter, knownFolderMapping, CSProjects.Values, t => t.AssemblyDefinitionInfo.AssetLocation, t => t.Guid);

            //TODO handle existing projects

            exporter.AdditionalSections = solutionFileInfo.SolutionSections;

            exporter.Write();
        }