Esempio n. 1
0
        private async Task OpenItemsAsync(params string[] itemsFullPath)
        {
            await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();

            var dte = await _vsShellService.GetDteAsync();

            if (itemsFullPath == null || itemsFullPath.Length == 0)
            {
                return;
            }

            foreach (var item in itemsFullPath)
            {
                switch (Path.GetExtension(item).ToUpperInvariant())
                {
                case ".XAML":
                    dte.ItemOperations.OpenFile(item, EnvDTE.Constants.vsViewKindDesigner);
                    break;

                default:
                    if (!item.EndsWith(".xaml.cs", StringComparison.OrdinalIgnoreCase))
                    {
                        dte.ItemOperations.OpenFile(item, EnvDTE.Constants.vsViewKindPrimary);
                    }

                    break;
                }
            }
        }
Esempio n. 2
0
        private async Task <Project> GetActiveProjectAsync()
        {
            Project p = null;

            try
            {
                await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();

                var dte = await _vsShellService.GetDteAsync();

                Array projects = (Array)dte.ActiveSolutionProjects;

                if (projects?.Length >= 1)
                {
                    p = (Project)projects.GetValue(0);
                }

                return(p);
            }
            catch (Exception)
            {
                // WE GET AN EXCEPTION WHEN THERE ISN'T A PROJECT LOADED
                p = null;
            }

            return(p);
        }
Esempio n. 3
0
        public async Task <bool> IsBuildInProgressAsync()
        {
            await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();

            var dte = await _vsShellService.GetDteAsync();

            return(dte.Solution.SolutionBuild.BuildState == vsBuildState.vsBuildStateInProgress);
        }
Esempio n. 4
0
        private async Task ChangeSolutionConfigurationAsync(IEnumerable <ProjectConfiguration> projectConfigurations)
        {
            await SafeThreading.JoinableTaskFactory.SwitchToMainThreadAsync();

            var dte = await _vsShellService.GetDteAsync();

            foreach (SolutionConfiguration solConfiguration in dte.Solution?.SolutionBuild?.SolutionConfigurations)
            {
                foreach (SolutionContext context in solConfiguration.SolutionContexts)
                {
                    var projectName = context.ProjectName;
                    if (projectConfigurations.Any(p => p.Project == projectName))
                    {
                        var projConfig = projectConfigurations.FirstOrDefault(p => p.Project == projectName);
                        context.ShouldDeploy = projConfig.SetDeploy;
                    }
                }
            }
        }