Browse Source

Fixed support for parallel builds.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/dotnet4@4288 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 16 years ago
parent
commit
528f42af4f
  1. 2
      debugbuild.bat
  2. 37
      src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs

2
debugbuild.bat

@ -1,4 +1,4 @@
%windir%\microsoft.net\framework\v4.0.20506\msbuild SharpDevelop.sln /p:Configuration=Debug "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU" %windir%\microsoft.net\framework\v4.0.20506\msbuild /m SharpDevelop.sln /p:Configuration=Debug "/p:FSharpBuildTasksPath=%CD%\src\AddIns\BackendBindings\FSharp\RequiredLibraries" "/p:Platform=Any CPU"
@IF %ERRORLEVEL% NEQ 0 GOTO err @IF %ERRORLEVEL% NEQ 0 GOTO err
rem %windir%\microsoft.net\framework\v4.0.20506\msbuild /m AddIns\Misc\Profiler\AutomatedBuild.proj /p:Configuration=Debug rem %windir%\microsoft.net\framework\v4.0.20506\msbuild /m AddIns\Misc\Profiler\AutomatedBuild.proj /p:Configuration=Debug
@IF %ERRORLEVEL% NEQ 0 GOTO err @IF %ERRORLEVEL% NEQ 0 GOTO err

37
src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs

@ -148,6 +148,7 @@ namespace ICSharpCode.SharpDevelop.Project
public bool ReportUnknownEvents { get; set; } public bool ReportUnknownEvents { get; set; }
List<string> interestingTasks = new List<string>(); List<string> interestingTasks = new List<string>();
string temporaryFileName;
/// <summary> /// <summary>
/// The list of task names for which TaskStarted and TaskFinished events should be /// The list of task names for which TaskStarted and TaskFinished events should be
@ -194,29 +195,39 @@ namespace ICSharpCode.SharpDevelop.Project
return new ParallelMSBuildManager(new MSBuild.ProjectCollection()); return new ParallelMSBuildManager(new MSBuild.ProjectCollection());
}); });
// Use a temporary project collection to prevent MSBuild from opening the element from the global collection // Using projects with in-memory modifications doesn't work with parallel build.
// - we don't want to modify the ProjectRootElement opened as project because we don't want to save // As a work-around, we'll write our modifications to a file and force MSBuild to include that file using a custom property.
// back our changes to disk. temporaryFileName = Path.GetTempFileName();
ProjectRootElement projectFile = ProjectRootElement.Open(project.FileName, manager.ProjectCollection); using (StreamWriter w = new StreamWriter(temporaryFileName)) {
foreach (string import in additionalTargetFiles) w.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">");
projectFile.AddImport(import);
foreach (string import in additionalTargetFiles) {
w.WriteLine(" <Import Project=\"" + import + "\" />");
}
if (globalProperties.ContainsKey("BuildingInsideVisualStudio")) { if (globalProperties.ContainsKey("BuildingInsideVisualStudio")) {
// When we set BuildingInsideVisualStudio, MSBuild skips its own change detection // When we set BuildingInsideVisualStudio, MSBuild skips its own change detection
// because in Visual Studio, the host compiler does the change detection. // because in Visual Studio, the host compiler does the change detection.
// We override the property '_ComputeNonExistentFileProperty' which is responsible // We override the target '_ComputeNonExistentFileProperty' which is responsible
// for recompiling each time - our _ComputeNonExistentFileProperty does nothing, // for recompiling each time - our _ComputeNonExistentFileProperty does nothing,
// which re-enables the MSBuild's usual change detection. // which re-enables the MSBuild's usual change detection.
projectFile.AddTarget("_ComputeNonExistentFileProperty"); w.WriteLine(" <Target Name=\"_ComputeNonExistentFileProperty\" />");
} }
w.WriteLine("</Project>");
ProjectInstance projectInstance = MSBuildInternals.LoadProjectInstance(manager.ProjectCollection, projectFile, globalProperties); // inject our imports at the end of 'Microsoft.Common.Targets' by replacing the CodeAnalysisTargets.
if (globalProperties.ContainsKey("CodeAnalysisTargets")) {
w.WriteLine(" <Import Project=\"" + globalProperties["CodeAnalysisTargets"] + "\" />");
}
globalProperties["CodeAnalysisTargets"] = temporaryFileName;
}
string fileName = project.FileName;
string[] targets = { options.Target.TargetName }; string[] targets = { options.Target.TargetName };
BuildRequestData requestData = new BuildRequestData(projectInstance, targets, new HostServices()); BuildRequestData requestData = new BuildRequestData(fileName, globalProperties, null, targets, new HostServices());
ILogger[] loggers = { ILogger[] loggers = {
new SharpDevelopLogger(this), new SharpDevelopLogger(this),
new BuildLogFileLogger(projectFile.FullPath + ".log", LoggerVerbosity.Diagnostic) new BuildLogFileLogger(fileName + ".log", LoggerVerbosity.Diagnostic)
}; };
manager.StartBuild(requestData, loggers, OnComplete); manager.StartBuild(requestData, loggers, OnComplete);
} }
@ -454,6 +465,10 @@ namespace ICSharpCode.SharpDevelop.Project
public void Shutdown() public void Shutdown()
{ {
if (worker.temporaryFileName != null) {
File.Delete(worker.temporaryFileName);
worker.temporaryFileName = null;
}
} }
#endregion #endregion
} }

Loading…
Cancel
Save