本文整理汇总了C#中MonoDevelop.Projects.BuildResult.AddError方法的典型用法代码示例。如果您正苦于以下问题:C# BuildResult.AddError方法的具体用法?C# BuildResult.AddError怎么用?C# BuildResult.AddError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonoDevelop.Projects.BuildResult
的用法示例。
在下文中一共展示了BuildResult.AddError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateDesignerFile
public static BuildResult UpdateDesignerFile (
CodeBehindWriter writer,
DotNetProject project,
ProjectFile file, ProjectFile designerFile
)
{
var result = new BuildResult ();
//parse the ASP.NET file
var parsedDocument = TypeSystemService.ParseFile (project, file.FilePath).Result as WebFormsParsedDocument;
if (parsedDocument == null) {
result.AddError (string.Format ("Failed to parse file '{0}'", file.Name));
return result;
}
//TODO: ensure type system is up to date
CodeCompileUnit ccu;
result.Append (GenerateCodeBehind (project, designerFile.FilePath, parsedDocument, out ccu));
if (ccu != null) {
writer.WriteFile (designerFile.FilePath, ccu);
}
return result;
}
示例2: CompileXibFiles
public static BuildResult CompileXibFiles (IProgressMonitor monitor, IEnumerable<ProjectFile> files,
FilePath outputRoot)
{
var result = new BuildResult ();
var ibfiles = GetIBFilePairs (files, outputRoot).Where (NeedsBuilding).ToList ();
if (ibfiles.Count > 0) {
monitor.BeginTask (GettextCatalog.GetString ("Compiling interface definitions"), 0);
foreach (var file in ibfiles) {
file.EnsureOutputDirectory ();
var args = new ProcessArgumentBuilder ();
args.AddQuoted (file.Input);
args.Add ("--compile");
args.AddQuoted (file.Output);
var psi = new ProcessStartInfo ("ibtool", args.ToString ());
monitor.Log.WriteLine (psi.FileName + " " + psi.Arguments);
psi.WorkingDirectory = outputRoot;
string errorOutput;
int code;
try {
code = ExecuteCommand (monitor, psi, out errorOutput);
} catch (System.ComponentModel.Win32Exception ex) {
LoggingService.LogError ("Error running ibtool", ex);
result.AddError (null, 0, 0, null, "ibtool not found. Please ensure the Apple SDK is installed.");
return result;
}
if (code != 0) {
//FIXME: parse the plist that ibtool returns
result.AddError (null, 0, 0, null, "ibtool returned error code " + code);
}
}
monitor.EndTask ();
}
return result;
}
示例3: OnBuild
protected override BuildResult OnBuild (MonoDevelop.Core.IProgressMonitor monitor, ConfigurationSelector configuration)
{
var restResult = RestClient.CompileScripts ();
var result = new BuildResult ();
foreach (var message in restResult.Messages)
{
var file = BaseDirectory + "/" + message.File;
var msg = message.Message;
var errorNum = "";
var messageStrings = message.Message.Split(':');
if (messageStrings.Length == 3)
{
var errorNumStrings = messageStrings[1].Split(' ');
if (errorNumStrings.Length > 1)
errorNum = errorNumStrings[errorNumStrings.Length - 1];
msg = messageStrings[2];
}
if(message.Type == "warning")
result.AddWarning(file, message.Line, message.Column, errorNum, msg);
else
result.AddError(file, message.Line, message.Column, errorNum, msg);
}
return result;
}
示例4: WaitForRestoreThenBuild
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);
}
示例5: HandleReturnCode
/// <summary>
/// Checks a compilation return code,
/// and adds an error result if the compiler results
/// show no errors.
/// </summary>
/// <param name="monitor"></param>
/// <param name="br"> A <see cref="BuildResult"/>: The return code from a build run.</param>
/// <param name="returnCode">A <see cref="System.Int32"/>: A process return code.</param>
public static bool HandleReturnCode(IProgressMonitor monitor, BuildResult br, int returnCode)
{
if (returnCode != 0)
{
if (monitor != null)
monitor.Log.WriteLine("Exit code " + returnCode.ToString());
if(br.ErrorCount == 0)
br.AddError(string.Empty, 0, 0, string.Empty,
GettextCatalog.GetString("Build failed - check build output for details"));
return false;
}
return true;
}
示例6: Build
protected override BuildResult Build (IProgressMonitor monitor, IBuildTarget item, ConfigurationSelector configuration)
{
if (!(item is MonoDroidProject))
return base.Build (monitor, item, configuration);
MonoDroidProject project = (MonoDroidProject) item;
TargetFramework requiredFramework = Runtime.SystemAssemblyService.GetTargetFramework ("4.0");
// Check that we support 4.0 to infer we are at Mono 2.8 at least.
if (!project.TargetRuntime.IsInstalled (requiredFramework)) {
var message = "Mono 2.8 or newer is required.";
MessageService.GenericAlert (MonoDevelop.Ide.Gui.Stock.MonoDevelop, message,
"Mono 2.8 or newer is requiered. Please go to http://www.mono-project.com to update your installation.",
AlertButton.Ok);
var buildResult = new BuildResult ();
buildResult.AddError (message);
return buildResult;
}
return base.Build (monitor, item, configuration);
}
示例7: OnBuild
protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration, OperationContext operationContext)
{
if (Project.References.Count == 0 || !GtkDesignInfo.HasDesignedObjects (Project))
return await base.OnBuild (monitor, configuration, operationContext);
Generator gen = new Generator ();
if (!await gen.Run (monitor, Project, configuration)) {
BuildResult gr = new BuildResult ();
foreach (string s in gen.Messages)
gr.AddError (DesignInfo.GuiBuilderProject.File, 0, 0, null, s);
return gr;
}
BuildResult res = await base.OnBuild (monitor, configuration, operationContext);
if (gen.Messages != null) {
foreach (string s in gen.Messages)
res.AddWarning (DesignInfo.GuiBuilderProject.File, 0, 0, null, s);
if (gen.Messages.Length > 0)
DesignInfo.ForceCodeGenerationOnBuild ();
}
if (res.Failed && !Platform.IsWindows && !Platform.IsMac) {
// Some gtk# packages don't include the .pc file unless you install gtk-sharp-devel
if (Project.AssemblyContext.GetPackage ("gtk-sharp-2.0") == null) {
string msg = GettextCatalog.GetString (
"ERROR: MonoDevelop could not find the Gtk# 2.0 development package. " +
"Compilation of projects depending on Gtk# libraries will fail. " +
"You may need to install development packages for gtk-sharp-2.0.");
monitor.Log.WriteLine ();
monitor.Log.WriteLine (BrandingService.BrandApplicationName (msg));
}
}
return res;
}
示例8: OnBuild
protected override BuildResult OnBuild (IProgressMonitor monitor, ConfigurationSelector configuration)
{
BuildResult res = new BuildResult ();
res.AddError ("Unknown project type");
return res;
}
示例9: CompileResourceScript
bool CompileResourceScript(BuildResult targetBuildResult, ProjectFile f)
{
var res = GetRelativeObjectFileName (BuildConfig.ObjectDirectory, f, ".res");
// Build argument string
var resCmpArgs = FillInMacros (Win32ResourceCompiler.Instance.Arguments,
new Win32ResourceCompiler.ArgProvider
{
RcFile = f.FilePath,
ResFile = res
},commonMacros);
// Execute compiler
string output;
string stdOutput;
int _exitCode = ExecuteCommand (Win32ResourceCompiler.Instance.Executable,
resCmpArgs,
Project.BaseDirectory,
monitor,
out output,
out stdOutput);
// Error analysis
if (!string.IsNullOrEmpty (output))
targetBuildResult.AddError (f.FilePath, 0, 0, "", output);
if (!string.IsNullOrEmpty (stdOutput))
targetBuildResult.AddError (f.FilePath, 0, 0, "", stdOutput);
HandleReturnCode (targetBuildResult, Win32ResourceCompiler.Instance.Executable, _exitCode);
if (_exitCode != 0) {
targetBuildResult.FailedBuildCount++;
return false;
} else {
f.LastGenOutput = res;
targetBuildResult.BuildCount++;
Project.LastModificationTimes [f] = File.GetLastWriteTime (f.FilePath);
BuiltObjects.Add (MakeRelativeToPrjBase (res));
return true;
}
}
示例10: HandleReturnCode
/// <summary>
/// Checks a compilation return code,
/// and adds an error result if the compiler results
/// show no errors.
/// </summary>
/// <param name="returnCode">
/// A <see cref="System.Int32"/>: A process return code
/// </param>
/// <param name="cr">
/// A <see cref="CompilerResults"/>: The return code from a compilation run
/// </param>
void HandleReturnCode(BuildResult br, string executable, int returnCode)
{
if (returnCode != 0) {
if (monitor != null)
monitor.Log.WriteLine ("Exit code " + returnCode.ToString ());
br.AddError (string.Empty, 0, 0, string.Empty,
GettextCatalog.GetString ("Build failed - check build output for details"));
}
}
示例11: GetTool
public static ProcessStartInfo GetTool (string tool, DotNetProject project, IProgressMonitor monitor,
out BuildResult error)
{
var toolPath = project.TargetRuntime.GetToolPath (project.TargetFramework, tool);
if (String.IsNullOrEmpty (toolPath)) {
var err = GettextCatalog.GetString ("Error: Unable to find '" + tool + "' tool.");
monitor.ReportError (err, null);
error = new BuildResult ();
error.AddError (null, 0, 0, null, err);
return null;
}
error = null;
return new ProcessStartInfo (toolPath) {
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
};
}
示例12: Build
/// <summary>
/// Compiles a D project.
/// </summary>
public BuildResult Build(DProject Project, ConfigurationSelector BuildConfigurationSelector)
{
this.Project = Project;
BuildConfig = Project.GetConfiguration (BuildConfigurationSelector) as DProjectConfiguration;
commonMacros = new PrjPathMacroProvider {
slnPath = Project.ParentSolution.BaseDirectory
};
BuiltObjects.Clear ();
if (Compiler == null) {
var targetBuildResult = new BuildResult ();
targetBuildResult.AddError ("Project compiler \"" + Project.UsedCompilerVendor + "\" not found");
targetBuildResult.FailedBuildCount++;
return targetBuildResult;
}
if (Path.IsPathRooted (BuildConfig.ObjectDirectory))
AbsoluteObjectDirectory = BuildConfig.ObjectDirectory;
else
AbsoluteObjectDirectory = Path.Combine (Project.BaseDirectory, EnsureCorrectPathSeparators (BuildConfig.ObjectDirectory));
if (!Directory.Exists (AbsoluteObjectDirectory))
Directory.CreateDirectory (AbsoluteObjectDirectory);
if (CanDoOneStepBuild)
return DoOneStepBuild ();
else
return DoStepByStepBuild ();
}
示例13: PromptForSave
// Note: This must run in the main thread
void PromptForSave (BuildResult result)
{
var couldNotSaveError = "The build has been aborted as the file '{0}' could not be saved";
foreach (var doc in IdeApp.Workbench.Documents) {
if (doc.IsDirty && doc.Project != null) {
if (MessageService.AskQuestion (GettextCatalog.GetString ("Save changed documents before building?"),
GettextCatalog.GetString ("Some of the open documents have unsaved changes."),
AlertButton.BuildWithoutSave, AlertButton.Save) == AlertButton.Save) {
MarkFileDirty (doc.FileName);
doc.Save ();
if (doc.IsDirty)
result.AddError (string.Format (couldNotSaveError, Path.GetFileName (doc.FileName)), doc.FileName);
} else
break;
}
}
}
示例14: CompileXibFiles
public static BuildResult CompileXibFiles (IProgressMonitor monitor, IEnumerable<ProjectFile> files,
FilePath outputRoot)
{
var result = new BuildResult ();
var ibfiles = GetIBFilePairs (files, outputRoot).Where (NeedsBuilding).ToList ();
if (ibfiles.Count > 0) {
monitor.BeginTask (GettextCatalog.GetString ("Compiling interface definitions"), 0);
foreach (var file in ibfiles) {
file.EnsureOutputDirectory ();
var args = new ProcessArgumentBuilder ();
args.Add ("--errors", "--warnings", "--notices", "--output-format", "human-readable-text");
args.AddQuoted (file.Input);
args.Add ("--compile");
args.AddQuoted (file.Output);
var ibtoolPath = AppleSdkSettings.DeveloperRoot.Combine ("usr", "bin", "ibtool");
var psi = new ProcessStartInfo (ibtoolPath, args.ToString ());
monitor.Log.WriteLine (psi.FileName + " " + psi.Arguments);
int code;
try {
code = MacBuildUtilities.ExecuteBuildCommand (monitor, psi);
} catch (System.ComponentModel.Win32Exception ex) {
LoggingService.LogError ("Error running ibtool", ex);
result.AddError (null, 0, 0, null, "ibtool not found. Please ensure the Apple SDK is installed.");
return result;
}
if (monitor.IsCancelRequested)
return result;
if (code != 0) {
result.AddError (null, 0, 0, null, "ibtool returned error code " + code);
return result;
}
}
monitor.EndTask ();
}
return result;
}
示例15: Compile
public BuildResult Compile (ProjectItemCollection items, DotNetProjectConfiguration configuration, ConfigurationSelector configSelector, ProgressMonitor monitor)
{
VBCompilerParameters compilerparameters = (VBCompilerParameters) configuration.CompilationParameters;
if (compilerparameters == null)
compilerparameters = new VBCompilerParameters ();
var projectparameters = (VBProject) configuration.ParentItem;
string exe = configuration.CompiledOutputName;
string responseFileName = Path.GetTempFileName();
StreamWriter writer = new StreamWriter (responseFileName);
writer.WriteLine (GenerateOptions (configuration, compilerparameters, projectparameters, exe));
// Write references
foreach (ProjectReference lib in items.GetAll<ProjectReference> ()) {
foreach (string fileName in lib.GetReferencedFileNames (configSelector)) {
writer.Write ("\"-r:");
writer.Write (fileName);
writer.WriteLine ("\"");
}
}
// Write source files and embedded resources
foreach (ProjectFile finfo in items.GetAll<ProjectFile> ()) {
if (finfo.Subtype != Subtype.Directory) {
switch (finfo.BuildAction) {
case "Compile":
writer.WriteLine("\"" + finfo.Name + "\"");
break;
case "EmbeddedResource":
string fname = finfo.Name;
if (String.Compare (Path.GetExtension (fname), ".resx", true) == 0)
fname = Path.ChangeExtension (fname, ".resources");
writer.WriteLine("\"-resource:{0},{1}\"", fname, finfo.ResourceId);
break;
default:
continue;
}
}
}
// Write source files and embedded resources
foreach (Import import in items.GetAll<Import> ()) {
writer.WriteLine ("-imports:{0}", import.Include);
}
TempFileCollection tf = new TempFileCollection ();
writer.Close();
string output = "";
string compilerName = configuration.TargetRuntime.GetToolPath (configuration.TargetFramework, "vbc");
if (compilerName == null) {
BuildResult res = new BuildResult ();
res.AddError (string.Format ("Visual Basic .NET compiler not found ({0})", configuration.TargetRuntime.DisplayName));
return res;
}
string workingDir = ".";
if (configuration.ParentItem != null)
workingDir = configuration.ParentItem.BaseDirectory;
int exitCode;
var envVars = configuration.TargetRuntime.GetToolsExecutionEnvironment (configuration.TargetFramework);
monitor.Log.WriteLine (Path.GetFileName (compilerName) + " " + string.Join (" ", File.ReadAllLines (responseFileName)));
exitCode = DoCompilation (compilerName, responseFileName, tf, workingDir, envVars, ref output);
monitor.Log.WriteLine (output);
BuildResult result = ParseOutput (tf, output);
if (result.Errors.Count == 0 && exitCode != 0) {
// Compilation failed, but no errors?
// Show everything the compiler said.
result.AddError (output);
}
FileService.DeleteFile (responseFileName);
if (configuration.CompileTarget != CompileTarget.Library) {
WriteManifestFile (exe);
}
return result;
}