In the 0.84 build there is a bug (keep forgeting to get an official patch) where the solution task will fail if the output assembly is read-only on the drive.

Normally you would think this is the desired behaviour but it is different that what VS.NET does. We actually rely on this bug to make our builds work.

here is how I patched it (on 0.84) (look for the ->)

File: Project.cs

public override bool Compile(string configuration, ArrayList alCSCArguments, string strLogFile, bool bVerbose, bool bShowCommands) {
bool bSuccess = true;


ConfigurationSettings cs = (ConfigurationSettings) _htConfigurations[configuration];
if (cs == null) {
Log(Level.Info, LogPrefix + "Configuration {0} does not exist. Skipping.", configuration);
return true;
}


Log(Level.Info, LogPrefix + "Building {0} [{1}]...", Name, configuration);
Directory.CreateDirectory(cs.OutputDir);


              // perform prebuild actions (for VS.NET 2003)
              if (ProjectSettings.RunPostBuildEvent != null) {
                  bSuccess = PreBuild(cs);
              }

              // ensure the temp dir exists
              Directory.CreateDirectory(TempFiles.BasePath);

string tempResponseFile = Path.Combine(TempFiles.BasePath, Project.CommandFile);

using (StreamWriter sw = File.CreateText(tempResponseFile)) {
if (CheckUpToDate(cs)) {
Log(Level.Verbose, LogPrefix + "Project is up-to-date.");
if (ProjectSettings.RunPostBuildEvent != null) {
PostBuild(cs, true, false);
}
return true;
}


                  foreach (string setting in alCSCArguments) {
                      sw.WriteLine(setting);
                  }

                  foreach (string setting in ProjectSettings.Settings) {
                      sw.WriteLine(setting);
                  }

                  foreach (string setting in cs.Settings) {
                      sw.WriteLine(setting);
                  }

                  if (_projectSettings.Type == ProjectType.VBNet) {
                      sw.WriteLine(_imports);
                  }

Log(Level.Verbose, LogPrefix + "Copying references:");
foreach (Reference reference in _htReferences.Values) {
Log(Level.Verbose, LogPrefix + " - " + reference.Name);


if (reference.CopyLocal) {
if (reference.IsCreated) {
string program, commandLine;
reference.GetCreationCommand(cs, out program, out commandLine);


Log(Level.Verbose, LogPrefix + program + " " + commandLine);
ProcessStartInfo psiRef = new ProcessStartInfo(program, commandLine);
psiRef.UseShellExecute = false;
psiRef.WorkingDirectory = cs.OutputDir;


try {
Process pRef = Process.Start(psiRef);
pRef.WaitForExit();
} catch (Win32Exception ex) {
throw new BuildException(string.Format("Unable to start process '{0}' with commandline '{1}'.", program, commandLine), ex);
}
} else {
StringCollection fromFilenames = reference.GetReferenceFiles(cs);


                              // create instance of Copy task
                              CopyTask ct = new CopyTask();

                              // inherit project from solution task
                              ct.Project = SolutionTask.Project;

                              // inherit parent from solution task
                              ct.Parent = SolutionTask.Parent;

                              // inherit verbose setting from solution task
                              ct.Verbose = SolutionTask.Verbose;

// make sure framework specific information is set
ct.InitializeTaskConfiguration();


                              // set parent of child elements
                              ct.CopyFileSet.Parent = ct;

// inherit project from solution task for child elements
ct.CopyFileSet.Project = SolutionTask.Project;


// set task properties
foreach (string file in fromFilenames) {
ct.CopyFileSet.Includes.Add(file);
}
ct.CopyFileSet.BaseDirectory = reference.GetBaseDirectory(cs);
ct.ToDirectory = cs.OutputDir;


                              ct.Project.Indent();
                              ct.Execute();
                              ct.Project.Unindent();
                          }
                      }
                      sw.WriteLine(reference.Setting);
                  }

if (_htResources.Count > 0) {
Log(Level.Verbose, LogPrefix + "Compiling resources:");
foreach (Resource resource in _htResources.Values) {
Log(Level.Verbose, LogPrefix + " - {0}", resource.InputFile);
resource.Compile(cs, bShowCommands);
sw.WriteLine(resource.Setting);
}
}


                  // add the files to compile
                  foreach (string file in _htFiles.Keys) {
                      sw.WriteLine(@"""" + file + @"""");
                  }
              }

if (bShowCommands) {
using (StreamReader sr = new StreamReader(tempResponseFile)) {
Console.WriteLine("Commands:");
Console.WriteLine(sr.ReadToEnd());
}
}


Log(Level.Verbose, LogPrefix + "Starting compiler...");
-> if (System.IO.File.Exists (cs.OutputPath)) {
-> System.IO.File.SetAttributes (cs.OutputPath , System.IO.FileAttributes.Normal );
-> }
->
ProcessStartInfo psi = null;
if (_projectSettings.Type == ProjectType.CSharp) {
psi = new ProcessStartInfo(Path.Combine(SolutionTask.Project.CurrentFramework.FrameworkDirectory.FullName, "csc.exe"), "@\"" + tempResponseFile + "\"");
}


if (_projectSettings.Type == ProjectType.VBNet) {
psi = new ProcessStartInfo(Path.Combine(SolutionTask.Project.CurrentFramework.FrameworkDirectory.FullName, "vbc.exe"), "@\"" + tempResponseFile + "\"");
}


              psi.UseShellExecute = false;
              psi.RedirectStandardOutput = true;
              psi.WorkingDirectory = _projectDirectory;

              Process p = Process.Start(psi);

if (strLogFile != null) {
using (StreamWriter sw = new StreamWriter(strLogFile, true)) {
sw.WriteLine("Configuration: {0}", configuration);
sw.WriteLine("");
while (true) {
string logContents = p.StandardOutput.ReadLine();
if (logContents == null) {
break;
}
sw.WriteLine(logContents);
}
}
} else {
SolutionTask.Project.Indent();
while (true) {
string logContents = p.StandardOutput.ReadLine();
if (logContents == null) {
break;
}
Log(Level.Info, " [compile] " + logContents);
}
SolutionTask.Project.Unindent();
}


              p.WaitForExit();

int exitCode = p.ExitCode;
Log(Level.Verbose, LogPrefix + "{0}! (exit code = {1})", (exitCode == 0) ? "Success" : "Failure", exitCode);


if (exitCode > 0) {
bSuccess = false;
} else {
if (_isWebProject) {
Log(Level.Verbose, LogPrefix + "Uploading output files...");
WebDavClient wdc = new WebDavClient(new Uri(_webProjectBaseUrl));
//wdc.DeleteFile( cs.FullOutputFile, cs.RelativeOutputPath.Replace(@"\", "/") + _ps.OutputFile );
wdc.UploadFile(cs.OutputPath, cs.RelativeOutputDir.Replace(@"\", "/") + _projectSettings.OutputFileName);
}


// Copy any extra files over
foreach (string extraOutputFile in cs.ExtraOutputFiles) {
FileInfo sourceFile = new FileInfo(extraOutputFile);
if (_isWebProject) {
WebDavClient wdc = new WebDavClient(new Uri(_webProjectBaseUrl));
wdc.UploadFile(extraOutputFile, cs.RelativeOutputDir.Replace(@"\", "/") + sourceFile.Name);
} else {
FileInfo destFile = new FileInfo(Path.Combine(cs.OutputDir, sourceFile.Name));


if (destFile.Exists) {
// only copy the file if the source file is more
// recent than the destination file
if (FileSet.FindMoreRecentLastWriteTime(sourceFile.FullName, destFile.LastWriteTime) == null) {
continue;
}


                              // make sure the destination file is writable
                              destFile.Attributes = FileAttributes.Normal;
                          }

// copy the file and overwrite the destination file
// if it already exists
sourceFile.CopyTo(destFile.FullName, true);
}
}
}


if (ProjectSettings.RunPostBuildEvent != null) {
if (!PostBuild(cs, (exitCode == 0) ? true : false, (exitCode == 0) ? true : false)) {
bSuccess = false;
}
}


              if (!bSuccess ) {
                  Log(Level.Error, LogPrefix + "Build failed.");
              }

              return bSuccess;
          }

public override string GetOutputPath(string configuration) {
ConfigurationSettings settings = (ConfigurationSettings) GetConfiguration(configuration);
if (settings == null) {
return null;
}
return settings.OutputPath;
}


public override ConfigurationBase GetConfiguration(string configuration) {
return (ConfigurationSettings) _htConfigurations[configuration];
}


          #endregion Public Instance Methods

          #region Private Instance Methods

private bool PreBuild(ConfigurationSettings cs) {
string buildCommandLine = _projectSettings.PreBuildEvent;
Log(Level.Debug, LogPrefix + "PreBuild commandline: {0}", buildCommandLine);
// check if there are pre build commands to be run
if (buildCommandLine != null) {
// create a batch file for this, mirroring the behavior of VS.NET
// the file is not even removed after a successful build by VS.NET,
// so we don't either
using (StreamWriter sw = new StreamWriter(Path.Combine(cs.OutputDir, "PreBuildEvent.bat"))) {
sw.WriteLine("@echo off");
// replace any VS macros in the command line with real values
buildCommandLine = ReplaceMacros(_projectSettings, cs, buildCommandLine);
// handle linebreak charaters
buildCommandLine = buildCommandLine.Replace("
", "\n");
sw.WriteLine(buildCommandLine);
sw.WriteLine("if errorlevel 1 goto EventReportError");
sw.WriteLine("goto EventEnd");
sw.WriteLine(":EventReportError");
sw.WriteLine("echo Project error: A tool returned an error code from the build event");
sw.WriteLine("exit 1");
sw.WriteLine(":EventEnd");
}
// now that we have to file on disk execute it
return ExecuteBuildEvent(Path.Combine(cs.OutputDir, "PreBuildEvent.bat"), "PreBuildEvent");
}
// nothing to do, signal success
return true;
}





From: Nicklas Norling <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: RE: [nant-dev] <solution> changes
Date: Fri, 12 Nov 2004 12:01:39 +0100

Is there a lot done since nightly 11-08? I've got that version deployed
in my organisation and it seems to be working just fine (so far).

Don't think we have wrapper assemblies, what are those?

/Nicke

-----Original Message-----
From: Gert Driesen [mailto:[EMAIL PROTECTED]
Sent: den 12 november 2004 11:55
To: [EMAIL PROTECTED]
Subject: [nant-dev] <solution> changes


Hi,

I've finally took some time to refactor the way the <solution> task deals
with references. We now also use the <tlbimp> / <aximp> tasks to generate
wrapper assemblies.

With the 0.85 release closing in on us (finally, I know), I'd really
appreciate it everyone could check whether there are no regressions.

Thanks !

Gert




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's
Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
nant-developers mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers



------------------------------------------------------- This SF.Net email is sponsored by: Sybase ASE Linux Express Edition - download now for FREE LinuxWorld Reader's Choice Award Winner for best database on Linux. http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click _______________________________________________ nant-developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nant-developers




-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to