public BuildResult(MSBuildResult buildResult, ProjectInstance projectInstance) { this.buildResult = buildResult; this.projectInstance = projectInstance; Debug.Assert(!this.IsSuccessful || this.ProjectInstance != null, "All successfull build results should have project instances"); }
private void NotifyBuildEnd(MSBuildResult result, string buildTarget) { int success = ((result == MSBuildResult.Successful) ? 1 : 0); foreach (IVsBuildStatusCallback cb in callbacks) { try { ErrorHandler.ThrowOnFailure(cb.BuildEnd(success)); } catch (Exception e) { // If those who ask for status have bugs in their code it should not prevent the build/notification from happening Debug.Fail(SR.GetString(SR.BuildEventError, e.Message)); } finally { // We want to refresh the references if we are building with the Build or Rebuild target or if the project was opened for browsing only. bool shouldRepaintReferences = (buildTarget == null || buildTarget == MsBuildTarget.Build || buildTarget == MsBuildTarget.Rebuild); // Now repaint references if that is needed. // We hardly rely here on the fact the ResolveAssemblyReferences target has been run as part of the build. // One scenario to think at is when an assembly reference is renamed on disk thus becomming unresolvable, // but msbuild can actually resolve it. // Another one if the project was opened only for browsing and now the user chooses to build or rebuild. if (shouldRepaintReferences && (result == MSBuildResult.Successful)) { this.RefreshReferences(); } } } }
private void Build(uint options, IVsOutputWindowPane output, string target) { if (!this.config.ProjectMgr.HasPassedSecurityChecks) { // From a security perspective, if there was something truly malicious about the project, // the user is about to toast himself by requesting a build. Any further attempts at // preventing damage by avoiding MSBuild targets/tasks are futile. So, from this point // forward, we might as well pretend that this project has passed all security checks, // and we're free to run any targets we like. this.config.ProjectMgr.HasPassedSecurityChecks = true; } // We want to refresh the references if we are building with the Build or Rebuild target or if the project was opened for browsing only. bool shouldRepaintReferences = (target == null || target == MsBuildTarget.Build || target == MsBuildTarget.Rebuild || !this.config.ProjectMgr.HasPassedSecurityChecks); int shouldContinue = 1; foreach (IVsBuildStatusCallback cb in callbacks) { try { ErrorHandler.ThrowOnFailure(cb.BuildBegin(ref shouldContinue)); if (shouldContinue == 0) { return; } } catch (Exception e) { // If those who ask for status have bugs in their code it should not prevent the build/notification from happening Debug.Fail(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.BuildEventError, CultureInfo.CurrentUICulture), e.Message)); } } MSBuildResult result = MSBuildResult.Failed; try { result = config.ProjectMgr.Build(options, this.config.ConfigName, output, target); } catch (Exception e) { Trace.WriteLine("Exception : " + e.Message); ErrorHandler.ThrowOnFailure(output.OutputStringThreadSafe("Unhandled Exception:" + e.Message + "\n")); throw e; } finally { int success = ((result == MSBuildResult.Successful) ? 1 : 0); foreach (IVsBuildStatusCallback cb in callbacks) { try { ErrorHandler.ThrowOnFailure(cb.BuildEnd(success)); } catch (Exception e) { // If those who ask for status have bugs in their code it should not prevent the build/notification from happening Debug.Fail(String.Format(CultureInfo.CurrentCulture, SR.GetString(SR.BuildEventError, CultureInfo.CurrentUICulture), e.Message)); } } ErrorHandler.ThrowOnFailure(output.FlushToTaskList()); // Now repaint references if that is needed. // We hardly rely here on the fact the ResolveAssemblyReferences target has been run as part of the build. // One scenario to think at is when an assembly reference is renamed on disk thus becomming unresolvable, // but msbuild can actually resolve it. // Another one if the project was opened only for browsing and now the user chooses to build or rebuild. if (shouldRepaintReferences && (result == MSBuildResult.Successful)) { this.RefreshReferences(); } } }