62 changed files with 635 additions and 683 deletions
@ -1,39 +0,0 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.IO; |
|
||||||
using ICSharpCode.Scripting; |
|
||||||
using ICSharpCode.SharpDevelop.Project; |
|
||||||
|
|
||||||
namespace ICSharpCode.Scripting.Tests.Utils |
|
||||||
{ |
|
||||||
public sealed class MSBuildEngineHelper |
|
||||||
{ |
|
||||||
MSBuildEngineHelper() |
|
||||||
{ |
|
||||||
} |
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The MSBuildEngine sets theBinPath so if
|
|
||||||
/// the Build.Tasks assembly is shadow copied it refers
|
|
||||||
/// to the shadow copied assembly not the original. This
|
|
||||||
/// causes problems for python projects that refer to the
|
|
||||||
/// SharpDevelop.*.Build.targets import via $(BinPath)
|
|
||||||
/// so here we change it so it points to the real BinPath
|
|
||||||
/// binary.
|
|
||||||
/// </summary>
|
|
||||||
public static void InitMSBuildEngine(string binPathName, string addInRelativePath, Type typeForCodeBase) |
|
||||||
{ |
|
||||||
MSBuildEngine.MSBuildProperties.Remove(binPathName); |
|
||||||
|
|
||||||
// Set the bin path property so it points to
|
|
||||||
// the actual bin path where the Build.Tasks was built not
|
|
||||||
// to the shadow copy folder.
|
|
||||||
string codeBase = typeForCodeBase.Assembly.CodeBase.Replace("file:///", String.Empty); |
|
||||||
string folder = Path.GetDirectoryName(codeBase); |
|
||||||
folder = Path.GetFullPath(Path.Combine(folder, addInRelativePath)); |
|
||||||
MSBuildEngine.MSBuildProperties[binPathName] = folder; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,168 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Threading; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using ICSharpCode.Core; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Project |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Interface to static MSBuildEngine methods.
|
||||||
|
/// </summary>
|
||||||
|
[SDService] |
||||||
|
public interface IMSBuildEngine |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of the task names that cause a "Compiling ..." log message.
|
||||||
|
/// You can add items to this set by putting strings into
|
||||||
|
/// "/SharpDevelop/MSBuildEngine/CompileTaskNames".
|
||||||
|
/// </summary>
|
||||||
|
ISet<string> CompileTaskNames { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the global MSBuild properties.
|
||||||
|
/// You can add items to this dictionary by putting strings into
|
||||||
|
/// "/SharpDevelop/MSBuildEngine/AdditionalProperties".
|
||||||
|
/// </summary>
|
||||||
|
IEnumerable<KeyValuePair<string, string>> GlobalBuildProperties { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of additional target files that are automatically loaded into all projects.
|
||||||
|
/// You can add items into this list by putting strings into
|
||||||
|
/// "/SharpDevelop/MSBuildEngine/AdditionalTargetFiles"
|
||||||
|
/// </summary>
|
||||||
|
IList<FileName> AdditionalTargetFiles { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of additional MSBuild loggers.
|
||||||
|
/// You can register your loggers by putting them into
|
||||||
|
/// "/SharpDevelop/MSBuildEngine/AdditionalLoggers"
|
||||||
|
/// </summary>
|
||||||
|
IList<IMSBuildAdditionalLogger> AdditionalMSBuildLoggers { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a list of MSBuild logger filter.
|
||||||
|
/// You can register your loggers by putting them into
|
||||||
|
/// "/SharpDevelop/MSBuildEngine/LoggerFilters"
|
||||||
|
/// </summary>
|
||||||
|
IList<IMSBuildLoggerFilter> MSBuildLoggerFilters { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves the location of the reference files.
|
||||||
|
/// </summary>
|
||||||
|
IList<ReferenceProjectItem> ResolveAssemblyReferences( |
||||||
|
MSBuildBasedProject baseProject, |
||||||
|
ReferenceProjectItem[] additionalReferences = null, bool resolveOnlyAdditionalReferences = false, |
||||||
|
bool logErrorsToOutputPad = true); |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Compiles the specified project using MSBuild.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="project">The project to be built.</param>
|
||||||
|
/// <param name="options">The options to use for building this project.</param>
|
||||||
|
/// <param name="feedbackSink">Callback for errors/warning and log messages</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token for aborting the build</param>
|
||||||
|
/// <param name="additionalTargetFiles">Additional MSBuild target files that should be included in the build.
|
||||||
|
/// Note: target files specified in the AddInTree path "/SharpDevelop/MSBuildEngine/AdditionalTargetFiles" are always included
|
||||||
|
/// and do not have to be specified.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>True if the build completes successfully; false otherwise.</returns>
|
||||||
|
Task<bool> BuildAsync(IProject project, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, CancellationToken cancellationToken, IEnumerable<string> additionalTargetFiles = null); |
||||||
|
} |
||||||
|
|
||||||
|
public interface IMSBuildLoggerContext |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// The project being built.
|
||||||
|
/// </summary>
|
||||||
|
IProject Project { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the project file being compiled by this engine.
|
||||||
|
/// </summary>
|
||||||
|
FileName ProjectFileName { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls whether messages should be made available to loggers.
|
||||||
|
/// Logger AddIns should set this property in their CreateLogger method.
|
||||||
|
/// </summary>
|
||||||
|
bool ReportMessageEvents { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls whether the TargetStarted event should be made available to loggers.
|
||||||
|
/// Logger AddIns should set this property in their CreateLogger method.
|
||||||
|
/// </summary>
|
||||||
|
bool ReportTargetStartedEvents { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls whether the TargetStarted event should be made available to loggers.
|
||||||
|
/// Logger AddIns should set this property in their CreateLogger method.
|
||||||
|
/// </summary>
|
||||||
|
bool ReportTargetFinishedEvents { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls whether all TaskStarted events should be made available to loggers.
|
||||||
|
/// Logger AddIns should set this property in their CreateLogger method.
|
||||||
|
/// </summary>
|
||||||
|
bool ReportAllTaskStartedEvents { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls whether all TaskFinished events should be made available to loggers.
|
||||||
|
/// Logger AddIns should set this property in their CreateLogger method.
|
||||||
|
/// </summary>
|
||||||
|
bool ReportAllTaskFinishedEvents { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Controls whether the AnyEventRaised and StatusEventRaised events should
|
||||||
|
/// be called for unknown events.
|
||||||
|
/// Logger AddIns should set this property in their CreateLogger method.
|
||||||
|
/// </summary>
|
||||||
|
bool ReportUnknownEvents { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The list of task names for which TaskStarted and TaskFinished events should be
|
||||||
|
/// made available to loggers.
|
||||||
|
/// Logger AddIns should add entries in their CreateLogger method.
|
||||||
|
/// </summary>
|
||||||
|
ISet<string> InterestingTasks { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Outputs a text line into the message log.
|
||||||
|
/// </summary>
|
||||||
|
void OutputTextLine(string text); |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reports an error. This method bypasses the logger filter chain.
|
||||||
|
/// </summary>
|
||||||
|
void ReportError(BuildError error); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for elements in /SharpDevelop/MSBuildEngine/AdditionalLoggers
|
||||||
|
/// </summary>
|
||||||
|
public interface IMSBuildAdditionalLogger |
||||||
|
{ |
||||||
|
Microsoft.Build.Framework.ILogger CreateLogger(IMSBuildLoggerContext context); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for elements in /SharpDevelop/MSBuildEngine/LoggerFilters
|
||||||
|
/// </summary>
|
||||||
|
public interface IMSBuildLoggerFilter |
||||||
|
{ |
||||||
|
IMSBuildChainedLoggerFilter CreateFilter(IMSBuildLoggerContext context, IMSBuildChainedLoggerFilter nextFilter); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Element in the logger filter chain.
|
||||||
|
/// Receives build events and errors and forwards them to the next element in the chain (possibly after modifying the event).
|
||||||
|
/// </summary>
|
||||||
|
public interface IMSBuildChainedLoggerFilter |
||||||
|
{ |
||||||
|
void HandleError(BuildError error); |
||||||
|
void HandleBuildEvent(Microsoft.Build.Framework.BuildEventArgs e); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,18 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// SharpDevelop UI service.
|
||||||
|
///
|
||||||
|
/// This service provides methods for accessing the dialogs and other UI element built into SharpDevelop.
|
||||||
|
/// </summary>
|
||||||
|
public interface IUIService |
||||||
|
{ |
||||||
|
void ShowSolutionConfigurationEditorDialog(ISolution solution); |
||||||
|
} |
||||||
|
} |
||||||
@ -1,120 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||||
<root> |
|
||||||
<!-- |
|
||||||
Microsoft ResX Schema |
|
||||||
|
|
||||||
Version 2.0 |
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format |
|
||||||
that is mostly human readable. The generation and parsing of the |
|
||||||
various data types are done through the TypeConverter classes |
|
||||||
associated with the data types. |
|
||||||
|
|
||||||
Example: |
|
||||||
|
|
||||||
... ado.net/XML headers & schema ... |
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|
||||||
<resheader name="version">2.0</resheader> |
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|
||||||
</data> |
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|
||||||
<comment>This is a comment</comment> |
|
||||||
</data> |
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple |
|
||||||
name/value pairs. |
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a |
|
||||||
type or mimetype. Type corresponds to a .NET class that support |
|
||||||
text/value conversion through the TypeConverter architecture. |
|
||||||
Classes that don't support this are serialized and stored with the |
|
||||||
mimetype set. |
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the |
|
||||||
ResXResourceReader how to depersist the object. This is currently not |
|
||||||
extensible. For a given mimetype the value must be set accordingly: |
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|
||||||
that the ResXResourceWriter will generate, however the reader can |
|
||||||
read any of the formats listed below. |
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64 |
|
||||||
value : The object must be serialized with |
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter |
|
||||||
: and then encoded with base64 encoding. |
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64 |
|
||||||
value : The object must be serialized with |
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|
||||||
: and then encoded with base64 encoding. |
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|
||||||
value : The object must be serialized into a byte array |
|
||||||
: using a System.ComponentModel.TypeConverter |
|
||||||
: and then encoded with base64 encoding. |
|
||||||
--> |
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> |
|
||||||
<xsd:element name="root" msdata:IsDataSet="true"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:choice maxOccurs="unbounded"> |
|
||||||
<xsd:element name="metadata"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:sequence> |
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|
||||||
</xsd:sequence> |
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" /> |
|
||||||
<xsd:attribute name="type" type="xsd:string" /> |
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|
||||||
<xsd:attribute ref="xml:space" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
<xsd:element name="assembly"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:attribute name="alias" type="xsd:string" /> |
|
||||||
<xsd:attribute name="name" type="xsd:string" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
<xsd:element name="data"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:sequence> |
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|
||||||
</xsd:sequence> |
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> |
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|
||||||
<xsd:attribute ref="xml:space" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
<xsd:element name="resheader"> |
|
||||||
<xsd:complexType> |
|
||||||
<xsd:sequence> |
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|
||||||
</xsd:sequence> |
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
</xsd:choice> |
|
||||||
</xsd:complexType> |
|
||||||
</xsd:element> |
|
||||||
</xsd:schema> |
|
||||||
<resheader name="resmimetype"> |
|
||||||
<value>text/microsoft-resx</value> |
|
||||||
</resheader> |
|
||||||
<resheader name="version"> |
|
||||||
<value>2.0</value> |
|
||||||
</resheader> |
|
||||||
<resheader name="reader"> |
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|
||||||
</resheader> |
|
||||||
<resheader name="writer"> |
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|
||||||
</resheader> |
|
||||||
</root> |
|
||||||
@ -0,0 +1,222 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.IO; |
||||||
|
using System.Linq; |
||||||
|
using System.Threading; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using ICSharpCode.Core; |
||||||
|
using ICSharpCode.SharpDevelop.Parser; |
||||||
|
using Microsoft.Build.Execution; |
||||||
|
using Microsoft.Build.Framework; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop.Project |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Class responsible for building a project using MSBuild.
|
||||||
|
/// Is called by MSBuildProject.
|
||||||
|
/// </summary>
|
||||||
|
sealed class MSBuildEngine : IMSBuildEngine |
||||||
|
{ |
||||||
|
const string CompileTaskNamesPath = "/SharpDevelop/MSBuildEngine/CompileTaskNames"; |
||||||
|
const string AdditionalTargetFilesPath = "/SharpDevelop/MSBuildEngine/AdditionalTargetFiles"; |
||||||
|
const string AdditionalLoggersPath = "/SharpDevelop/MSBuildEngine/AdditionalLoggers"; |
||||||
|
const string LoggerFiltersPath = "/SharpDevelop/MSBuildEngine/LoggerFilters"; |
||||||
|
const string AdditionalPropertiesPath = "/SharpDevelop/MSBuildEngine/AdditionalProperties"; |
||||||
|
|
||||||
|
public ISet<string> CompileTaskNames { get; private set; } |
||||||
|
public IList<FileName> AdditionalTargetFiles { get; private set; } |
||||||
|
public IList<IMSBuildAdditionalLogger> AdditionalMSBuildLoggers { get; private set; } |
||||||
|
public IList<IMSBuildLoggerFilter> MSBuildLoggerFilters { get; private set; } |
||||||
|
|
||||||
|
public MSBuildEngine() |
||||||
|
{ |
||||||
|
CompileTaskNames = new SortedSet<string>( |
||||||
|
AddInTree.BuildItems<string>(CompileTaskNamesPath, null, false), |
||||||
|
StringComparer.OrdinalIgnoreCase |
||||||
|
); |
||||||
|
AdditionalTargetFiles = SD.AddInTree.BuildItems<string>(AdditionalTargetFilesPath, null, false).Select(FileName.Create).ToList(); |
||||||
|
AdditionalMSBuildLoggers = SD.AddInTree.BuildItems<IMSBuildAdditionalLogger>(AdditionalLoggersPath, null, false).ToList(); |
||||||
|
MSBuildLoggerFilters = SD.AddInTree.BuildItems<IMSBuildLoggerFilter>(LoggerFiltersPath, null, false).ToList(); |
||||||
|
} |
||||||
|
|
||||||
|
public IEnumerable<KeyValuePair<string, string>> GlobalBuildProperties { |
||||||
|
get { |
||||||
|
yield return new KeyValuePair<string, string>("SharpDevelopBinPath", Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location)); |
||||||
|
// 'BuildingSolutionFile' 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
|
||||||
|
// repeatedly looking if a project needs to be rebuilt.
|
||||||
|
yield return new KeyValuePair<string, string>("BuildingSolutionFile", "true"); |
||||||
|
// BuildingSolutionFile does not work in MSBuild 4.0 anymore, but BuildingInsideVisualStudio
|
||||||
|
// can be used to get the same effect.
|
||||||
|
yield return new KeyValuePair<string, string>("BuildingInsideVisualStudio", "true"); |
||||||
|
|
||||||
|
// Re-load these properties from AddInTree every time because "text" might contain
|
||||||
|
// SharpDevelop properties resolved by the StringParser (e.g. ${property:FxCopPath}).
|
||||||
|
// (this is also why this is an enumerable implemented with yield return)
|
||||||
|
AddInTreeNode node = AddInTree.GetTreeNode(MSBuildEngine.AdditionalPropertiesPath, false); |
||||||
|
if (node != null) { |
||||||
|
foreach (Codon codon in node.Codons) { |
||||||
|
object item = node.BuildChildItem(codon, null); |
||||||
|
if (item != null) { |
||||||
|
string text = item.ToString(); |
||||||
|
yield return new KeyValuePair<string, string>(codon.Id, text); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public Task<bool> BuildAsync(IProject project, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, CancellationToken cancellationToken, IEnumerable<string> additionalTargetFiles) |
||||||
|
{ |
||||||
|
if (project == null) |
||||||
|
throw new ArgumentNullException("project"); |
||||||
|
if (options == null) |
||||||
|
throw new ArgumentNullException("options"); |
||||||
|
if (feedbackSink == null) |
||||||
|
throw new ArgumentNullException("feedbackSink"); |
||||||
|
|
||||||
|
var additionalTargetFileList = additionalTargetFiles != null ? additionalTargetFiles.ToList() : new List<string>(); |
||||||
|
if (project.MinimumSolutionVersion >= SolutionFormatVersion.VS2010) { |
||||||
|
additionalTargetFileList.Add(Path.Combine(Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location), "SharpDevelop.TargetingPack.targets")); |
||||||
|
} |
||||||
|
var engine = new MSBuildEngineWorker(this, project, options, feedbackSink, additionalTargetFileList); |
||||||
|
return engine.RunBuildAsync(cancellationToken); |
||||||
|
} |
||||||
|
|
||||||
|
public IList<ReferenceProjectItem> ResolveAssemblyReferences( |
||||||
|
MSBuildBasedProject baseProject, |
||||||
|
ReferenceProjectItem[] additionalReferences, bool resolveOnlyAdditionalReferences, |
||||||
|
bool logErrorsToOutputPad) |
||||||
|
{ |
||||||
|
ProjectInstance project = baseProject.CreateProjectInstance(); |
||||||
|
project.SetProperty("BuildingProject", "false"); |
||||||
|
project.SetProperty("DesignTimeBuild", "true"); |
||||||
|
|
||||||
|
List<ProjectItemInstance> references = ( |
||||||
|
from item in project.Items |
||||||
|
where ItemType.ReferenceItemTypes.Contains(new ItemType(item.ItemType)) |
||||||
|
select item |
||||||
|
).ToList(); |
||||||
|
|
||||||
|
List<ReferenceProjectItem> referenceProjectItems; |
||||||
|
|
||||||
|
if (resolveOnlyAdditionalReferences) { |
||||||
|
// Remove existing references from project
|
||||||
|
foreach (ProjectItemInstance reference in references) { |
||||||
|
project.RemoveItem(reference); |
||||||
|
} |
||||||
|
references.Clear(); |
||||||
|
referenceProjectItems = new List<ReferenceProjectItem>(); |
||||||
|
} else { |
||||||
|
// Remove the "Private" meta data.
|
||||||
|
// This is necessary to detect the default value for "Private"
|
||||||
|
foreach (ProjectItemInstance reference in references) { |
||||||
|
reference.RemoveMetadata("Private"); |
||||||
|
} |
||||||
|
referenceProjectItems = baseProject.Items.OfType<ReferenceProjectItem>().ToList(); |
||||||
|
} |
||||||
|
|
||||||
|
if (additionalReferences != null) { |
||||||
|
referenceProjectItems.AddRange(additionalReferences); |
||||||
|
foreach (ReferenceProjectItem item in additionalReferences) { |
||||||
|
references.Add(project.AddItem("Reference", item.Include)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
List<string> targets = new List<string>(); |
||||||
|
if (baseProject.MinimumSolutionVersion >= SolutionFormatVersion.VS2010) { |
||||||
|
targets.Add("ResolveReferences"); |
||||||
|
targets.Add("DesignTimeResolveAssemblyReferences"); |
||||||
|
} else { |
||||||
|
targets.Add("ResolveAssemblyReferences"); |
||||||
|
} |
||||||
|
BuildRequestData requestData = new BuildRequestData(project, targets.ToArray(), new HostServices()); |
||||||
|
List<ILogger> loggers = new List<ILogger>(); |
||||||
|
//loggers.Add(new ConsoleLogger(LoggerVerbosity.Diagnostic));
|
||||||
|
if (logErrorsToOutputPad) |
||||||
|
loggers.Add(new SimpleErrorLogger()); |
||||||
|
lock (MSBuildInternals.SolutionProjectCollectionLock) { |
||||||
|
BuildParameters parameters = new BuildParameters(baseProject.MSBuildProjectCollection); |
||||||
|
parameters.Loggers = loggers; |
||||||
|
|
||||||
|
//LoggingService.Debug("Started build for ResolveAssemblyReferences");
|
||||||
|
BuildResult result = BuildManager.DefaultBuildManager.Build(parameters, requestData); |
||||||
|
if (result == null) |
||||||
|
throw new InvalidOperationException("BuildResult is null"); |
||||||
|
//LoggingService.Debug("Build for ResolveAssemblyReferences finished: " + result.OverallResult);
|
||||||
|
} |
||||||
|
|
||||||
|
IEnumerable<ProjectItemInstance> resolvedAssemblyProjectItems = project.GetItems("_ResolveAssemblyReferenceResolvedFiles"); |
||||||
|
|
||||||
|
var query = |
||||||
|
from msbuildItem in resolvedAssemblyProjectItems |
||||||
|
where msbuildItem.GetMetadataValue("ReferenceSourceTarget") != "ProjectReference" |
||||||
|
let originalInclude = msbuildItem.GetMetadataValue("OriginalItemSpec") |
||||||
|
join item in referenceProjectItems.Where(p => p.ItemType != ItemType.ProjectReference) on originalInclude equals item.Include into referenceItems |
||||||
|
select new { |
||||||
|
OriginalInclude = originalInclude, |
||||||
|
AssemblyName = new DomAssemblyName(msbuildItem.GetMetadataValue("FusionName")), |
||||||
|
FullPath = FileUtility.GetAbsolutePath(baseProject.Directory, msbuildItem.GetMetadataValue("Identity")), |
||||||
|
Redist = msbuildItem.GetMetadataValue("Redist"), |
||||||
|
CopyLocal = bool.Parse(msbuildItem.GetMetadataValue("CopyLocal")), |
||||||
|
ReferenceItems = referenceItems |
||||||
|
}; |
||||||
|
// HACK: mscorlib is reported twice for portable library projects (even if we don't specify it as additionalReference)
|
||||||
|
query = query.DistinctBy(asm => asm.FullPath); |
||||||
|
List<ReferenceProjectItem> resolvedAssemblies = new List<ReferenceProjectItem>(); |
||||||
|
List<ReferenceProjectItem> handledReferenceItems = new List<ReferenceProjectItem>(); |
||||||
|
foreach (var assembly in query) { |
||||||
|
//LoggingService.Debug("Got information about " + assembly.OriginalInclude + "; fullpath=" + assembly.FullPath);
|
||||||
|
foreach (var referenceItem in assembly.ReferenceItems) { |
||||||
|
referenceItem.AssemblyName = assembly.AssemblyName; |
||||||
|
referenceItem.FileName = assembly.FullPath; |
||||||
|
referenceItem.Redist = assembly.Redist; |
||||||
|
referenceItem.DefaultCopyLocalValue = assembly.CopyLocal; |
||||||
|
handledReferenceItems.Add(referenceItem); |
||||||
|
} |
||||||
|
ReferenceProjectItem firstItem = assembly.ReferenceItems.FirstOrDefault(); |
||||||
|
if (firstItem != null) { |
||||||
|
resolvedAssemblies.Add(firstItem); |
||||||
|
} else { |
||||||
|
resolvedAssemblies.Add(new ReferenceProjectItem(baseProject, assembly.OriginalInclude) { FileName = assembly.FullPath }); |
||||||
|
} |
||||||
|
} |
||||||
|
// Add any assemblies that weren't resolved yet. This is important - for example, this adds back project references.
|
||||||
|
foreach (var referenceItem in referenceProjectItems.Except(handledReferenceItems)) { |
||||||
|
resolvedAssemblies.Add(referenceItem); |
||||||
|
} |
||||||
|
return resolvedAssemblies; |
||||||
|
} |
||||||
|
|
||||||
|
sealed class SimpleErrorLogger : ILogger |
||||||
|
{ |
||||||
|
#region ILogger interface implementation
|
||||||
|
public LoggerVerbosity Verbosity { get; set; } |
||||||
|
public string Parameters { get; set; } |
||||||
|
|
||||||
|
public void Initialize(IEventSource eventSource) |
||||||
|
{ |
||||||
|
eventSource.ErrorRaised += OnError; |
||||||
|
eventSource.WarningRaised += OnWarning; |
||||||
|
} |
||||||
|
|
||||||
|
public void Shutdown() |
||||||
|
{ |
||||||
|
} |
||||||
|
#endregion
|
||||||
|
|
||||||
|
void OnError(object sender, BuildErrorEventArgs e) |
||||||
|
{ |
||||||
|
TaskService.BuildMessageViewCategory.AppendLine(e.Message); |
||||||
|
} |
||||||
|
|
||||||
|
void OnWarning(object sender, BuildWarningEventArgs e) |
||||||
|
{ |
||||||
|
TaskService.BuildMessageViewCategory.AppendLine(e.Message); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -1,7 +1,7 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Gui |
namespace ICSharpCode.SharpDevelop.Project |
||||||
{ |
{ |
||||||
partial class AddNewConfigurationDialog : System.Windows.Forms.Form |
partial class AddNewConfigurationDialog : System.Windows.Forms.Form |
||||||
{ |
{ |
||||||
@ -1,7 +1,7 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Gui |
namespace ICSharpCode.SharpDevelop.Project |
||||||
{ |
{ |
||||||
partial class EditAvailableConfigurationsDialog : System.Windows.Forms.Form |
partial class EditAvailableConfigurationsDialog : System.Windows.Forms.Form |
||||||
{ |
{ |
||||||
@ -1,7 +1,7 @@ |
|||||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
namespace ICSharpCode.SharpDevelop.Gui |
namespace ICSharpCode.SharpDevelop.Project |
||||||
{ |
{ |
||||||
partial class SolutionConfigurationEditor : System.Windows.Forms.Form |
partial class SolutionConfigurationEditor : System.Windows.Forms.Form |
||||||
{ |
{ |
||||||
@ -0,0 +1,23 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.SharpDevelop.Project; |
||||||
|
|
||||||
|
namespace ICSharpCode.SharpDevelop |
||||||
|
{ |
||||||
|
class UIService : IUIService |
||||||
|
{ |
||||||
|
public void ShowSolutionConfigurationEditorDialog(ISolution solution) |
||||||
|
{ |
||||||
|
using (SolutionConfigurationEditor sce = new SolutionConfigurationEditor(solution)) { |
||||||
|
sce.ShowDialog(SD.WinForms.MainWin32Window); |
||||||
|
if (solution.IsDirty) |
||||||
|
solution.Save(); |
||||||
|
foreach (IProject project in solution.Projects) { |
||||||
|
project.Save(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue