From 0f1292abf6857c0a2d3a678a28c5fe8a03babf1d Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 19 Mar 2015 17:41:22 -0700 Subject: [PATCH] Transition root paths => relative for tooling. #2213 --- .../MvcRazorHost.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs index 64d71834e1..86fa368baa 100644 --- a/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs +++ b/src/Microsoft.AspNet.Mvc.Razor.Host/MvcRazorHost.cs @@ -51,6 +51,7 @@ namespace Microsoft.AspNet.Mvc.Razor public MvcRazorHost(string root) : this(new DefaultCodeTreeCache(new PhysicalFileProvider(root))) { + ApplicationRoot = root; } #endif /// @@ -112,6 +113,13 @@ namespace Microsoft.AspNet.Mvc.Razor } } +#if NET45 + /// + /// The path to the application root. + /// + public string ApplicationRoot { get; } +#endif + /// /// Gets the model type used by default when no model is specified. /// @@ -186,6 +194,14 @@ namespace Microsoft.AspNet.Mvc.Razor /// public override RazorParser DecorateRazorParser([NotNull] RazorParser razorParser, string sourceFileName) { +#if NET45 + // Need to convert sourceFileName to application relative (rooted paths are passed in by tooling). + if (Path.IsPathRooted(sourceFileName)) + { + sourceFileName = sourceFileName.Substring(ApplicationRoot.Length); + } +#endif + var inheritedCodeTrees = ChunkInheritanceUtility.GetInheritedCodeTrees(sourceFileName); return new MvcRazorParser(razorParser, inheritedCodeTrees, DefaultInheritedChunks); }