#74 - Parse the project.json file with Newtonsoft directly.
This commit is contained in:
parent
8a66871139
commit
c47d6d0c78
|
|
@ -17,7 +17,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Microsoft.Framework.ConfigurationModel;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Hosting
|
namespace Microsoft.AspNet.Hosting
|
||||||
{
|
{
|
||||||
|
|
@ -38,17 +39,19 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
public static string GetWebRoot(string applicationBasePath)
|
public static string GetWebRoot(string applicationBasePath)
|
||||||
{
|
{
|
||||||
try
|
var webroot = applicationBasePath;
|
||||||
|
using (var stream = File.OpenRead(Path.Combine(applicationBasePath, "project.json")))
|
||||||
{
|
{
|
||||||
var config = new Configuration();
|
using (var reader = new JsonTextReader(new StreamReader(stream)))
|
||||||
config.AddJsonFile(Path.Combine(applicationBasePath, "project.json"));
|
{
|
||||||
var webroot = config.Get("webroot") ?? string.Empty;
|
var project = JObject.Load(reader);
|
||||||
return Path.GetFullPath(Path.Combine(applicationBasePath, webroot));
|
if (project.TryGetValue("webroot", out var token))
|
||||||
}
|
{
|
||||||
catch (Exception)
|
webroot = Path.Combine(applicationBasePath, token.ToString());
|
||||||
{
|
}
|
||||||
return applicationBasePath;
|
}
|
||||||
}
|
}
|
||||||
|
return Path.GetFullPath(webroot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
"Microsoft.AspNet.PipelineCore": "1.0.0-*",
|
"Microsoft.AspNet.PipelineCore": "1.0.0-*",
|
||||||
"Microsoft.AspNet.Security.DataProtection": "1.0.0-*",
|
"Microsoft.AspNet.Security.DataProtection": "1.0.0-*",
|
||||||
"Microsoft.Framework.ConfigurationModel": "1.0.0-*",
|
"Microsoft.Framework.ConfigurationModel": "1.0.0-*",
|
||||||
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-*",
|
|
||||||
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
|
"Microsoft.Framework.DependencyInjection": "1.0.0-*",
|
||||||
"Microsoft.Framework.Logging": "1.0.0-*",
|
"Microsoft.Framework.Logging": "1.0.0-*",
|
||||||
"Microsoft.Framework.Runtime.Interfaces": "1.0.0-*"
|
"Microsoft.Framework.Runtime.Interfaces": "1.0.0-*",
|
||||||
|
"Newtonsoft.Json": "6.0.4"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"aspnet50": {},
|
"aspnet50": {},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue