Browse Source

Fixed SD2-1134. A user friendly error message is now shown if the NAnt executable cannot be found or the path specified is invalid.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1853 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 19 years ago
parent
commit
ce3eec7604
  1. BIN
      data/resources/StringResources.es-mx.resources
  2. BIN
      data/resources/StringResources.es.resources
  3. BIN
      data/resources/StringResources.it.resources
  4. BIN
      data/resources/StringResources.nl.resources
  5. 14
      src/AddIns/Misc/NAntAddIn/NAntAddIn.sln
  6. 34
      src/AddIns/Misc/NAntAddIn/Project/Src/AddInOptions.cs
  7. 32
      src/AddIns/Misc/NAntAddIn/Project/Src/Commands/AbstractRunNAntCommand.cs
  8. 15
      src/Main/Base/Project/Src/Util/ProcessRunner.cs
  9. BIN
      src/Main/StartUp/Project/Resources/StringResources.resources

BIN
data/resources/StringResources.es-mx.resources

Binary file not shown.

BIN
data/resources/StringResources.es.resources

Binary file not shown.

BIN
data/resources/StringResources.it.resources

Binary file not shown.

BIN
data/resources/StringResources.nl.resources

Binary file not shown.

14
src/AddIns/Misc/NAntAddIn/NAntAddIn.sln

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.646
# SharpDevelop 2.1.0.1782
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAntAddIn", "Project\NAntAddIn.csproj", "{1DB3CAD2-38E8-4C5E-8E1B-0E37B1A5C006}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAntAddIn.Tests", "Test\NAntAddIn.Tests.csproj", "{13AB8351-39E5-4F9D-A59C-B30D60CF6B8C}"
@ -14,6 +14,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "..\..\..\Libr @@ -14,6 +14,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "..\..\..\Libr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "..\..\..\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -48,5 +52,13 @@ Global @@ -48,5 +52,13 @@ Global
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.Build.0 = Release|Any CPU
{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.Build.0 = Release|Any CPU
{80318B5F-A25D-45AB-8A95-EF31D2370A4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU
{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

34
src/AddIns/Misc/NAntAddIn/Project/Src/AddInOptions.cs

@ -58,26 +58,26 @@ namespace ICSharpCode.NAntAddIn @@ -58,26 +58,26 @@ namespace ICSharpCode.NAntAddIn
/// or just the name of the executable (nant.exe) in which
/// case it is assumed that NAnt is on the path.
/// </remarks>
public static string NAntFileName
{
public static string NAntFileName {
get {
return (string)Properties.Get(NAntFileNameProperty, DefaultNAntFileName);
}
set {
Properties.Set(NAntFileNameProperty, value);
if (String.IsNullOrEmpty(value)) {
Properties.Set(NAntFileNameProperty, DefaultNAntFileName);
} else {
Properties.Set(NAntFileNameProperty, value);
}
}
}
/// <summary>
/// Gets the NAnt command line arguments.
/// </summary>
public static string NAntArguments
{
public static string NAntArguments {
get {
return (string)Properties.Get(NAntArgumentsProperty, String.Empty);
}
set {
Properties.Set(NAntArgumentsProperty, value);
}
@ -86,12 +86,10 @@ namespace ICSharpCode.NAntAddIn @@ -86,12 +86,10 @@ namespace ICSharpCode.NAntAddIn
/// <summary>
/// Gets the NAnt -verbose setting.
/// </summary>
public static bool Verbose
{
public static bool Verbose {
get {
return (bool)Properties.Get(VerboseProperty, false);
}
}
set {
Properties.Set(VerboseProperty, value);
}
@ -100,12 +98,10 @@ namespace ICSharpCode.NAntAddIn @@ -100,12 +98,10 @@ namespace ICSharpCode.NAntAddIn
/// <summary>
/// Gets the NAnt show logo setting.
/// </summary>
public static bool ShowLogo
{
public static bool ShowLogo {
get {
return (bool)Properties.Get(ShowLogoProperty, false);
}
}
set {
Properties.Set(ShowLogoProperty, value);
}
@ -114,12 +110,10 @@ namespace ICSharpCode.NAntAddIn @@ -114,12 +110,10 @@ namespace ICSharpCode.NAntAddIn
/// <summary>
/// Gets the NAnt -quiet setting.
/// </summary>
public static bool Quiet
{
public static bool Quiet {
get {
return (bool)Properties.Get(QuietProperty, false);
}
set {
Properties.Set(QuietProperty, value);
}
@ -128,12 +122,10 @@ namespace ICSharpCode.NAntAddIn @@ -128,12 +122,10 @@ namespace ICSharpCode.NAntAddIn
/// <summary>
/// Gets the NAnt -debug setting.
/// </summary>
public static bool DebugMode
{
public static bool DebugMode {
get {
return (bool)Properties.Get(DebugModeProperty, false);
}
set {
Properties.Set(DebugModeProperty, value);
}

32
src/AddIns/Misc/NAntAddIn/Project/Src/Commands/AbstractRunNAntCommand.cs

@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Gui; @@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Util;
using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
@ -33,6 +34,9 @@ namespace ICSharpCode.NAntAddIn.Commands @@ -33,6 +34,9 @@ namespace ICSharpCode.NAntAddIn.Commands
/// </summary>
public static readonly string NAntBuildFileExtension = ".build";
const int Win32FileNotFoundErrorCode = 2;
const int Win32PathNotFoundErrorCode = 3;
static MessageViewCategory category;
static NAntRunner runner;
@ -173,13 +177,20 @@ namespace ICSharpCode.NAntAddIn.Commands @@ -173,13 +177,20 @@ namespace ICSharpCode.NAntAddIn.Commands
CategoryWriteLine(StringParser.Parse("${res:ICSharpCode.NAntAddIn.AbstractRunNAntCommand.RunningNAntMessage}"));
CategoryWriteLine(runner.CommandLine);
runner.Start();
try {
runner.Start();
} catch (Win32Exception ex) {
if (ex.NativeErrorCode == Win32FileNotFoundErrorCode || ex.NativeErrorCode == Win32PathNotFoundErrorCode) {
throw new NAntAddInException(GetNAntNotFoundErrorMessage(AddInOptions.NAntFileName), ex);
} else {
throw;
}
}
}
/// <summary>
/// Gets any extra arguments from the NAnt pad's text box.
/// </summary>
/// <returns></returns>
protected string GetPadTextBoxArguments()
{
string arguments = String.Empty;
@ -231,7 +242,6 @@ namespace ICSharpCode.NAntAddIn.Commands @@ -231,7 +242,6 @@ namespace ICSharpCode.NAntAddIn.Commands
/// <summary>
/// Writes a line of text to the output window.
/// </summary>
/// <param name="message"></param>
void CategoryWriteLine(string message)
{
Category.AppendText(String.Concat(message, Environment.NewLine));
@ -254,19 +264,13 @@ namespace ICSharpCode.NAntAddIn.Commands @@ -254,19 +264,13 @@ namespace ICSharpCode.NAntAddIn.Commands
/// or null.</returns>
ProjectItem GetFirstMatchingFile(IProject project, string extension)
{
ProjectItem matchedProjectItem = null;
foreach (ProjectItem projectItem in project.Items) {
string projectFileNameExtension = Path.GetExtension(projectItem.FileName);
if (String.Compare(projectFileNameExtension, extension, true) == 0) {
matchedProjectItem = projectItem;
break;
return projectItem;
}
}
return matchedProjectItem;
return null;
}
/// <summary>
@ -303,5 +307,11 @@ namespace ICSharpCode.NAntAddIn.Commands @@ -303,5 +307,11 @@ namespace ICSharpCode.NAntAddIn.Commands
{
CategoryWriteLine(e.Line);
}
string GetNAntNotFoundErrorMessage(string fileName)
{
string formatString = StringParser.Parse("${res:ICSharpCode.NAntAddIn.AbstractRunNAntCommand.NAntExeNotFoundMessage}");
return String.Format(formatString, fileName);
}
}
}

15
src/Main/Base/Project/Src/Util/ProcessRunner.cs

@ -166,11 +166,20 @@ namespace ICSharpCode.SharpDevelop.Util @@ -166,11 +166,20 @@ namespace ICSharpCode.SharpDevelop.Util
if (ProcessExited != null) {
process.EnableRaisingEvents = true;
process.Exited += new EventHandler(OnProcessExited);
process.Exited += OnProcessExited;
}
process.Start();
bool started = false;
try {
process.Start();
started = true;
} finally {
if (!started) {
process.Exited -= OnProcessExited;
process = null;
}
}
standardOutputReader = new OutputReader(process.StandardOutput);
if (OutputLineReceived != null) {
standardOutputReader.LineReceived += new LineReceivedEventHandler(OnOutputLineReceived);

BIN
src/Main/StartUp/Project/Resources/StringResources.resources

Binary file not shown.
Loading…
Cancel
Save