Hi All,
I've made a quick patch to add a clean action to the solution task.
Basically it will remove all the primary output files. I would like some
feedback on this.
solution solutionfile=WindowsApplication.sln configuration=debug
action=Clean
/solution
Cheers,
Eddie
? patch.txt
Index: ConfigurationSettings.cs
===
RCS file: /cvsroot/nant/nant/src/NAnt.VSNet/ConfigurationSettings.cs,v
retrieving revision 1.10
diff -u -r1.10 ConfigurationSettings.cs
--- ConfigurationSettings.cs27 Aug 2003 16:55:10 - 1.10
+++ ConfigurationSettings.cs6 Sep 2003 14:27:04 -
@@ -19,6 +19,7 @@
using System.Globalization;
using System.IO;
using System.Collections;
+using System.Collections.Specialized;
using System.Xml;
using NAnt.Core;
@@ -66,6 +67,13 @@
Directory.CreateDirectory(Path.GetDirectoryName(_docFilename));
}
+string debugValue;
+if (!StringUtils.IsNullOrEmpty(debugValue =
elemConfig.GetAttribute(DebugSymbols))) {
+if (debugValue == true) {
+_pdbFilename = Path.Combine(_outputPath,
this._projectSettings.Name + .pdb);
+}
+}
+
_solutionTask.Log(Level.Debug, _solutionTask.LogPrefix + Project: {0}
Relative Output Path: {1} Output Path: {2} Documentation Path: {3},
projectSettings.Name, _relativeOutputPath, _outputPath, _docFilename);
@@ -115,11 +123,19 @@
public string[] ExtraOutputFiles {
get {
-if (_docFilename == null) {
-return new string[0];
+StringCollection extraFiles = new StringCollection();
+
+if (_docFilename != null) {
+extraFiles.Add(_docFilename);
+}
+
+if (_pdbFilename != null) {
+extraFiles.Add(_pdbFilename);
}
-return new string[] {_docFilename};
+string[] extraFilesArray = new string[extraFiles.Count];
+extraFiles.CopyTo(extraFilesArray, 0);
+return extraFilesArray;
}
}
@@ -149,6 +165,7 @@
private ArrayList _settings;
private string _docFilename;
+private string _pdbFilename;
private string _relativeOutputPath;
private string _outputPath;
private string _name;
Index: Project.cs
===
RCS file: /cvsroot/nant/nant/src/NAnt.VSNet/Project.cs,v
retrieving revision 1.17
diff -u -r1.17 Project.cs
--- Project.cs 2 Sep 2003 18:52:29 - 1.17
+++ Project.cs 6 Sep 2003 14:27:06 -
@@ -234,6 +234,34 @@
}
}
+public bool Clean(string configuration) {
+ConfigurationSettings cs = (ConfigurationSettings)
_htConfigurations[configuration];
+if (cs == null) {
+Log(Level.Info, _solutionTask.LogPrefix + Configuration {0} does not
exist, skipping., configuration);
+return true;
+}
+
+// Setup delete task
+DeleteTask dt = new DeleteTask();
+dt.InitializeTaskConfiguration();
+dt.Project = this._solutionTask.Project;
+dt.FailOnError = false;
+dt.Verbose = this._solutionTask.Verbose;
+
+// Clean primary output
+dt.DeleteFileSet.FileNames.Add(cs.FullOutputFile);
+
+// Clean extra output
+foreach (string file in cs.ExtraOutputFiles) {
+dt.DeleteFileSet.FileNames.Add(file);
+}
+
+// Execute delete task
+dt.Execute();
+
+return true;
+}
+
public bool Compile(string configuration, ArrayList alCSCArguments, string
strLogFile, bool bVerbose, bool bShowCommands) {
bool bSuccess = true;
Index: Solution.cs
===
RCS file: /cvsroot/nant/nant/src/NAnt.VSNet/Solution.cs,v
retrieving revision 1.13
diff -u -r1.13 Solution.cs
--- Solution.cs 2 Sep 2003 19:01:33 - 1.13
+++ Solution.cs 6 Sep 2003 14:27:08 -
@@ -49,13 +49,13 @@
string fileContents;
-using (StreamReader sr = new StreamReader(solutionFileName)) {
+using (StreamReader sr = new StreamReader(_solutionTask.SolutionFile)) {
fileContents = sr.ReadToEnd();
}
Regex re = new
Regex(@Project\(\(?package\{.*?\})\.*?\(?name.*?)\.*?\(?project.*?)\.*?\(?guid.*?)\);
MatchCollection mc = re.Matches(fileContents);
-FileInfo fiSolution = new FileInfo(solutionFileName);
+FileInfo fiSolution = new FileInfo(_solutionTask.SolutionFile);
foreach (Match m in mc) {
string project = m.Groups[project].Value;
@@ -181,6