Пример #1
0
        private bool TryToSetupMsBuildProcessObject(SolutionInfo solutionInfo, ref ProcessStartInfo info)
        {
            try
            {
                info.FileName = GetMsBuildPath();
                if (string.IsNullOrEmpty(info.FileName))
                {
                    _settings.Output.WriteLine(
                        "Warning: RudeBuild is setup to use MSBuild, but MSBuild could not be found.\n" +
                        "Falling back to using a regular Visual Studio build.\n" +
                        "Error: Couldn't find MSBuild command-line tool: " + info.FileName);
                    return(false);
                }

                string buildCommand = "Build";
                if (_settings.BuildOptions.Clean)
                {
                    buildCommand = "Clean";
                }
                else if (_settings.BuildOptions.Rebuild)
                {
                    buildCommand = "Rebuild";
                }

                string   target      = _settings.ModifyFileName(solutionInfo.FilePath);
                string[] buildConfig = _settings.BuildOptions.Config.Split('|');
                if (!string.IsNullOrEmpty(_settings.BuildOptions.Project))
                {
                    ProjectInfo projectInfo = solutionInfo.GetProjectInfo(_settings.BuildOptions.Project);
                    if (projectInfo != null)
                    {
                        string projectConfigName;
                        SolutionConfigManager.ProjectConfig projectConfig = solutionInfo.ConfigManager.GetProjectByFileName(projectInfo.FileName);
                        if (projectConfig.SolutionToProjectConfigMap.TryGetValue(_settings.BuildOptions.Config, out projectConfigName))
                        {
                            target      = _settings.ModifyFileName(Path.GetFullPath(projectInfo.FileName));
                            buildConfig = projectConfigName.Split('|');
                        }
                    }
                }
                info.Arguments = $"/nodeReuse:false /m /t:{buildCommand} /p:Configuration=\"{buildConfig[0]}\" /p:Platform=\"{buildConfig[1]}\" \"{target}\"";
            }
            catch (Exception ex)
            {
                _settings.Output.WriteLine(
                    "Warning: RudeBuild is setup to use MSBuild, but MSBuild doesn't seem to be installed properly.\n" +
                    "Falling back to using a regular Visual Studio build.\n" +
                    "Error: " + ex.Message);
                return(false);
            }
            return(true);
        }
Пример #2
0
        private bool TryToSetupSnVsBuildProcessObject(SolutionInfo solutionInfo, ref ProcessStartInfo info)
        {
            try
            {
                info.FileName = GetSnVsBuildPath();
                if (string.IsNullOrEmpty(info.FileName))
                {
                    _settings.Output.WriteLine(
                        "Warning: RudeBuild is setup to use SN-DBS, but SN-DBS or VSI doesn't seem to be installed properly.\n" +
                        "Falling back to using a regular Visual Studio build.\n" +
                        "Error: Couldn't find VSI command-line tool: " + info.FileName);
                    return(false);
                }

                string buildCommand = "/build";
                if (_settings.BuildOptions.Clean)
                {
                    buildCommand = "/clean";
                }
                else if (_settings.BuildOptions.Rebuild)
                {
                    buildCommand = "/rebuild";
                }

                info.Arguments = string.Format(" \"{0}\" {1} \"{2}\"", _settings.ModifyFileName(solutionInfo.FilePath), buildCommand, _settings.BuildOptions.Config);
                if (!string.IsNullOrEmpty(_settings.BuildOptions.Project))
                {
                    ProjectInfo projectInfo = solutionInfo.GetProjectInfo(_settings.BuildOptions.Project);
                    if (projectInfo != null)
                    {
                        string projectConfigName = null;
                        SolutionConfigManager.ProjectConfig projectConfig = solutionInfo.ConfigManager.GetProjectByFileName(projectInfo.FileName);
                        if (projectConfig.SolutionToProjectConfigMap.TryGetValue(_settings.BuildOptions.Config, out projectConfigName))
                        {
                            info.Arguments += string.Format(" /project \"{0}\" /projectconfig \"{1}\"", _settings.ModifyFileName(projectInfo.FileName), projectConfigName);
                        }
                    }
                }
                info.Arguments += " /sn-dbs";
            }
            catch (Exception ex)
            {
                _settings.Output.WriteLine(
                    "Warning: RudeBuild is setup to use SN-DBS, but SN-DBS doesn't seem to be installed properly.\n" +
                    "Falling back to using a regular Visual Studio build.\n" +
                    "Error: " + ex.Message);
                return(false);
            }
            return(true);
        }
Пример #3
0
        private bool RemoveNoLongerExistingProjects(SolutionInfo solutionInfo)
        {
            bool changed      = false;
            var  projectNames = new List <string>(ProjectNameToExcludedCppFileNameMap.Keys);

            foreach (string projectName in projectNames)
            {
                // Check if the projects we have stored settings for still exists. If they don't, remove them.
                if (solutionInfo.GetProjectInfo(projectName) == null || !ProjectNameToExcludedCppFileNameMap[projectName].Any())
                {
                    ProjectNameToExcludedCppFileNameMap.Remove(projectName);
                    changed = true;
                }
            }

            return(changed);
        }
Пример #4
0
        private void ValidateBuildOptions(SolutionInfo solutionInfo)
        {
            string solutionConfig = _settings.BuildOptions.Config;

            if (string.IsNullOrEmpty(solutionConfig))
            {
                throw new ArgumentException(string.Format("A solution configuration to build is required! None specified while trying to build solution {0}.", solutionInfo.Name));
            }

            if (!solutionInfo.ConfigManager.SolutionConfigs.Contains(solutionConfig))
            {
                throw new ArgumentException(string.Format("The specified solution configuration {0} does not exist in solution {1}.", solutionConfig, solutionInfo.Name));
            }

            string projectName = _settings.BuildOptions.Project;

            if (!string.IsNullOrEmpty(projectName) && null == solutionInfo.GetProjectInfo(projectName))
            {
                throw new ArgumentException(string.Format("Solution {0} doesn't contain a project called {1}!", solutionInfo.Name, projectName));
            }
        }
Пример #5
0
        public bool Update(SolutionInfo solutionInfo)
        {
            if (null == ProjectNameToExcludedCppFileNameMap)
            {
                ProjectNameToExcludedCppFileNameMap = new SerializableDictionary <string, List <string> >();
            }

            bool changed = RemoveNoLongerExistingProjects(solutionInfo);

            foreach (string projectName in solutionInfo.ProjectNames)
            {
                ProjectInfo projectInfo = solutionInfo.GetProjectInfo(projectName);
                if (null == projectInfo)
                {
                    throw new InvalidDataException("SolutionInfo does not contain ProjectInfo object for project called " + projectName);
                }

                changed = RemoveNoLongerExistingCppFileNames(projectInfo) || changed;
            }

            return(changed);
        }