Exemplo n.º 1
0
        private static void RunGenerateSDKProjects()
        {
            // Create a copy of the packages as they might change after we create the MSBuild project
            string generatedProjectPath = Path.Combine(Utilities.MSBuildOutputFolder, "Projects");

            try
            {
                Utilities.EnsureCleanDirectory(generatedProjectPath);
            }
            catch (IOException ex)
            {
                if (ex.Message.Contains(@"db.lock"))
                {
                    Debug.LogError("Generated project appears to be still open with Visual Studio.");
                    throw new InvalidDataException("Generated project appears to be still open with Visual Studio.", ex);
                }
                else
                {
                    throw;
                }
            }

            Utilities.EnsureCleanDirectory(Path.Combine(Utilities.MSBuildOutputFolder, "Output"));

            MakePackagesCopy(Utilities.MSBuildOutputFolder);

            List <CompilationPlatformInfo> platforms = CompilationPipeline.GetAssemblyDefinitionPlatforms()
                                                       .Where(t => supportedBuildTargets.Contains(t.BuildTarget))
                                                       .Select(CompilationPlatformInfo.GetCompilationPlatform)
                                                       .OrderBy(t => t.Name)
                                                       .ToList();

            CompilationPlatformInfo editorPlatform = CompilationPlatformInfo.GetEditorPlatform();

            CreateCommonPropsFile(platforms, editorPlatform, generatedProjectPath);
            UnityProjectInfo unityProjectInfo = new UnityProjectInfo(platforms, generatedProjectPath);

            // Read the solution template
            string solutionTemplateText = File.ReadAllText(TemplateFiles.Instance.MSBuildSolutionTemplatePath);

            // Read the project template
            string projectTemplateText = File.ReadAllText(TemplateFiles.Instance.SDKProjectFileTemplatePath);

            unityProjectInfo.ExportSolution(solutionTemplateText, projectTemplateText, generatedProjectPath);

            foreach (string otherFile in TemplateFiles.Instance.OtherFiles)
            {
                File.Copy(otherFile, Path.Combine(generatedProjectPath, Path.GetFileName(otherFile)));
            }

            string buildProjectsFile = "BuildProjects.proj";

            if (!File.Exists(Path.Combine(Utilities.MSBuildOutputFolder, buildProjectsFile)))
            {
                GenerateBuildProjectsFile(buildProjectsFile, unityProjectInfo.UnityProjectName, platforms);
            }
        }
Exemplo n.º 2
0
        public UnityProjectInfo(HashSet <BuildTarget> supportedBuildTargets)
        {
            AvailablePlatforms = new ReadOnlyCollection <CompilationPlatformInfo>(CompilationPipeline.GetAssemblyDefinitionPlatforms()
                                                                                  .Where(t => supportedBuildTargets.Contains(t.BuildTarget))
                                                                                  .Select(CompilationPlatformInfo.GetCompilationPlatform)
                                                                                  .OrderBy(t => t.Name).ToList());

            EditorPlatform = CompilationPlatformInfo.GetEditorPlatform();

            UnityProjectName = Application.productName;

            if (string.IsNullOrWhiteSpace(UnityProjectName))
            {
                UnityProjectName = "UnityProject";
            }

            RefreshPlugins();
            RefreshProjects();

            CurrentPlayerPlatform = AvailablePlatforms.First(t => t.BuildTarget == EditorUserBuildSettings.activeBuildTarget);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Parses the current state of the Unity project.
        /// </summary>
        /// <param name="supportedBuildTargets">BuildTargets that are considered supported.</param>
        /// <param name="config">Config for MSBuildTools.</param>
        /// <param name="performCompleteParse">If this is false, UnityProjectInfo will parse only the minimum required information about current project. Includes: <see cref="ExistingCSProjects"/> <see cref="CurrentPlayerPlatform"/>.</param>
        public UnityProjectInfo(ILogger logger, Dictionary <BuildTarget, string> supportedBuildTargets, MSBuildToolsConfig config, bool performCompleteParse = true)
        {
            this.logger = logger;
            this.config = config;

            if (performCompleteParse)
            {
                AvailablePlatforms = new ReadOnlyCollection <CompilationPlatformInfo>(CompilationPipeline.GetAssemblyDefinitionPlatforms()
                                                                                      .Where(t => Utilities.IsPlatformInstalled(t.BuildTarget))
                                                                                      .Where(t => supportedBuildTargets.ContainsKey(t.BuildTarget))
                                                                                      .Select(CompilationPlatformInfo.GetCompilationPlatform)
                                                                                      .OrderBy(t => t.Name).ToList());

                EditorPlatform = CompilationPlatformInfo.GetEditorPlatform();

                CurrentPlayerPlatform = AvailablePlatforms.First(t => t.BuildTarget == EditorUserBuildSettings.activeBuildTarget);
            }
            else
            {
                CurrentPlayerPlatform = CompilationPlatformInfo.GetCompilationPlatform(
                    CompilationPipeline.GetAssemblyDefinitionPlatforms()
                    .First(t => t.BuildTarget == EditorUserBuildSettings.activeBuildTarget));
            }

            UnityProjectName = Application.productName;

            if (string.IsNullOrWhiteSpace(UnityProjectName))
            {
                UnityProjectName = "UnityProject";
            }

            RefreshPlugins(performCompleteParse);

            if (performCompleteParse)
            {
                RefreshProjects();
            }
        }