コード例 #1
0
        public VsMachineWideSettings()
        {
            if (_asyncServiceProvider == null)
            {
                throw new ArgumentNullException(nameof(_asyncServiceProvider));
            }

            _settings = new AsyncLazy <Configuration.ISettings>(async() =>
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                var baseDirectory = Common.NuGetEnvironment.GetFolderPath(
                    Common.NuGetFolderPath.MachineWideConfigDirectory);

                var dte     = await _asyncServiceProvider.GetDTEAsync();
                var version = dte.Version;
                var sku     = dte.GetSKU();

                await TaskScheduler.Default;
                return(Configuration.Settings.LoadMachineWideSettings(
                           baseDirectory,
                           "VisualStudio",
                           version,
                           sku));
            },
                                                                ThreadHelper.JoinableTaskFactory);
        }
コード例 #2
0
        public OutputConsoleLogger(
            IAsyncServiceProvider asyncServiceProvider,
            IOutputConsoleProvider consoleProvider,
            Lazy <ErrorListTableDataSource> errorListDataSource)
        {
            if (asyncServiceProvider == null)
            {
                throw new ArgumentNullException(nameof(asyncServiceProvider));
            }

            if (consoleProvider == null)
            {
                throw new ArgumentNullException(nameof(consoleProvider));
            }

            ErrorListTableDataSource = errorListDataSource;

            NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                _dte         = await asyncServiceProvider.GetDTEAsync();
                _buildEvents = _dte.Events.BuildEvents;
                _buildEvents.OnBuildBegin    += (_, __) => { ErrorListTableDataSource.Value.ClearNuGetEntries(); };
                _solutionEvents               = _dte.Events.SolutionEvents;
                _solutionEvents.AfterClosing += () => { ErrorListTableDataSource.Value.ClearNuGetEntries(); };
                OutputConsole = consoleProvider.CreatePackageManagerConsole();
            });
        }
コード例 #3
0
        private async Task <Tuple <IVsProjectAdapter, string> > CreateProjectAdapterAsync(string projectUniqueName)
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var dte = await _asyncServiceprovider.GetDTEAsync();

            var supportedProjects = dte.Solution.Projects.Cast <EnvDTE.Project>();

            foreach (var solutionProject in supportedProjects)
            {
                var solutionProjectPath = EnvDTEProjectInfoUtility.GetFullProjectPath(solutionProject);

                if (!string.IsNullOrEmpty(solutionProjectPath) &&
                    PathUtility.GetStringComparerBasedOnOS().Equals(solutionProjectPath, projectUniqueName))
                {
                    // get the VSProjectAdapter instance which will be used to retrieve MSBuild properties
                    var projectApadter = await _vsProjectAdapterProvider.Value.CreateAdapterForFullyLoadedProjectAsync(solutionProject);

                    // read ProjectAssetsFile property to get assets file full path
                    var projectAssetsFile = await projectApadter.BuildProperties.GetPropertyValueAsync(ProjectAssetsFile);

                    return(Tuple.Create(projectApadter, projectAssetsFile));
                }
            }

            return(null);
        }
コード例 #4
0
 public VsCommonOperations(
     [Import(typeof(SVsServiceProvider))]
     IAsyncServiceProvider asyncServiceProvider)
 {
     Assumes.NotNull(asyncServiceProvider);
     _asyncServiceProvider = asyncServiceProvider;
     _dte = new AsyncLazy <EnvDTE.DTE>(async() =>
     {
         return(await asyncServiceProvider.GetDTEAsync());
     }, NuGetUIThreadHelper.JoinableTaskFactory);
 }
        public VsSourceControlManagerProvider(
            [Import(typeof(SVsServiceProvider))]
            IAsyncServiceProvider asyncServiceProvider,
            Configuration.ISettings vsSettings)
        {
            Assumes.NotNull(asyncServiceProvider);
            _asyncServiceProvider = asyncServiceProvider;
            Assumes.Present(vsSettings);

            _settings = vsSettings;
            _dte      = new AsyncLazy <EnvDTE.DTE>(async() =>
            {
                return(await asyncServiceProvider.GetDTEAsync());
            }, NuGetUIThreadHelper.JoinableTaskFactory);
        }
コード例 #6
0
        private async Task <NuGetProject> CreateNuGetProjectAsync(string projectUniqueName)
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            DTE dte = await _asyncServiceprovider.GetDTEAsync();

            IEnumerable <Project> supportedProjects = await GetProjectsInSolutionAsync(dte);

            foreach (Project solutionProject in supportedProjects)
            {
                string solutionProjectPath = solutionProject.GetFullProjectPath();

                if (!string.IsNullOrEmpty(solutionProjectPath) &&
                    PathUtility.GetStringComparerBasedOnOS().Equals(solutionProjectPath, projectUniqueName))
                {
                    return(await _solutionManager.Value.GetOrCreateProjectAsync(solutionProject, _projectContext.Value));
                }
            }

            return(null);
        }
コード例 #7
0
        private async Task <NuGetProject> CreateNuGetProjectAsync(string projectUniqueName)
        {
            await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            var dte = await _asyncServiceprovider.GetDTEAsync();

            var supportedProjects = dte.Solution.Projects.Cast <EnvDTE.Project>();

            foreach (var solutionProject in supportedProjects)
            {
                var solutionProjectPath = EnvDTEProjectInfoUtility.GetFullProjectPath(solutionProject);

                if (!string.IsNullOrEmpty(solutionProjectPath) &&
                    PathUtility.GetStringComparerBasedOnOS().Equals(solutionProjectPath, projectUniqueName))
                {
                    return(await _solutionManager.Value.GetOrCreateProjectAsync(solutionProject, _projectContext.Value));
                }
            }

            return(null);
        }
コード例 #8
0
 /// <summary> Creates a new instance of <see cref="VisualStudioShell"/>. </summary>
 /// <param name="asyncServiceProvider"> Async service provider. </param>
 internal VisualStudioShell(IAsyncServiceProvider asyncServiceProvider)
 {
     Verify.ArgumentIsNotNull(asyncServiceProvider, nameof(asyncServiceProvider));
     _dte = new AsyncLazy <EnvDTE.DTE>(() => asyncServiceProvider.GetDTEAsync(), NuGetUIThreadHelper.JoinableTaskFactory);
 }