protected override PackageManagementEventsMonitor CreateEventMonitor ( ProgressMonitor monitor, IPackageManagementEvents packageManagementEvents) { EventsMonitor = new TestablePackageManagementEventsMonitor (monitor, packageManagementEvents); return EventsMonitor; }
static void GenerateInternal (ProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { if (file.Project.SupportedLanguages.All (l => l != "C#")) { string msg = GettextCatalog.GetString ("Razor templates are only supported in C# projects"); result.Errors.Add (new CompilerError (file.Name, -1, -1, null, msg)); monitor.Log.WriteLine (msg); return; } var host = new PreprocessedRazorHost (file.FilePath); var defaultOutputName = file.FilePath.ChangeExtension (".cs"); var ns = CustomToolService.GetFileNamespace (file, defaultOutputName); host.DefaultNamespace = ns; CompilerErrorCollection errors; var code = host.GenerateCode (out errors); result.Errors.AddRange (errors); var writer = new MonoDevelop.DesignerSupport.CodeBehindWriter (); writer.WriteFile (defaultOutputName, code); writer.WriteOpenFiles (); result.GeneratedFilePath = defaultOutputName; foreach (var err in result.Errors) { monitor.Log.WriteLine (err); } }
protected override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration) { if (base.OnGetCanExecute(context, configuration)) { return base.OnExecute(monitor, context, configuration); } try { var project = Project as DotNetProject; if (project != null && IsSupportedProject) { const string SoftDebuggerName = RhinoSoftDebuggerEngine.DebuggerName; var config = project.GetConfiguration(configuration) as DotNetProjectConfiguration; var cmd = new RhinoCommonExecutionCommand(project.GetOutputFileName(configuration), project); cmd.Arguments = config.CommandLineParameters; cmd.WorkingDirectory = Path.GetDirectoryName(config.CompiledOutputName); cmd.EnvironmentVariables = config.GetParsedEnvironmentVariables(); cmd.TargetRuntime = project.TargetRuntime; cmd.UserAssemblyPaths = project.GetUserAssemblyPaths(configuration); var executionModes = Runtime.ProcessService.GetExecutionModes(); var executionMode = executionModes.SelectMany(r => r.ExecutionModes).FirstOrDefault(r => r.Id == SoftDebuggerName); var console = context.ConsoleFactory.CreateConsole(new OperationConsoleFactory.CreateConsoleOptions(true)); var operation = executionMode.ExecutionHandler.Execute(cmd, console); monitor.CancellationToken.Register(() => operation.Cancel()); return operation.Task; } } catch (Exception ex) { monitor.ReportError($"An error occurred starting Rhino.\n{ex}", ex); } return null; }
public async Task<BuildResult> Build (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { var res = new BuildResult { BuildCount = 0 }; foreach (var bt in Items.OfType<IBuildTarget> ()) res.Append (await bt.Build (monitor, configuration, operationContext:operationContext)); return res; }
public TestablePackageManagementEventsMonitor ( ProgressMonitor progressMonitor, IPackageManagementEvents packageManagementEvents, IProgressProvider progressProvider) : base (progressMonitor, packageManagementEvents, progressProvider) { }
public virtual bool BuildPackage (ProgressMonitor monitor, PackageBuilder builder) { if (Next != null) return Next.BuildPackage (monitor, builder); else return builder.Build (monitor); }
public void Start() { tracker = CreateProgressMonitor (); tracker.BeginTask(GetDescription(), 1); // Sync invoke background worker which will end up doing async invoke on the internal run. BackgroundWorker (); }
internal protected virtual Task Execute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionRunConfiguration runConfiguration) { context.RunConfiguration = runConfiguration; #pragma warning disable 618 // Type or member is obsolete return Execute (monitor, context, configuration); #pragma warning restore 618 // Type or member is obsolete }
protected override async Task OnExecute(MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration) { bool defaultCanExecute; lock (canExecuteCheckLock) { try { checkingCanExecute = true; defaultCanExecute = Project.CanExecute(context, configuration); } finally { checkingCanExecute = false; } } if (defaultCanExecute) { // It is executable by default await base.OnExecute(monitor, context, configuration); return; } UnitTest test = FindRootTest(); if (test != null) { var cs = new CancellationTokenSource(); using (monitor.CancellationToken.Register(cs.Cancel)) await NUnitService.Instance.RunTest(test, context.ExecutionHandler, false, false, cs); } }
internal protected override void OnWriteProject (ProgressMonitor monitor, MSBuildProject project) { base.OnWriteProject (monitor, project); HashSet<string> validProjitems = new HashSet<string> (); foreach (var r in Project.References.Where (rp => rp.ReferenceType == ReferenceType.Project)) { var ip = r.GetItemsProjectPath (); if (!string.IsNullOrEmpty (ip)) { ip = MSBuildProjectService.ToMSBuildPath (Project.ItemDirectory, ip); validProjitems.Add (ip); if (!project.Imports.Any (im => im.Project == ip)) { // If there is already a Shared import, place the new import in the same location MSBuildObject before = project.Imports.FirstOrDefault (i => i.Label == "Shared" && i.Project.EndsWith (".projitems")); if (before == null) { var fsharpProject = project.ProjectTypeGuids.Contains("{F2A71F9B-5D33-465A-A702-920D77279786}"); if (fsharpProject) //For F# use the first item group as the shared project files have to be listed first before = project.ItemGroups.FirstOrDefault (i => i.Label != "Shared"); else before = project.Imports.FirstOrDefault (i => i.Label != "Shared"); } var im = project.AddNewImport (ip, beforeObject: before); im.Label = "Shared"; im.Condition = "Exists('" + ip + "')"; } } } foreach (var im in project.Imports.ToArray ()) { if (im.Label == "Shared" && im.Project.EndsWith (".projitems") && !(validProjitems.Contains (im.Project))) project.RemoveImport (im.Project); } }
protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { foreach (Package p in packages) if (!await p.Build (monitor)) break; return BuildResult.CreateSuccess (); }
protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { Task restoreTask = PackageRestoreTask; if (restoreTask != null) { return WaitForRestoreThenBuild (restoreTask, monitor, configuration, operationContext); } return base.OnBuild (monitor, configuration, operationContext); }
public ProgressMonitorWrapperJob (IAnalysisJob wrappedJob, string message) { this.wrappedJob = wrappedJob; monitor = IdeApp.Workbench.ProgressMonitors.GetStatusProgressMonitor (message, null, false); var work = wrappedJob.GetFiles ().Sum (f => wrappedJob.GetIssueProviders (f).Count ()); monitor.BeginTask (message, work); }
/// <summary> /// If the project is a NuGet packaging project then just use the normal build target. /// This ensures that the dependent projects are built. /// /// Otherwise the Pack target is called. /// </summary> public async Task<BuildResult> Build (ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null) { if (project is PackagingProject) { return await project.Build (monitor, configuration, buildReferencedTargets, new TargetEvaluationContext (operationContext)); } else { return await Pack (monitor, configuration, buildReferencedTargets, operationContext); } }
public override Task<WorkspaceItem> LoadWorkspaceItem (ProgressMonitor monitor, string fileName) { return Task.Run (async () => { var workspaceItem = ReadWorkspaceItemFile (fileName, monitor); await workspaceItem.LoadUserProperties (); return workspaceItem; }); }
public void Install (ProgressMonitor monitor, SolutionFolderItem entry, string appName, string prefix, ConfigurationSelector configuration) { this.appName = appName; using (DeployContext ctx = new DeployContext (this, DeployService.CurrentPlatform, prefix)) { InstallEntry (monitor, ctx, entry, configuration); } }
public BuildEventArgs (ProgressMonitor monitor, bool success) { this.monitor = monitor; this.success = success; this.WarningCount = -1; this.ErrorCount = -1; this.BuildCount = -1; this.FailedBuildCount = -1; }
protected override Task<TargetEvaluationResult> OnRunTarget(ProgressMonitor monitor, string target, ConfigurationSelector configuration, TargetEvaluationContext context) { if (Commands.SelectActiveCompilerHandler.IsRoslynCompilerSet) { context.GlobalProperties.SetValue("CscToolExe", "csc.exe"); context.GlobalProperties.SetValue("CscToolPath", Path.Combine(Path.GetDirectoryName(typeof(ProjectExtension).Assembly.Location), "RoslynCompilerFiles")); context.GlobalProperties.SetValue("DebugType", "portable"); } return base.OnRunTarget(monitor, target, configuration, context); }
public Task Generate (ProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { return Task.Run (delegate { try { GenerateInternal (monitor, file, result); } catch (Exception ex) { result.UnhandledException = ex; } }); }
public override Task<SolutionItem> LoadSolutionItem (ProgressMonitor monitor, SolutionLoadContext ctx, string fileName, MSBuildFileFormat expectedFormat, string typeGuid, string itemGuid) { return Task.Run (() => { foreach (var f in MSBuildFileFormat.GetSupportedFormats ()) { if (f.CanReadFile (fileName, typeof(SolutionItem))) return MSBuildProjectService.LoadItem (monitor, fileName, f, typeGuid, itemGuid, ctx); } throw new NotSupportedException (); }); }
public override Task<WorkspaceItem> LoadWorkspaceItem (ProgressMonitor monitor, string fileName) { return Task.Run (async () => { foreach (var f in MSBuildFileFormat.GetSupportedFormats ()) { if (f.CanReadFile (fileName, typeof(WorkspaceItem))) return (WorkspaceItem) await f.ReadFile (fileName, typeof(WorkspaceItem), monitor); } throw new NotSupportedException (); }); }
public async Task Generate (ProgressMonitor monitor, ProjectFile file, SingleFileCustomToolResult result) { var buildResult = await file.Project.PerformGeneratorAsync (monitor, IdeApp.Workspace.ActiveConfiguration, this.targetName); foreach (var err in buildResult.BuildResult.Errors) { result.Errors.Add (new CompilerError (err.FileName, err.Line, err.Column, err.ErrorNumber, err.ErrorText) { IsWarning = err.IsWarning }); } }
public static CodeBehindWriter CreateForProject (ProgressMonitor monitor, DotNetProject project) { var pol = project.Policies.Get<TextStylePolicy> (); var options = new CodeGeneratorOptions () { IndentString = pol.TabsToSpaces? new string (' ', pol.TabWidth) : "\t", BlankLinesBetweenMembers = true, }; var provider = project.LanguageBinding.GetCodeDomProvider (); return new CodeBehindWriter (monitor, provider, options); }
protected override void OnWriteProject (ProgressMonitor monitor, MSBuildProject msproject) { base.OnWriteProject (monitor, msproject); UpdateRequiresMSBuildSetting (msproject, true); if (InstallBuildPackagingNuGetAfterWrite) { InstallBuildPackagingNuGetAfterWrite = false; Project.InstallBuildPackagingNuGetPackage (); } }
internal async Task <object> ReadFile(FilePath file, Type expectedType, MonoDevelop.Core.ProgressMonitor monitor) { if (slnFileFormat.CanReadFile(file, this)) { return(await slnFileFormat.ReadFile(file, monitor)); } else { throw new NotSupportedException(); } }
async Task<BuildResult> WaitForRestoreThenBuild (Task restoreTask, ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { try { await restoreTask; } catch (Exception ex) { var result = new BuildResult (); result.AddError (GettextCatalog.GetString ("{0}. Please see the Package Console for more details.", ex.Message)); return result; } return await base.OnBuild (monitor, configuration, operationContext); }
public async Task<BuildResult> RunTarget (ProgressMonitor monitor, string target, ConfigurationSelector configuration) { switch (target) { case "Build": return await OnBuild (monitor, configuration); case "Clean": return await OnClean (monitor, configuration); } return new BuildResult (new CompilerResults (null), ""); }
protected override bool OnBuild (ProgressMonitor monitor, DeployContext ctx) { string tmpFolder = null; try { SolutionConfigurationSelector conf = (SolutionConfigurationSelector) configuration; var bt = RootSolutionItem as IBuildTarget; if (bt != null) { BuildResult res = bt.Build (monitor, conf).Result; if (res.ErrorCount > 0) { foreach (BuildError e in res.Errors) monitor.ReportError (e.ToString (), null); monitor.ReportError (GettextCatalog.GetString ("The source project failed to build."), null); return false; } } tmpFolder = FileService.CreateTempDirectory (); string tf = Path.GetFileNameWithoutExtension (targetFile); if (tf.EndsWith (".tar")) tf = Path.GetFileNameWithoutExtension (tf); string folder = FileService.GetFullPath (Path.Combine (tmpFolder, tf)); // Export the binary files DeployFileCollection deployFiles = GetDeployFiles (ctx, conf); foreach (DeployFile file in deployFiles) { string tfile = Path.Combine (folder, file.ResolvedTargetFile); string tdir = FileService.GetFullPath (Path.GetDirectoryName (tfile)); if (!Directory.Exists (tdir)) Directory.CreateDirectory (tdir); File.Copy (file.SourcePath, tfile, true); } // Create the archive string td = Path.GetDirectoryName (targetFile); if (!Directory.Exists (td)) Directory.CreateDirectory (td); DeployService.CreateArchive (monitor, tmpFolder, targetFile); } catch (Exception ex) { monitor.ReportError ("Package creation failed", ex); LoggingService.LogError ("Package creation failed", ex); return false; } finally { if (tmpFolder != null) Directory.Delete (tmpFolder, true); } monitor.Log.WriteLine (GettextCatalog.GetString ("Created file: {0}", targetFile)); return true; }
void RunInternal () { progressMessage = CreateCheckingPackageCompatibilityMessage (); using (progressMonitor = CreateProgressMonitor ()) { using (PackageManagementEventsMonitor eventMonitor = CreateEventMonitor (progressMonitor)) { try { CheckCompatibility (); } catch (Exception ex) { eventMonitor.ReportError (progressMessage, ex); } } } }
void CheckForPackageUpdates ( ProgressMonitor progressMonitor, ProgressMonitorStatusMessage progressMessage, PackageUpdatesEventMonitor eventMonitor) { updatedPackagesInSolution.CheckForUpdates (); if (updatedPackagesInSolution.AnyUpdates ()) { progressMonitor.ReportSuccess (GettextCatalog.GetString ("Package updates are available.")); } else if (eventMonitor.WarningReported) { progressMonitor.ReportWarning (progressMessage.Warning); } else { progressMonitor.ReportSuccess (progressMessage.Success); } }
public override void MoveFile (FilePath source, FilePath dest) { ProgressMonitor monitor = new ProgressMonitor (); Repository srcRepo = GetRepository (source); Repository dstRepo = GetRepository (dest); if (dstRepo != null && dstRepo.CanMoveFilesFrom (srcRepo, source, dest)) srcRepo.MoveFile (source, dest, true, monitor); else { CopyFile (source, dest, true); srcRepo.DeleteFile (source, true, monitor, false); } }
public async Task<bool> Run (ProgressMonitor monitor, DotNetProject project, ConfigurationSelector configuration) { try { Stetic.CodeGenerationResult res = await GuiBuilderService.GenerateSteticCode (monitor, project, configuration); if (res != null) Messages = res.Warnings; return true; } catch (Exception ex) { Error = ex; LoggingService.LogError (ex.ToString ()); Messages = new [] { Error.Message }; return false; } }
protected override async Task OnExecute(MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration) { if (runConfiguration == unitTestingRunConfigurationInstance) { // The user selected to run the tests UnitTest test = FindRootTest(); if (test != null) { using (var cs = CancellationTokenSource.CreateLinkedTokenSource(monitor.CancellationToken)) await UnitTestService.RunTest(test, context, false, false, cs); } } else { await base.OnExecute(monitor, context, configuration, runConfiguration); } }
protected override BuildResult OnCompileSources(ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, MonoDevelop.Core.ProgressMonitor monitor) { return(VBBindingCompilerServices.InternalCompile(items, configuration, configSelector, monitor)); }
protected override Task <BuildResult> OnBuild(MonoDevelop.Core.ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext) { return(Task.FromResult(BuildResult.CreateSuccess())); }
protected override BuildResult OnCompileSources(ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, MonoDevelop.Core.ProgressMonitor monitor) { Debug.Assert(compilerServices != null); return(compilerServices.Compile(items, configuration, configSelector, monitor)); }
protected override BuildResult OnCompileSources(ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, MonoDevelop.Core.ProgressMonitor monitor) { monitor.Log.WriteLine("Starting..."); var fileNames = items.OfType <ProjectFile>().Select((ProjectFile arg) => arg.FilePath.ToString()).ToArray(); var options = new System.CodeDom.Compiler.CompilerParameters(); options.OutputAssembly = configuration.CompiledOutputName.ToString(); var compileResult = OneScriptCompilerService.CompileAssemblyFromFile(options, fileNames); monitor.Log.WriteLine("Done!"); return(new BuildResult(compileResult, null)); }