Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnkit Jain <ankit.jain@xamarin.com>2016-06-09 20:47:55 +0300
committerAnkit Jain <ankit.jain@xamarin.com>2016-07-01 07:06:53 +0300
commitda65a62a73478fd711727db26c703f258c24e3f7 (patch)
tree5606c355d80b517dfec9869572b8754963eade85 /main/src/core/MonoDevelop.Projects.Formats.MSBuild
parentab653ae9f579056e5c94ac90c645fdb0757d9034 (diff)
Make the msbuild(oss) project builder work without need for MONO_PATH by
.. using a custom assembly resolver. - Also, set `MSBuildBinPath` and `MSBuildToolsPath` in the app.config file for the builder. - And set binding redirects for all MSBuild assemblies (>4.0) to the new 14.1 assemblies
Diffstat (limited to 'main/src/core/MonoDevelop.Projects.Formats.MSBuild')
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/Main.cs69
-rw-r--r--main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v14.1.config31
2 files changed, 85 insertions, 15 deletions
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/Main.cs b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/Main.cs
index d1b85e7c26..e16a17afe6 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/Main.cs
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/Main.cs
@@ -26,6 +26,8 @@
using System;
using System.IO;
using System.Collections;
+using System.Linq;
+using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
@@ -38,30 +40,42 @@ namespace MonoDevelop.Projects.MSBuild
class MainClass
{
static readonly ManualResetEvent exitEvent = new ManualResetEvent (false);
+ static string msbuildBinDir = null;
[STAThread]
- public static void Main ()
+ public static void Main (string [] args)
{
try {
- RegisterRemotingChannel ();
- WatchProcess (Console.ReadLine ());
-
- var builderEngine = new BuildEngine ();
- var bf = new BinaryFormatter ();
- ObjRef oref = RemotingServices.Marshal (builderEngine);
- var ms = new MemoryStream ();
- bf.Serialize (ms, oref);
- Console.Error.WriteLine ("[MonoDevelop]" + Convert.ToBase64String (ms.ToArray ()));
-
- if (WaitHandle.WaitAny (new WaitHandle[] { builderEngine.WaitHandle, exitEvent }) == 0) {
- // Wait before exiting, so that the remote call that disposed the builder can be completed
- Thread.Sleep (400);
+ msbuildBinDir = Console.ReadLine ();
+ if (msbuildBinDir.Trim ().Length > 0) {
+ // if we have a "binDir" argument, then we want to build with
+ // OSS msbuild on OSX/Linux
+ AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler (MSBuildAssemblyResolver);
}
-
+
+ Start ();
} catch (Exception ex) {
Console.WriteLine (ex);
}
}
+
+ static void Start()
+ {
+ RegisterRemotingChannel ();
+ WatchProcess (Console.ReadLine ());
+
+ var builderEngine = new BuildEngine ();
+ var bf = new BinaryFormatter ();
+ ObjRef oref = RemotingServices.Marshal (builderEngine);
+ var ms = new MemoryStream ();
+ bf.Serialize (ms, oref);
+ Console.Error.WriteLine ("[MonoDevelop]" + Convert.ToBase64String (ms.ToArray ()));
+
+ if (WaitHandle.WaitAny (new WaitHandle[] { builderEngine.WaitHandle, exitEvent }) == 0) {
+ // Wait before exiting, so that the remote call that disposed the builder can be completed
+ Thread.Sleep (400);
+ }
+ }
public static void RegisterRemotingChannel ()
{
@@ -97,5 +111,30 @@ namespace MonoDevelop.Projects.MSBuild
t.IsBackground = true;
t.Start ();
}
+
+ static Assembly MSBuildAssemblyResolver (object sender, ResolveEventArgs args)
+ {
+ // MSBuild 14.0 assemblies are being redirected to 14.1 assemblies,
+ // so we just need to look for 14.1 here
+ var msbuildAssembles = new string[] {
+ "Microsoft.Build",
+ "Microsoft.Build.Framework",
+ "Microsoft.Build.Tasks.Core",
+ "Microsoft.Build.Utilities.Core" };
+
+ var asmName = new AssemblyName (args.Name);
+ if (msbuildAssembles.Any (n => String.Compare (n, asmName.Name, StringComparison.InvariantCultureIgnoreCase) == 0)
+ && asmName.Version < new Version (14, 1))
+ return null;
+
+ string fullPath = Path.Combine (msbuildBinDir, asmName.Name + ".dll");
+ if (File.Exists (fullPath)) {
+ // If the file exists under the msbuild bin dir, then we need
+ // to load it only from there. If that fails, then let that exception
+ // escape
+ return Assembly.LoadFrom (fullPath);
+ } else
+ return null;
+ }
}
}
diff --git a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v14.1.config b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v14.1.config
index 3aa67d68e0..dbf45949a1 100644
--- a/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v14.1.config
+++ b/main/src/core/MonoDevelop.Projects.Formats.MSBuild/app.v14.1.config
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
+ <configSections>
+ <!-- Microsoft.Build.Engine instead of Microsoft.Build here because a task run under Microsoft.Build may load Microsoft.Build.Engine, which will attempt to read this section. -->
+ <section name="msbuildToolsets" type="Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build, Version=14.1.0.0, Culture=neutral" />
+ </configSections>
<runtime>
<generatePublisherEvidence enabled="false" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
@@ -11,6 +15,33 @@
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="14.1.0.0" />
</dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="14.1.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Utilities.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="14.1.0.0" />
+ </dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Build.Tasks.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="14.1.0.0" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
+ <msbuildToolsets default="14.1">
+ <toolset toolsVersion="14.1">
+ <property name="MSBuildBinPath" value="/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/14.1/bin" />
+ <property name="MSBuildToolsPath" value="/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/14.1/bin" />
+ <property name="TargetFrameworkRootPathSearchPathsOSX" value="/Library/Frameworks/Mono.framework/External/xbuild-frameworks/" />
+ <msbuildExtensionsPathSearchPaths>
+ <searchPaths os="osx">
+ <property name="MSBuildExtensionsPath" value="/Library/Frameworks/Mono.framework/External/xbuild/"/>
+ <property name="MSBuildExtensionsPath32" value="/Library/Frameworks/Mono.framework/External/xbuild/"/>
+ <property name="MSBuildExtensionsPath64" value="/Library/Frameworks/Mono.framework/External/xbuild/"/>
+ </searchPaths>
+ </msbuildExtensionsPathSearchPaths>
+ </toolset>
+ </msbuildToolsets>
+
</configuration>