public async Task BuildSolution(string target) { State = AppState.Building; BuildStarted?.Invoke(this, EventArgs.Empty); var results = new List <Microsoft.Build.Execution.BuildResult>(); await Task.Factory.StartNew(() => { ClearOutput(); var msbuild = Microsoft.Build.Execution.BuildManager.DefaultBuildManager; var projs = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection; projs.AddToolset(new Microsoft.Build.Evaluation.Toolset("Current", Path.Combine(DotNetInfo.SdkPath, DotNetInfo.SdkVersion), projs, Path.Combine(DotNetInfo.SdkPath, DotNetInfo.SdkVersion))); var globalProperties = new Dictionary <string, string>() { { "Configuration", SelectedConfiguration }, { "PlatformTarget", SelectedPlatform } }; foreach (var proj in this.Workspace.CurrentSolution.Projects) { projs.LoadProject(proj.FilePath); } var parameters = new Microsoft.Build.Execution.BuildParameters(projs); var loggers = new List <Microsoft.Build.Framework.ILogger>(); var cl = new Microsoft.Build.Logging.ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Normal, new Microsoft.Build.Logging.WriteHandler((s) => MSBuildLog(s)), new Microsoft.Build.Logging.ColorSetter((c) => MSBuildLogSetColor(c)), new Microsoft.Build.Logging.ColorResetter(() => MSBuildLogResetColor())); loggers.Add(cl); parameters.Loggers = loggers; msbuild.BeginBuild(parameters); var targets = new[] { target }; if (!target.Equals("restore", StringComparison.OrdinalIgnoreCase) && !target.Equals("clean", StringComparison.OrdinalIgnoreCase)) { targets = new[] { "restore", target }; } foreach (var p in Workspace.ProjectInstances) { var pinstance = new Microsoft.Build.Execution.ProjectInstance(p.FullPath, globalProperties, projs.DefaultToolsVersion, projs); var requestData = new Microsoft.Build.Execution.BuildRequestData(pinstance, targets); results.Add(msbuild.BuildRequest(requestData)); } msbuild.EndBuild(); }); State = AppState.SolutionReady; BuildFinished?.Invoke(this, EventArgs.Empty); OnBuildFinished(results); }
void OnBuildFinished(string assemblyPath, CompilerMessage[] messages) { if (messages.Any()) { foreach (var error in messages) { if (error.type == CompilerMessageType.Error) { Debug.LogError(error.message); } if (error.type == CompilerMessageType.Warning) { Debug.LogWarning(error.message); } } } // cleanup if (m_AssemblyBuilder != null) { m_AssemblyBuilder.buildFinished -= OnBuildFinished; m_AssemblyBuilder = null; } BuildFinished?.Invoke(assemblyPath, messages); // refresh all assets to trigger a domain reload AssetDatabase.Refresh(); }
public void OnBuildFinished(bool succeeded, string message = null, string helpKeyword = null) { BuildFinishedEventArgs args = new BuildFinishedEventArgs(message, helpKeyword, succeeded); BuildFinished?.Invoke(this, args); OnAnyEventRaised(args); }
/// <summary> /// Raise one of the events that is appropriate for the type of the BuildEventArgs /// </summary> public void Dispatch(BuildEventArgs buildEvent) { if (buildEvent is BuildMessageEventArgs) { MessageRaised?.Invoke(null, (BuildMessageEventArgs)buildEvent); } else if (buildEvent is TaskStartedEventArgs) { TaskStarted?.Invoke(null, (TaskStartedEventArgs)buildEvent); } else if (buildEvent is TaskFinishedEventArgs) { TaskFinished?.Invoke(null, (TaskFinishedEventArgs)buildEvent); } else if (buildEvent is TargetStartedEventArgs) { TargetStarted?.Invoke(null, (TargetStartedEventArgs)buildEvent); } else if (buildEvent is TargetFinishedEventArgs) { TargetFinished?.Invoke(null, (TargetFinishedEventArgs)buildEvent); } else if (buildEvent is ProjectStartedEventArgs) { ProjectStarted?.Invoke(null, (ProjectStartedEventArgs)buildEvent); } else if (buildEvent is ProjectFinishedEventArgs) { ProjectFinished?.Invoke(null, (ProjectFinishedEventArgs)buildEvent); } else if (buildEvent is BuildStartedEventArgs) { BuildStarted?.Invoke(null, (BuildStartedEventArgs)buildEvent); } else if (buildEvent is BuildFinishedEventArgs) { BuildFinished?.Invoke(null, (BuildFinishedEventArgs)buildEvent); } else if (buildEvent is CustomBuildEventArgs) { CustomEventRaised?.Invoke(null, (CustomBuildEventArgs)buildEvent); } else if (buildEvent is BuildStatusEventArgs) { StatusEventRaised?.Invoke(null, (BuildStatusEventArgs)buildEvent); } else if (buildEvent is BuildWarningEventArgs) { WarningRaised?.Invoke(null, (BuildWarningEventArgs)buildEvent); } else if (buildEvent is BuildErrorEventArgs) { ErrorRaised?.Invoke(null, (BuildErrorEventArgs)buildEvent); } AnyEventRaised?.Invoke(null, buildEvent); }
private static bool Publish(BuildInfo buildInfo) { if (_buildInProgress != null) { throw new InvalidOperationException("A build is already in progress."); } _buildInProgress = buildInfo; try { BuildStarted?.Invoke(buildInfo); // Required in order to update the build tasks list Internal.GodotMainIteration(); try { RemoveOldIssuesFile(buildInfo); } catch (IOException e) { BuildLaunchFailed?.Invoke(buildInfo, $"Cannot remove issues file: {GetIssuesFilePath(buildInfo)}"); Console.Error.WriteLine(e); } try { int exitCode = BuildSystem.Publish(buildInfo, StdOutputReceived, StdErrorReceived); if (exitCode != 0) { PrintVerbose( $"dotnet publish exited with code: {exitCode}. Log file: {GetLogFilePath(buildInfo)}"); } BuildFinished?.Invoke(exitCode == 0 ? BuildResult.Success : BuildResult.Error); return(exitCode == 0); } catch (Exception e) { BuildLaunchFailed?.Invoke(buildInfo, $"The publish method threw an exception.\n{e.GetType().FullName}: {e.Message}"); Console.Error.WriteLine(e); return(false); } } finally { _buildInProgress = null; } }
public static async Task <bool> BuildAsync(BuildInfo buildInfo) { if (_buildInProgress != null) { throw new InvalidOperationException("A build is already in progress."); } _buildInProgress = buildInfo; try { BuildStarted?.Invoke(buildInfo); try { RemoveOldIssuesFile(buildInfo); } catch (IOException e) { BuildLaunchFailed?.Invoke(buildInfo, $"Cannot remove issues file: {GetIssuesFilePath(buildInfo)}"); Console.Error.WriteLine(e); } try { int exitCode = await BuildSystem.BuildAsync(buildInfo, StdOutputReceived, StdErrorReceived); if (exitCode != 0) { PrintVerbose($"MSBuild exited with code: {exitCode}. Log file: {GetLogFilePath(buildInfo)}"); } BuildFinished?.Invoke(exitCode == 0 ? BuildResult.Success : BuildResult.Error); return(exitCode == 0); } catch (Exception e) { BuildLaunchFailed?.Invoke(buildInfo, $"The build method threw an exception.\n{e.GetType().FullName}: {e.Message}"); Console.Error.WriteLine(e); return(false); } } finally { _buildInProgress = null; } }
private void OnBuildDone(vsBuildScope Scope, vsBuildAction Action) { IsBuilding = false; BuildFinished?.Invoke(this, EventArgs.Empty); }
protected virtual void OnBuildFinished(EventArgs args) { BuildFinished?.Invoke(this, args); }
private void EventSourceOnBuildFinished(object sender, BuildFinishedEventArgs e) { BuildFinished?.Invoke(sender, e); }