/// <summary>
        /// Starts a build of the solution.
        /// </summary>
        public static Task <bool> Build(this ISolutionNode solution)
        {
            var sln = solution.As <EnvDTE.Solution>();

            if (sln == null)
            {
                throw new ArgumentException(Strings.ISolutionNodeExtensions.BuildNotSupported);
            }

            return(System.Threading.Tasks.Task.Factory.StartNew <bool>(() =>
            {
                var mre = new ManualResetEventSlim();
                var events = sln.DTE.Events.BuildEvents;
                EnvDTE._dispBuildEvents_OnBuildDoneEventHandler done = (scope, action) => mre.Set();
                events.OnBuildDone += done;
                try
                {
                    // Let build run async.
                    sln.SolutionBuild.Build(false);

                    // Wait until it's done.
                    mre.Wait();

                    // LastBuildInfo == # of projects that failed to build.
                    return sln.SolutionBuild.LastBuildInfo == 0;
                }
                catch (Exception ex)
                {
                    tracer.Error(ex, Strings.ISolutionNodeExtensions.BuildException);
                    return false;
                }
                finally
                {
                    // Cleanup handler.
                    events.OnBuildDone -= done;
                }
            }, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default));
        }
Пример #2
0
 /// <summary>
 /// Adapts a <see cref="ISolutionNode"/> to an <see cref="IVsHierarchy"/>.
 /// </summary>
 /// <returns>The <see cref="IVsSolution"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static IVsHierarchy AsVsHierarchy(this ISolutionNode solution) => solution.As <IVsHierarchy>();
Пример #3
0
 /// <summary>
 /// Adapts a <see cref="ISolutionNode"/> to an <see cref="IVsHierarchyItem"/>.
 /// </summary>
 /// <returns>The <see cref="IVsSolution"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static IVsHierarchyItem AsVsHierarchyItem(this ISolutionNode solution) => solution.As <IVsHierarchyItem>();
Пример #4
0
 /// <summary>
 /// Adapts a <see cref="ISolutionNode"/> to a DTE <see cref="Solution"/>.
 /// </summary>
 /// <returns>The DTE <see cref="Solution"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static Solution AsSolution(this ISolutionNode solution) => solution.As <EnvDTE.Solution>();
Пример #5
0
 /// <summary>
 /// Adapts a <see cref="ISolutionNode"/> to an <see cref="IVsSolution"/>.
 /// </summary>
 /// <returns>The <see cref="IVsSolution"/> or <see langword="null"/> if conversion is not possible.</returns>
 public static IVsSolution AsVsSolution(this ISolutionNode solution) => solution.As <IVsSolution>();
Пример #6
0
 internal static IProjectContainerNode AsProjectContainerNode(this ISolutionNode solution) =>
 solution.As <IProjectContainerNode>();