本文整理汇总了C#中IProgressMonitor.ReportError方法的典型用法代码示例。如果您正苦于以下问题:C# IProgressMonitor.ReportError方法的具体用法?C# IProgressMonitor.ReportError怎么用?C# IProgressMonitor.ReportError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProgressMonitor
的用法示例。
在下文中一共展示了IProgressMonitor.ReportError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CopyFiles
public override void CopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context)
{
DirectoryInfo tempDir = null;
try {
tempDir = CreateTempDir ();
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Could not create temporary directory."), e);
return;
}
try {
MountTempDirectory (copyConfig, tempDir.FullName);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Could not mount FUSE filesystem."), e);
RemoveTempDirIfEmpty (tempDir);
return;
}
try {
base.InternalCopyFiles (monitor, replacePolicy, copyConfig, deployFiles, context, tempDir.FullName);
} finally {
try {
//unmount the fuse directory
RunFuseCommand ("fusermount", string.Format ("-u \"{0}\"", tempDir.FullName));
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Could not unmount FUSE filesystem."), e);
}
RemoveTempDirIfEmpty (tempDir);
}
}
示例2: OnBuild
protected override bool OnBuild (IProgressMonitor monitor, DeployContext ctx)
{
string tmpFolder = null;
try {
SolutionConfigurationSelector conf = (SolutionConfigurationSelector) configuration;
if (RootSolutionItem.NeedsBuilding (conf)) {
BuildResult res = RootSolutionItem.Build (monitor, conf);
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);
}
if (monitor.AsyncOperation.Success)
monitor.Log.WriteLine (GettextCatalog.GetString ("Created file: {0}", targetFile));
return true;
}
示例3: DoExecute
protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
{
IodineConfiguration config = (IodineConfiguration)GetConfiguration (configuration);
IConsole console = config.ExternalConsole ?
context.ExternalConsoleFactory.CreateConsole (!config.PauseConsoleOutput) :
context.ConsoleFactory.CreateConsole (!config.PauseConsoleOutput);
AggregatedOperationMonitor aggregatedMonitor = new AggregatedOperationMonitor (monitor);
try {
string param = string.Format ("\"{0}\" {1}", config.MainFile, config.CommandLineParameters);
IProcessAsyncOperation op = Runtime.ProcessService.StartConsoleProcess ("iodine",
param, BaseDirectory,
config.EnvironmentVariables, console, null);
monitor.CancelRequested += delegate {
op.Cancel ();
};
aggregatedMonitor.AddOperation (op);
op.WaitForCompleted ();
monitor.Log.WriteLine ("Iodine exited with code: " + op.ExitCode);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", config.MainFile), e);
} finally {
console.Dispose ();
aggregatedMonitor.Dispose ();
}
}
示例4: ReadFile_
public static object ReadFile_(string file, Type expectedType, IProgressMonitor monitor)
{
bool clearLoadedPrjList = AlreadyLoadedPackages == null;
if (clearLoadedPrjList)
AlreadyLoadedPackages = new List<string> ();
if (AlreadyLoadedPackages.Contains (file))
return null;
AlreadyLoadedPackages.Add (file);
DubProject defaultPackage;
try{
using (var s = File.OpenText (file))
using (var r = new JsonTextReader (s))
defaultPackage = ReadPackageInformation(file, r, monitor);
}catch(Exception ex){
if (clearLoadedPrjList)
AlreadyLoadedPackages = null;
monitor.ReportError ("Couldn't load dub package \"" + file + "\"", ex);
return null;
}
if (expectedType.IsInstanceOfType (defaultPackage)) {
LoadDubProjectReferences (defaultPackage, monitor);
if (clearLoadedPrjList)
AlreadyLoadedPackages = null;
return defaultPackage;
}
var sln = new DubSolution();
if (!expectedType.IsInstanceOfType (sln)) {
if (clearLoadedPrjList)
AlreadyLoadedPackages = null;
return null;
}
sln.RootFolder.AddItem(defaultPackage, false);
sln.StartupItem = defaultPackage;
// Introduce solution configurations
foreach (var cfg in defaultPackage.Configurations)
sln.AddConfiguration(cfg.Name, false).Platform = cfg.Platform;
LoadDubProjectReferences (defaultPackage, monitor, sln);
sln.LoadUserProperties();
if (clearLoadedPrjList) {
AlreadyLoadedPackages = null;
// Clear 'dub list' outputs
DubReferencesCollection.DubListOutputs.Clear ();
}
return sln;
}
示例5: CopyFiles
public override void CopyFiles (IProgressMonitor monitor, IFileReplacePolicy replacePolicy, FileCopyConfiguration copyConfig, DeployFileCollection deployFiles, DeployContext context)
{
DirectoryInfo tempDir = null;
try {
tempDir = CreateTempDir ();
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Could not create temporary directory."), e);
return;
}
try {
MountTempDirectory (monitor, copyConfig, tempDir.FullName);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Could not mount FUSE filesystem."), e);
RemoveTempDirIfEmpty (tempDir);
return;
}
try {
base.InternalCopyFiles (monitor, replacePolicy, copyConfig, deployFiles, context, tempDir.FullName);
} finally {
//unmount the filesystem
try {
string escapedDir = tempDir.FullName.Replace ("\"", "\\\"");
string cmd, args;
if (PropertyService.IsMac) {
cmd = "umount";
args = string.Format ("\"{0}\"", escapedDir);
} else {
cmd = "fusermount";
args = string.Format ("-u \"{0}\"", escapedDir);
}
RunFuseCommand (monitor, cmd, args);
} catch (Exception e) {
LoggingService.LogError (GettextCatalog.GetString ("Could not unmount FUSE filesystem."), e);
monitor.ReportError (GettextCatalog.GetString ("Could not unmount FUSE filesystem."), e);
}
RemoveTempDirIfEmpty (tempDir);
}
}
示例6: Generate
public static void Generate(IProgressMonitor monitor, BuildResult result, MonobjcProject project, ConfigurationSelector configuration, String outputDirectory, bool native)
{
// Infer application name from configuration
String applicationName = project.GetApplicationName(configuration);
LoggingService.LogInfo("Generate => applicationName='" + applicationName + "'");
LoggingService.LogInfo("Generate => outputDirectory='" + outputDirectory + "'");
// Create the bundle maker
BundleMaker maker = new BundleMaker(applicationName, outputDirectory);
// Compile the XIB files
BuildHelper.CompileXIBFiles(monitor, project, maker, result);
if (result.ErrorCount > 0)
{
monitor.ReportError(GettextCatalog.GetString("Failed to compile XIB files"), null);
return;
}
// Copy the output and dependencies
BuildHelper.CopyOutputFiles(monitor, project, configuration, maker);
// Copy the content files
BuildHelper.CopyContentFiles(monitor, project, configuration, maker);
// Create the Info.plist
BuildHelper.CreateInfoPList(monitor, project, configuration, maker);
if (native)
{
GenerateNative(monitor, result, project, configuration, maker);
}
else
{
// Copy the Monobjc assemblies
BuildHelper.CopyMonobjcAssemblies(monitor, project, configuration, maker);
// Write the native runtime
monitor.BeginTask(GettextCatalog.GetString("Copying native launcher..."), 0);
maker.WriteRuntime(project.TargetOSVersion);
monitor.EndTask();
}
BuildHelper.CombineArtwork(monitor, project, maker);
BuildHelper.EncryptContentFiles(monitor, project, configuration, maker);
// Perform the signing
BuildHelper.SignBundle(monitor, project, maker);
BuildHelper.SignNativeBinaries(monitor, project, maker);
}
示例7: LoadWorkspaceItem
public override WorkspaceItem LoadWorkspaceItem (IProgressMonitor monitor, string fileName)
{
WorkspaceItem item = base.LoadWorkspaceItem (monitor, fileName);
Solution sol = item as Solution;
if (sol != null) {
//Resolve project references
try {
MakefileData.ResolveProjectReferences (sol.RootFolder, monitor);
} catch (Exception e) {
LoggingService.LogError (GettextCatalog.GetString (
"Error resolving Makefile based project references for solution {0}", sol.Name), e);
monitor.ReportError (GettextCatalog.GetString (
"Error resolving Makefile based project references for solution {0}", sol.Name), e);
}
}
return item;
}
示例8: ExecuteProject
internal static void ExecuteProject(DubProject prj,IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
{
var conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
IConsole console;
if (conf.ExternalConsole)
console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
else
console = context.ConsoleFactory.CreateConsole(true);
var operationMonitor = new AggregatedOperationMonitor(monitor);
var sr = new StringBuilder("run");
Instance.BuildCommonArgAppendix(sr, prj, configuration);
try
{
var cmd = new NativeExecutionCommand(Instance.DubExecutable, sr.ToString(), prj.BaseDirectory.ToString());
if (!context.ExecutionHandler.CanExecute(cmd))
{
monitor.ReportError("Cannot execute \"" + "\". The selected execution mode is not supported for Dub projects.", null);
return;
}
var op = context.ExecutionHandler.Execute(cmd, console);
operationMonitor.AddOperation(op);
op.WaitForCompleted();
monitor.Log.WriteLine(Instance.DubExecutable+" exited with code: {0}", op.ExitCode);
}
catch (Exception ex)
{
monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
}
finally
{
operationMonitor.Dispose();
console.Dispose();
}
}
示例9: BuildSolutionItemAsync
void BuildSolutionItemAsync (IBuildTarget entry, IProgressMonitor monitor, ITimeTracker tt, bool skipPrebuildCheck = false, ProjectOperationContext context = null)
{
BuildResult result = null;
try {
if (!skipPrebuildCheck) {
tt.Trace ("Pre-build operations");
result = DoBeforeCompileAction ();
}
//wait for any custom tools that were triggered by the save, since the build may depend on them
MonoDevelop.Ide.CustomTools.CustomToolService.WaitForRunningTools (monitor);
if (skipPrebuildCheck || result.ErrorCount == 0) {
tt.Trace ("Building item");
SolutionItem it = entry as SolutionItem;
if (it != null)
result = it.Build (monitor, IdeApp.Workspace.ActiveConfiguration, true, context);
else if (entry is WorkspaceItem)
result = ((WorkspaceItem)entry).Build (monitor, IdeApp.Workspace.ActiveConfiguration, context);
else
result = entry.RunTarget (monitor, ProjectService.BuildTarget, IdeApp.Workspace.ActiveConfiguration);
}
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Build failed."), ex);
if (result == null)
result = new BuildResult ();
result.AddError ("Build failed. See the build log for details.");
if (result.SourceTarget == null)
result.SourceTarget = entry;
} finally {
tt.Trace ("Done building");
}
DispatchService.GuiDispatch (
delegate {
BuildDone (monitor, result, entry, tt); // BuildDone disposes the monitor
});
}
示例10: Execute
protected override void Execute (IProgressMonitor monitor, SolutionEntityItem entry, ExecutionContext context, ConfigurationSelector configuration)
{
Project project = entry as Project;
if (project == null) {
base.Execute (monitor, entry, context, configuration);
return;
}
MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.ExecuteTargetName)) {
base.Execute (monitor, entry, context, configuration);
return;
}
IConsole console = context.ConsoleFactory.CreateConsole (true);
monitor.BeginTask (GettextCatalog.GetString ("Executing {0}", project.Name), 1);
try
{
ProcessWrapper process = Runtime.ProcessService.StartProcess (data.AbsoluteMakeCommand,
data.ExecuteTargetName,
project.BaseDirectory,
console.Out,
console.Error,
null);
process.WaitForOutput ();
monitor.Log.WriteLine (GettextCatalog.GetString ("The application exited with code: {0}", process.ExitCode));
monitor.Step (1);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Project could not be executed: "), e);
return;
} finally {
monitor.EndTask ();
console.Dispose ();
}
}
示例11: Clean
protected override void Clean (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
{
Project proj = entry as Project;
if (proj == null) {
base.Clean (monitor, entry, configuration);
return;
}
MakefileData data = proj.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.CleanTargetName)) {
base.Clean (monitor, entry, configuration);
return;
}
monitor.BeginTask (GettextCatalog.GetString ("Cleaning project"), 1);
try {
string baseDir = proj.BaseDirectory;
ProcessWrapper process = Runtime.ProcessService.StartProcess (data.AbsoluteMakeCommand,
data.CleanTargetName,
baseDir,
monitor.Log,
monitor.Log,
null);
process.WaitForOutput ();
if (process.ExitCode > 0)
throw new Exception ( GettextCatalog.GetString ("An unspecified error occurred while running '{0} {1}'", data.AbsoluteMakeCommand, data.CleanTargetName) );
monitor.Step (1);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Project could not be cleaned: "), e);
return;
} finally {
monitor.EndTask ();
}
monitor.ReportSuccess (GettextCatalog.GetString ("Project successfully cleaned"));
}
示例12: Build
//FIXME: Check whether autogen.sh is required or not
protected override BuildResult Build (IProgressMonitor monitor, SolutionEntityItem entry, ConfigurationSelector configuration)
{
Project project = entry as Project;
if (project == null)
return base.Build (monitor, entry, configuration);
MakefileData data = project.ExtendedProperties ["MonoDevelop.Autotools.MakefileInfo"] as MakefileData;
if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.BuildTargetName))
return base.Build (monitor, entry, configuration);
//FIXME: Gen autofoo ? autoreconf?
string output = String.Empty;
int exitCode = 0;
monitor.BeginTask (GettextCatalog.GetString ("Building {0}", project.Name), 1);
try {
string baseDir = project.BaseDirectory;
StringBuilder args = new StringBuilder ();
if (data.RelativeMakeCommand.EndsWith ("make", StringComparison.OrdinalIgnoreCase))
args.AppendFormat (" -j {0}", data.ParallelProcesses, data.BuildTargetName);
args.AppendFormat (" {0}", data.BuildTargetName);
StringWriter swOutput = new StringWriter ();
LogTextWriter chainedOutput = new LogTextWriter ();
chainedOutput.ChainWriter (monitor.Log);
chainedOutput.ChainWriter (swOutput);
ProcessWrapper process = Runtime.ProcessService.StartProcess (data.AbsoluteMakeCommand,
args.ToString (),
baseDir,
chainedOutput,
chainedOutput,
null);
process.WaitForOutput ();
exitCode = process.ExitCode;
output = swOutput.ToString ();
chainedOutput.Close ();
swOutput.Close ();
monitor.Step (1);
} catch (Exception e) {
monitor.ReportError (GettextCatalog.GetString ("Project could not be built: "), e);
return null;
} finally {
monitor.EndTask ();
}
TempFileCollection tf = new TempFileCollection ();
Regex regexError = data.GetErrorRegex (false);
Regex regexWarning = data.GetWarningRegex (false);
BuildResult cr = ParseOutput (tf, output, project.BaseDirectory, regexError, regexWarning);
if (exitCode != 0 && cr.FailedBuildCount == 0)
cr.AddError (GettextCatalog.GetString ("Build failed. See Build Output panel."));
else
entry.SetNeedsBuilding (false, configuration);
return cr;
}
示例13: ExecuteSolutionItemAsync
void ExecuteSolutionItemAsync (IProgressMonitor monitor, IBuildTarget entry, ExecutionContext context)
{
try {
OnBeforeStartProject ();
entry.Execute (monitor, context, IdeApp.Workspace.ActiveConfiguration);
} catch (Exception ex) {
monitor.ReportError (GettextCatalog.GetString ("Execution failed."), ex);
LoggingService.LogError ("Execution failed", ex);
} finally {
monitor.Dispose ();
}
}
示例14: CopyFiles
bool CopyFiles (IProgressMonitor monitor, IWorkspaceFileObject obj, IEnumerable<FilePath> files, FilePath targetBasePath, bool ignoreExternalFiles)
{
FilePath baseDir = obj.BaseDirectory.FullPath;
foreach (FilePath file in files) {
if (!File.Exists (file)) {
monitor.ReportWarning (GettextCatalog.GetString ("File '{0}' not found.", file));
continue;
}
FilePath fname = file.FullPath;
// Can't export files from outside the root solution directory
if (!fname.IsChildPathOf (baseDir)) {
if (ignoreExternalFiles)
continue;
if (obj is Solution)
monitor.ReportError ("The solution '" + obj.Name + "' is referencing the file '" + Path.GetFileName (file) + "' which is located outside the root solution directory.", null);
else
monitor.ReportError ("The project '" + obj.Name + "' is referencing the file '" + Path.GetFileName (file) + "' which is located outside the project directory.", null);
return false;
}
FilePath rpath = fname.ToRelative (baseDir);
rpath = rpath.ToAbsolute (targetBasePath);
if (!Directory.Exists (rpath.ParentDirectory))
Directory.CreateDirectory (rpath.ParentDirectory);
File.Copy (file, rpath, true);
}
return true;
}
示例15: BuildDone
void BuildDone (IProgressMonitor monitor, BuildResult result, IBuildTarget entry, ITimeTracker tt)
{
Task[] tasks = null;
tt.Trace ("Begin reporting build result");
try {
if (result != null) {
lastResult = result;
monitor.Log.WriteLine ();
monitor.Log.WriteLine (GettextCatalog.GetString ("---------------------- Done ----------------------"));
tt.Trace ("Updating task service");
tasks = new Task [result.Errors.Count];
for (int n=0; n<tasks.Length; n++) {
tasks [n] = new Task (result.Errors [n]);
tasks [n].Owner = this;
}
TaskService.Errors.AddRange (tasks);
TaskService.Errors.ResetLocationList ();
IdeApp.Workbench.ActiveLocationList = TaskService.Errors;
tt.Trace ("Reporting result");
string errorString = GettextCatalog.GetPluralString("{0} error", "{0} errors", result.ErrorCount, result.ErrorCount);
string warningString = GettextCatalog.GetPluralString("{0} warning", "{0} warnings", result.WarningCount, result.WarningCount);
if (result.ErrorCount == 0 && result.WarningCount == 0 && lastResult.FailedBuildCount == 0) {
monitor.ReportSuccess (GettextCatalog.GetString ("Build successful."));
} else if (result.ErrorCount == 0 && result.WarningCount > 0) {
monitor.ReportWarning(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString);
} else if (result.ErrorCount > 0) {
monitor.ReportError(GettextCatalog.GetString("Build: ") + errorString + ", " + warningString, null);
} else {
monitor.ReportError(GettextCatalog.GetString("Build failed."), null);
}
tt.Trace ("End build event");
OnEndBuild (monitor, lastResult.FailedBuildCount == 0, lastResult, entry as SolutionItem);
} else {
tt.Trace ("End build event");
OnEndBuild (monitor, false);
}
tt.Trace ("Showing results pad");
try {
Pad errorsPad = IdeApp.Workbench.GetPad<MonoDevelop.Ide.Gui.Pads.ErrorListPad> ();
switch (IdeApp.Preferences.ShowErrorPadAfterBuild) {
case BuildResultStates.Always:
if (!errorsPad.Visible)
errorsPad.IsOpenedAutomatically = true;
errorsPad.Visible = true;
errorsPad.BringToFront ();
break;
case BuildResultStates.Never:
break;
case BuildResultStates.OnErrors:
if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error))
goto case BuildResultStates.Always;
goto case BuildResultStates.Never;
case BuildResultStates.OnErrorsOrWarnings:
if (TaskService.Errors.Any (task => task.Severity == TaskSeverity.Error || task.Severity == TaskSeverity.Warning))
goto case BuildResultStates.Always;
goto case BuildResultStates.Never;
}
} catch {}
if (tasks != null) {
Task jumpTask = null;
switch (IdeApp.Preferences.JumpToFirstErrorOrWarning) {
case JumpToFirst.Error:
jumpTask = tasks.FirstOrDefault (t => t.Severity == TaskSeverity.Error && TaskStore.IsProjectTaskFile (t));
break;
case JumpToFirst.ErrorOrWarning:
jumpTask = tasks.FirstOrDefault (t => (t.Severity == TaskSeverity.Error || t.Severity == TaskSeverity.Warning) && TaskStore.IsProjectTaskFile (t));
break;
}
if (jumpTask != null) {
tt.Trace ("Jumping to first result position");
jumpTask.JumpToPosition ();
}
}
} finally {
monitor.Dispose ();
tt.End ();
}
}