Browse Source

Fixed bug in MSBuildEngine that caused "Check with FxCop" to fail in some circumstances.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@5025 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
18f32ada97
  1. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs
  2. 2
      src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs
  3. 2
      src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin
  4. 2
      src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs
  5. 2
      src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs
  6. 37
      src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs
  7. 5
      src/Main/Base/Project/Src/Project/MSBuildEngine/ParallelMSBuildManager.cs
  8. 2
      src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

2
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs

@ -87,7 +87,7 @@ namespace CSharpBinding
options, options,
feedbackSink, feedbackSink,
MSBuildEngine.AdditionalTargetFiles.Concat( MSBuildEngine.AdditionalTargetFiles.Concat(
new [] { "$(SharpDevelopBinPath)/SharpDevelop.CheckMSBuild35Features.targets" })); new [] { Path.Combine(MSBuildEngine.SharpDevelopBinPath, "SharpDevelop.CheckMSBuild35Features.targets") }));
} else { } else {
base.StartBuild(buildServices, options, feedbackSink); base.StartBuild(buildServices, options, feedbackSink);
} }

2
src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs

@ -109,7 +109,7 @@ namespace VBNetBinding
options, options,
feedbackSink, feedbackSink,
MSBuildEngine.AdditionalTargetFiles.Concat( MSBuildEngine.AdditionalTargetFiles.Concat(
new [] { "$(SharpDevelopBinPath)/SharpDevelop.CheckMSBuild35Features.targets" })); new [] { Path.Combine(MSBuildEngine.SharpDevelopBinPath, "SharpDevelop.CheckMSBuild35Features.targets") }));
} else { } else {
base.StartBuild(buildServices, options, feedbackSink); base.StartBuild(buildServices, options, feedbackSink);
} }

2
src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin

@ -14,7 +14,7 @@
<Path name = "/SharpDevelop/MSBuildEngine/AdditionalProperties"> <Path name = "/SharpDevelop/MSBuildEngine/AdditionalProperties">
<!-- Replace the MS CodeAnalysis targets with our own --> <!-- Replace the MS CodeAnalysis targets with our own -->
<String id="CodeAnalysisTargets" text = "$(SharpDevelopBinPath)/SharpDevelop.CodeAnalysis.targets"/> <String id="CodeAnalysisTargets" text = "${SharpDevelopBinPath}/SharpDevelop.CodeAnalysis.targets"/>
<!-- Tell our FxCop task where FxCop can be found --> <!-- Tell our FxCop task where FxCop can be found -->
<String id="FxCopDir" text = "${property:CodeAnalysis.FxCopPath}"/> <String id="FxCopDir" text = "${property:CodeAnalysis.FxCopPath}"/>
</Path> </Path>

2
src/AddIns/Misc/Profiler/Controller/Data/Linq/SQLiteQueryProvider.cs

@ -314,6 +314,8 @@ namespace ICSharpCode.Profiler.Controller.Data.Linq
{ {
MethodCallExpression mc = (MethodCallExpression)expr; MethodCallExpression mc = (MethodCallExpression)expr;
// TODO: accept StartsWith on any object (not only NameMapping.Name)
// accept NameMapping.Name also in other contexts
if (IsMemberOnNameMappingOnParameter(mc.Object, KnownMembers.NameMapping_Name)) { if (IsMemberOnNameMappingOnParameter(mc.Object, KnownMembers.NameMapping_Name)) {
if (mc.Arguments[0].NodeType == ExpressionType.Constant && mc.Arguments[1].NodeType == ExpressionType.Constant) { if (mc.Arguments[0].NodeType == ExpressionType.Constant && mc.Arguments[1].NodeType == ExpressionType.Constant) {
StringComparison cmp = (StringComparison)GetConstantValue(mc.Arguments[1]); StringComparison cmp = (StringComparison)GetConstantValue(mc.Arguments[1]);

2
src/Main/Base/Project/Src/Commands/CustomStringTagProvider.cs

@ -147,6 +147,8 @@ namespace ICSharpCode.SharpDevelop.Commands
return Path.GetFileName(ProjectService.OpenSolution.FileName); return Path.GetFileName(ProjectService.OpenSolution.FileName);
} catch (Exception) {} } catch (Exception) {}
break; break;
case "SHARPDEVELOPBINPATH":
return Path.GetDirectoryName(typeof(SharpDevelopStringTagProvider).Assembly.Location);
case "STARTUPPATH": case "STARTUPPATH":
return Application.StartupPath; return Application.StartupPath;
} }

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

@ -10,8 +10,11 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using System.Xml;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using Microsoft.Build.Construction; using Microsoft.Build.Construction;
@ -60,6 +63,12 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary> /// </summary>
public static readonly IList<IMSBuildAdditionalLogger> AdditionalMSBuildLoggers; public static readonly IList<IMSBuildAdditionalLogger> AdditionalMSBuildLoggers;
public static string SharpDevelopBinPath {
get {
return Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location);
}
}
static MSBuildEngine() static MSBuildEngine()
{ {
CompileTaskNames = new Set<string>( CompileTaskNames = new Set<string>(
@ -70,7 +79,7 @@ namespace ICSharpCode.SharpDevelop.Project
AdditionalMSBuildLoggers = AddInTree.BuildItems<IMSBuildAdditionalLogger>(AdditionalLoggersPath, null, false); AdditionalMSBuildLoggers = AddInTree.BuildItems<IMSBuildAdditionalLogger>(AdditionalLoggersPath, null, false);
MSBuildProperties = new SortedList<string, string>(); MSBuildProperties = new SortedList<string, string>();
MSBuildProperties.Add("SharpDevelopBinPath", Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location)); MSBuildProperties.Add("SharpDevelopBinPath", SharpDevelopBinPath);
// 'BuildingInsideVisualStudio' tells MSBuild that we took care of building a project's dependencies // 'BuildingInsideVisualStudio' tells MSBuild that we took care of building a project's dependencies
// before trying to build the project itself. This speeds up compilation because it prevents MSBuild from // before trying to build the project itself. This speeds up compilation because it prevents MSBuild from
// repeatedly looking if a project needs to be rebuilt. // repeatedly looking if a project needs to be rebuilt.
@ -189,7 +198,7 @@ namespace ICSharpCode.SharpDevelop.Project
List<ILogger> loggers = new List<ILogger> { List<ILogger> loggers = new List<ILogger> {
new SharpDevelopLogger(this), new SharpDevelopLogger(this),
//new BuildLogFileLogger(fileName + ".log", LoggerVerbosity.Diagnostic) //new BuildLogFileLogger(project.FileName + ".log", LoggerVerbosity.Diagnostic)
}; };
foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers) { foreach (IMSBuildAdditionalLogger loggerProvider in MSBuildEngine.AdditionalMSBuildLoggers) {
loggers.Add(loggerProvider.CreateLogger(this)); loggers.Add(loggerProvider.CreateLogger(this));
@ -206,11 +215,14 @@ namespace ICSharpCode.SharpDevelop.Project
// Using projects with in-memory modifications doesn't work with parallel build. // Using projects with in-memory modifications doesn't work with parallel build.
// As a work-around, we'll write our modifications to a file and force MSBuild to include that file using a custom property. // As a work-around, we'll write our modifications to a file and force MSBuild to include that file using a custom property.
temporaryFileName = Path.GetTempFileName(); temporaryFileName = Path.GetTempFileName();
using (StreamWriter w = new StreamWriter(temporaryFileName)) { using (XmlWriter w = new XmlTextWriter(temporaryFileName, Encoding.UTF8)) {
w.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); const string xmlNamespace = "http://schemas.microsoft.com/developer/msbuild/2003";
w.WriteStartElement("Project", xmlNamespace);
foreach (string import in additionalTargetFiles) { foreach (string import in additionalTargetFiles) {
w.WriteLine(" <Import Project=\"" + import + "\" />"); w.WriteStartElement("Import", xmlNamespace);
w.WriteAttributeString("Project", MSBuildInternals.Escape(import));
w.WriteEndElement();
} }
if (globalProperties.ContainsKey("BuildingInsideVisualStudio")) { if (globalProperties.ContainsKey("BuildingInsideVisualStudio")) {
@ -219,7 +231,9 @@ namespace ICSharpCode.SharpDevelop.Project
// We override the target '_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.
w.WriteLine(" <Target Name=\"_ComputeNonExistentFileProperty\" />"); w.WriteStartElement("Target", xmlNamespace);
w.WriteAttributeString("Name", "_ComputeNonExistentFileProperty");
w.WriteEndElement();
} }
// 'MsTestToolsTargets' is preferred because it's at the end of the MSBuild 3.5 and 4.0 target file, // 'MsTestToolsTargets' is preferred because it's at the end of the MSBuild 3.5 and 4.0 target file,
@ -230,14 +244,21 @@ namespace ICSharpCode.SharpDevelop.Project
// because we'll replace the hijackedProperty, manually write the corresponding include // because we'll replace the hijackedProperty, manually write the corresponding include
if (globalProperties.ContainsKey(hijackedProperty)) { if (globalProperties.ContainsKey(hijackedProperty)) {
w.WriteLine(" <Import Project=\"" + globalProperties[hijackedProperty] + "\" />"); // we need to escape the project name because properties passed to MSBuild will not be evaluated
w.WriteStartElement("Import", xmlNamespace);
w.WriteAttributeString("Project", MSBuildInternals.Escape(globalProperties[hijackedProperty]));
w.WriteEndElement();
} }
w.WriteLine("</Project>"); w.WriteEndElement();
// inject our imports at the end of 'Microsoft.Common.Targets' by replacing the hijackedProperty. // inject our imports at the end of 'Microsoft.Common.Targets' by replacing the hijackedProperty.
globalProperties[hijackedProperty] = temporaryFileName; globalProperties[hijackedProperty] = temporaryFileName;
} }
#if DEBUG
LoggingService.Debug(File.ReadAllText(temporaryFileName));
#endif
string fileName = project.FileName; string fileName = project.FileName;
string[] targets = { options.Target.TargetName }; string[] targets = { options.Target.TargetName };
BuildRequestData requestData = new BuildRequestData(fileName, globalProperties, null, targets, new HostServices()); BuildRequestData requestData = new BuildRequestData(fileName, globalProperties, null, targets, new HostServices());

5
src/Main/Base/Project/Src/Project/MSBuildEngine/ParallelMSBuildManager.cs

@ -88,10 +88,7 @@ namespace ICSharpCode.SharpDevelop.Project
LoggingService.Info("ParallelMSBuildManager: got start permisson, starting..."); LoggingService.Info("ParallelMSBuildManager: got start permisson, starting...");
BuildParameters parameters = new BuildParameters(this.ProjectCollection); BuildParameters parameters = new BuildParameters(this.ProjectCollection);
parameters.Loggers = new ILogger[] { parameters.Loggers = new ILogger[] {
new CentralLogger(this), new CentralLogger(this)
#if DEBUG
new ConsoleLogger(LoggerVerbosity.Normal),
#endif
}; };
parameters.EnableNodeReuse = false; parameters.EnableNodeReuse = false;
parameters.MaxNodeCount = BuildOptions.DefaultParallelProjectCount; parameters.MaxNodeCount = BuildOptions.DefaultParallelProjectCount;

2
src/Main/Core/Project/Src/Services/StringParser/StringParser.cs

@ -53,7 +53,7 @@ namespace ICSharpCode.Core
/// <summary> /// <summary>
/// Parses an array and replaces the elements in the existing array. /// Parses an array and replaces the elements in the existing array.
/// </summary> /// </summary>
[Obsolete("Call Parse(string) in a loop / consider suing LINQ Select instead")] [Obsolete("Call Parse(string) in a loop / consider using LINQ Select instead")]
public static void Parse(string[] inputs) public static void Parse(string[] inputs)
{ {
for (int i = 0; i < inputs.Length; ++i) { for (int i = 0; i < inputs.Length; ++i) {

Loading…
Cancel
Save