示例#1
0
        /// <summary>
        /// Check if a particular component set for this IDE version
        /// </summary>
        /// <param name="ideInfo">The IDE info to search for the components</param>
        /// <param name="vsVersionToComponent">A dictionary of Visual Studio versions to their respective paths for a given component</param>
        /// <returns>true if the IDE has any of the component versions available, false otherwise</returns>
        internal static bool IsVSComponentAvailableForIDE(IDEInfo ideInfo, IDictionary <Version, string> vsVersionToComponent)
        {
            if (ideInfo == null)
            {
                throw new ArgumentNullException("ideInfo");
            }
            if (vsVersionToComponent == null)
            {
                throw new ArgumentNullException("vsVersionToComponent");
            }

            string path = null;

            if (vsVersionToComponent.TryGetValue(ideInfo.Version, out path))
            {
                if (ideInfo.Version == VS2015Version)
                {
                    return(IsFileInProgramFilesx86Exist(path));
                }
                else
                {
                    return(ideInfo.PackageVersions.ContainsKey(path));
                }
            }
            else if (vsVersionToComponent.TryGetValue(VSAnyVersion, out path))
            {
                return(ideInfo.PackageVersions.ContainsKey(path));
            }
            return(false);
        }
示例#2
0
        /// <summary>
        /// Initialize
        /// </summary>
        public void Init()
        {
            CheckFile();
            FileStream   fs = File.Open(_cfgFilePath, FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);
            string       line;

            SettingInfoList = new List <IDEInfo>();
            while ((line = sr.ReadLine()) != null)
            {
                string[] sL = line.Split(new char[] { '=' }, 2);

                if (sL.Length == 2)
                {
                    IDEInfo info = new IDEInfo(sL[0], sL[1]);
                    SettingInfoList.Add(info);
                }
            }


            if (TryGetIDEInfo(VersionKey) == null)
            {
                SettingInfoList = new List <IDEInfo>();
                SettingInfoList.Add(new IDEInfo(VersionKey, DATA_VER));
            }

            sr.Close();
            fs.Close();
        }
示例#3
0
文件: Program.cs 项目: zvoronz/stride
 private static void UpdateVisualStudioToLatest(string vsInstallerPath, IDEInfo existingVisualStudioInstall)
 {
     try
     {
         // Not sure why, but it seems VS Update is sometimes sending Ctrl+C to our process...
         Console.CancelKeyPress += Console_IgnoreControlC;
         var vsInstallerExitCode = RunProgramAndAskUntilSuccess("Visual Studio", vsInstallerPath, $"update --noUpdateInstaller --passive --norestart --installPath \"{existingVisualStudioInstall.InstallationPath}\"", DialogBoxTryAgainVS);
         if (vsInstallerExitCode != 0)
         {
             var errorMessage = $"{existingVisualStudioInstall.DisplayName} update failed with error {vsInstallerExitCode}";
             MessageBox.Show(errorMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             throw new InvalidOperationException(errorMessage);
         }
     }
     finally
     {
         Console.CancelKeyPress -= Console_IgnoreControlC;
     }
 }
示例#4
0
 public Debugger(IDEInfo ideInfo)
 {
     this.ideInfo = ideInfo;
 }
示例#5
0
        public static async Task <Process> StartVisualStudio(SessionViewModel session, IDEInfo ideInfo)
        {
            if (!await CheckCanOpenSolution(session))
            {
                return(null);
            }

            var startInfo = new ProcessStartInfo();

            if (ideInfo == null)
            {
                var defaultIDEName = EditorSettings.DefaultIDE.GetValue();

                if (!EditorSettings.DefaultIDE.GetAcceptableValues().Contains(defaultIDEName))
                {
                    defaultIDEName = EditorSettings.DefaultIDE.DefaultValue;
                }

                ideInfo = VisualStudioVersions.AvailableVisualStudioInstances.FirstOrDefault(x => x.DisplayName == defaultIDEName) ?? VisualStudioVersions.DefaultIDE;
            }

            // It will be null if either "Default", or if not available anymore (uninstalled?)
            if (ideInfo.DevenvPath != null && File.Exists(ideInfo.DevenvPath))
            {
                startInfo.FileName  = ideInfo.DevenvPath;
                startInfo.Arguments = $"\"{session.SolutionPath}\"";
            }
            else
            {
                startInfo.FileName        = session.SolutionPath.ToWindowsPath();
                startInfo.UseShellExecute = true;
            }
            try
            {
                return(Process.Start(startInfo));
            }
            catch
            {
                await session.Dialogs.MessageBox(Tr._p("Message", "An error occurred while starting Visual Studio."), MessageBoxButton.OK, MessageBoxImage.Information);

                return(null);
            }
        }
示例#6
0
        public static async Task <bool> StartOrToggleVisualStudio(SessionViewModel session, IDEInfo ideInfo)
        {
            if (!await CheckCanOpenSolution(session))
            {
                return(false);
            }

            var process = await GetVisualStudio(session, true) ?? await StartVisualStudio(session, ideInfo);

            return(process != null);
        }