From 23b1f7af8d7c69a0a7b867214b7299c823be3e7d Mon Sep 17 00:00:00 2001 From: vfedosevich Date: Wed, 22 May 2013 16:47:46 -0700 Subject: [PATCH] Getting PrivateBinPath from web.config --- .../HostedSharePointServer2013.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.SharePoint2013/HostedSharePointServer2013.cs b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.SharePoint2013/HostedSharePointServer2013.cs index c034dcd0..dc7faca0 100644 --- a/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.SharePoint2013/HostedSharePointServer2013.cs +++ b/WebsitePanel/Sources/WebsitePanel.Providers.HostedSolution.SharePoint2013/HostedSharePointServer2013.cs @@ -29,6 +29,8 @@ using System; using System.Collections.Generic; using System.IO; +using System.Text.RegularExpressions; +using System.Xml; using Microsoft.Win32; using WebsitePanel.Providers.SharePoint; using WebsitePanel.Providers.Utils; @@ -307,7 +309,7 @@ namespace WebsitePanel.Providers.HostedSolution try { Type type = typeof(HostedSharePointServer2013Impl); - var info = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory), PrivateBinPath = string.Join(Path.PathSeparator.ToString(), new string[]{"bin", "bin/debug", "bin/SharePoint2013"}) }; + var info = new AppDomainSetup { ApplicationBase = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory), PrivateBinPath = GetPrivateBinPath() }; domain = AppDomain.CreateDomain("WSS30", null, info); var impl = (HostedSharePointServer2013Impl)domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName); @@ -324,6 +326,27 @@ namespace WebsitePanel.Providers.HostedSolution throw new ArgumentNullException("action"); } + /// Getting PrivatePath from web.config. + /// The PrivateBinPath. + private static string GetPrivateBinPath() + { + var lines = new List{ "bin", "bin/debug" }; + string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "web.config"); + + if (File.Exists(path)) + { + using (var reader = new StreamReader(path)) + { + string content = reader.ReadToEnd(); + var pattern = new Regex(@"(?<=probing .*?privatePath\s*=\s*"")[^""]+(?="".*?>)"); + Match match = pattern.Match(content); + lines.AddRange(match.Value.Split(';')); + } + } + + return string.Join(Path.PathSeparator.ToString(), lines.ToArray()); + } + #endregion } } \ No newline at end of file