예제 #1
0
        /// <summary>
        /// Applies changes found in Config.PropertyDataToAdd to solution
        /// </summary>
        /// <param name="solution">Solution to apply changes to</param>
        /// <param name="projectConfigs">List of configs for each project. Used for applying properties to all configs</param>
        private void ApplyChangesToProjects(Solution2 solution, Dictionary <string, List <string> > projectConfigs)
        {
            // Apply config changes to solution
            foreach (PropertyData property in Config.Instance.PropertyDataToAdd)
            {
                List <string> configsToApply = new List <string>();

                // Config type of '*' means we should apply this change to all configs
                if (property.Config == "*")
                {
                    configsToApply.AddRange(projectConfigs[property.SolutionName.ToLower()]);
                }
                else
                {
                    configsToApply.Add(property.Config);
                }

                foreach (string configName in configsToApply)
                {
                    OutputLine(property.ToString());
                    if (property.IsPrependingData)
                    {
                        ProjectTools.AddToProperty(solution, property.SolutionName, configName, property.Rule, property.Property, property.DataToAdd);
                    }
                    else
                    {
                        ProjectTools.SetProperty(solution, property.SolutionName, configName, property.Rule, property.Property, property.DataToAdd);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Loads and edits the specified Visual Studio solution with values from Config. This function
        /// will load visual studio and interact with it through Visual Studio's automation interface.
        /// If it fails then it's likely that the user will be left with a copy of DevEnv.exe running
        /// in the background.
        /// </summary>
        /// <param name="studentSolutionPath">Path to student version of the sln</param>
        /// <param name="solution">solution</param>
        private void ProcessSolution(string studentSolutionPath, Solution2 solution)
        {
            List <Project> projectsToRemove = new List <Project>();

            // Map of config types for each project.
            // EG: "EDMemoryManager" -> {"Release|x86","Debug|x86","Release|x64","Debug|x64"}
            Dictionary <string, List <string> > projectConfigs = new Dictionary <string, List <string> >();

            OutputLine("Opening solution '" + studentSolutionPath + Config.Instance.StudentEngineName + "'...");
            solution.Open(studentSolutionPath + Config.Instance.StudentEngineName);

            try
            {
                TraverseSolution(solution, new Action <Project>(currentProject =>
                {
                    string currentProjectName = currentProject.Name.ToLower().Trim();
                    if (currentProject.ConfigurationManager != null)
                    {
                        string uniqueProjectName = currentProject.UniqueName.ToLower();

                        Array configRowNames   = (Array)currentProject.ConfigurationManager.ConfigurationRowNames;
                        Array platformRowNames = (Array)currentProject.ConfigurationManager.PlatformNames;

                        if (!projectConfigs.ContainsKey(uniqueProjectName))
                        {
                            projectConfigs.Add(uniqueProjectName, new List <string>());
                        }
                        foreach (string configName in configRowNames)
                        {
                            foreach (string platformName in platformRowNames)
                            {
                                projectConfigs[uniqueProjectName].Add(configName + "|" + platformName);
                            }
                        }
                    }
                    if (Config.Instance.NamesOfProjectsToRemove.Contains(currentProjectName))
                    {
                        projectsToRemove.Add(currentProject);
                    }
                    else
                    {
                        //ProjectTools.RemoveCustomBuildToolsFromFxFiles(currentProject);
                        ProjectTools.DisableHlslFiles(currentProject, Output);
                    }
                }));

                RemoveProjectsFromSolution(solution, projectsToRemove);
                ApplyChangesToProjects(solution, projectConfigs);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                solution.Close(true);
            }
        }