diff --git a/src/Umbraco.Core/Composing/CollectionBuilderBase.cs b/src/Umbraco.Core/Composing/CollectionBuilderBase.cs
index 0d398be83b..ca2bac3905 100644
--- a/src/Umbraco.Core/Composing/CollectionBuilderBase.cs
+++ b/src/Umbraco.Core/Composing/CollectionBuilderBase.cs
@@ -117,7 +117,7 @@ namespace Umbraco.Core.Composing
/// Creates a new collection each time it is invoked.
public virtual TCollection CreateCollection(IFactory factory)
{
- return factory.CreateInstance(CreateItems(factory));
+ return factory.CreateInstance( CreateItems(factory));
}
protected Type EnsureType(Type type, string action)
diff --git a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
index 38190112d3..a7ed204ee7 100644
--- a/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
+++ b/src/Umbraco.Core/Hosting/IHostingEnvironment.cs
@@ -34,8 +34,6 @@ namespace Umbraco.Core.Hosting
Version IISVersion { get; }
- // TODO: Should we change this name to MapPathWebRoot ? and also have a new MapPathContentRoot ?
-
///
/// Maps a virtual path to a physical path to the application's web root
///
@@ -45,7 +43,18 @@ namespace Umbraco.Core.Hosting
/// Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however
/// in netcore the web root is /www therefore this will Map to a physical path within www.
///
- string MapPath(string path);
+ string MapPathWebRoot(string path);
+
+ ///
+ /// Maps a virtual path to a physical path to the application's root (not always equal to the web root)
+ ///
+ ///
+ ///
+ ///
+ /// Depending on the runtime 'web root', this result can vary. For example in Net Framework the web root and the content root are the same, however
+ /// in netcore the web root is /www therefore this will Map to a physical path within www.
+ ///
+ string MapPathContentRoot(string path);
///
/// Converts a virtual path to an absolute URL path based on the application's web root
diff --git a/src/Umbraco.Core/IO/IOHelper.cs b/src/Umbraco.Core/IO/IOHelper.cs
index a71a307e01..a8a34e2e93 100644
--- a/src/Umbraco.Core/IO/IOHelper.cs
+++ b/src/Umbraco.Core/IO/IOHelper.cs
@@ -78,8 +78,8 @@ namespace Umbraco.Core.IO
if (_hostingEnvironment.IsHosted)
{
var result = (!string.IsNullOrEmpty(path) && (path.StartsWith("~") || path.StartsWith(_hostingEnvironment.ApplicationVirtualPath)))
- ? _hostingEnvironment.MapPath(path)
- : _hostingEnvironment.MapPath("~/" + path.TrimStart('/'));
+ ? _hostingEnvironment.MapPathWebRoot(path)
+ : _hostingEnvironment.MapPathWebRoot("~/" + path.TrimStart('/'));
if (result != null) return result;
}
diff --git a/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs b/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs
index df230bc3da..9efcdc4891 100644
--- a/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs
+++ b/src/Umbraco.Examine.Lucene/LuceneIndexCreator.cs
@@ -41,13 +41,13 @@ namespace Umbraco.Examine
public virtual Lucene.Net.Store.Directory CreateFileSystemLuceneDirectory(string folderName)
{
- var dirInfo = new DirectoryInfo(Path.Combine(_hostingEnvironment.MapPath(Constants.SystemDirectories.TempData), "ExamineIndexes", folderName));
+ var dirInfo = new DirectoryInfo(Path.Combine(_hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempData), "ExamineIndexes", folderName));
if (!dirInfo.Exists)
System.IO.Directory.CreateDirectory(dirInfo.FullName);
//check if there's a configured directory factory, if so create it and use that to create the lucene dir
var configuredDirectoryFactory = _settings.LuceneDirectoryFactory;
-
+
if (!configuredDirectoryFactory.IsNullOrWhiteSpace())
{
//this should be a fully qualified type
diff --git a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
index f83608736f..a936de3193 100644
--- a/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
+++ b/src/Umbraco.Infrastructure/Migrations/Install/DatabaseBuilder.cs
@@ -149,7 +149,7 @@ namespace Umbraco.Core.Migrations.Install
{
_configManipulator.SaveConnectionString(EmbeddedDatabaseConnectionString, Constants.DbProviderNames.SqlCe);
- var path = Path.Combine(_hostingEnvironment.ApplicationPhysicalPath, "App_Data", "Umbraco.sdf");
+ var path = _hostingEnvironment.MapPathContentRoot("App_Data\\Umbraco.sdf");
if (File.Exists(path) == false)
{
// this should probably be in a "using (new SqlCeEngine)" clause but not sure
@@ -362,7 +362,7 @@ namespace Umbraco.Core.Migrations.Install
var hasInstalledVersion = schemaResult.DetermineHasInstalledVersion();
//var installedSchemaVersion = schemaResult.DetermineInstalledVersion();
//var hasInstalledVersion = !installedSchemaVersion.Equals(new Version(0, 0, 0));
-
+
if (!hasInstalledVersion)
{
if (_runtime.Level == RuntimeLevel.Run)
diff --git a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
index cbcf90ab9a..347589b7c8 100644
--- a/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
+++ b/src/Umbraco.Infrastructure/Runtime/CoreRuntime.cs
@@ -141,7 +141,7 @@ namespace Umbraco.Core.Runtime
NetworkHelper.MachineName);
Logger.Debug("Runtime: {Runtime}", GetType().FullName);
- AppDomain.CurrentDomain.SetData("DataDirectory", IOHelper.MapPath(Constants.SystemDirectories.Data));
+ AppDomain.CurrentDomain.SetData("DataDirectory", HostingEnvironment?.MapPathContentRoot(Constants.SystemDirectories.Data));
// application environment
ConfigureUnhandledException();
diff --git a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
index 0f76e78f29..9285849430 100644
--- a/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
+++ b/src/Umbraco.Web.Common/AspNetCore/AspNetCoreHostingEnvironment.cs
@@ -1,11 +1,8 @@
using System;
-using System.Globalization;
using System.IO;
using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.Http;
using Umbraco.Core;
using Umbraco.Core.Configuration;
-using Umbraco.Core.Logging;
namespace Umbraco.Web.Common.AspNetCore
{
@@ -77,17 +74,23 @@ namespace Umbraco.Web.Common.AspNetCore
//case LocalTempStorage.Default:
//case LocalTempStorage.Unknown:
default:
- return _localTempPath = MapPath("~/App_Data/TEMP");
+ return _localTempPath = MapPathContentRoot("~/App_Data/TEMP");
}
}
}
- public string MapPath(string path)
+ public string MapPathWebRoot(string path)
{
var newPath = path.TrimStart('~', '/').Replace('/', Path.DirectorySeparatorChar);
return Path.Combine(_webHostEnvironment.WebRootPath, newPath);
}
+ public string MapPathContentRoot(string path)
+ {
+ var newPath = path.TrimStart('~', '/').Replace('/', Path.DirectorySeparatorChar);
+ return Path.Combine(_webHostEnvironment.ContentRootPath, newPath);
+ }
+
public string ToAbsolute(string virtualPath)
{
if (!virtualPath.StartsWith("~/") && !virtualPath.StartsWith("/"))
diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json
index b8087066c9..2b9f1f04f5 100644
--- a/src/Umbraco.Web.UI.Client/package-lock.json
+++ b/src/Umbraco.Web.UI.Client/package-lock.json
@@ -3002,7 +3002,7 @@
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
- "integrity": "sha1-dHIq8y6WFOnCh6jQu95IteLxomM=",
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
}
}
@@ -3451,7 +3451,8 @@
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
- "dev": true
+ "dev": true,
+ "optional": true
}
}
},
@@ -14616,7 +14617,7 @@
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
- "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=",
+ "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"dev": true,
"requires": {
"ms": "2.0.0"
@@ -15231,13 +15232,15 @@
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
"dev": true,
+ "optional": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@@ -15253,6 +15256,7 @@
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"dev": true,
+ "optional": true,
"requires": {
"safe-buffer": "~5.1.0"
}
diff --git a/src/Umbraco.Web.UI.NetCore/appsettings.json b/src/Umbraco.Web.UI.NetCore/appsettings.json
index 29be35e386..e9d34dce46 100644
--- a/src/Umbraco.Web.UI.NetCore/appsettings.json
+++ b/src/Umbraco.Web.UI.NetCore/appsettings.json
@@ -1,6 +1,6 @@
{
"ConnectionStrings": {
- "umbracoDbDSN": ""
+ "umbracoDbDSN": "Data Source=|DataDirectory|\\Umbraco.sdf;Flush Interval=1;"
},
"Logging": {
"LogLevel": {
@@ -119,4 +119,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs
index 06e5638204..df04d5cfac 100644
--- a/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs
+++ b/src/Umbraco.Web/AspNet/AspNetHostingEnvironment.cs
@@ -44,7 +44,7 @@ namespace Umbraco.Web.Hosting
public Version IISVersion { get; }
- public string MapPath(string path)
+ public string MapPathWebRoot(string path)
{
if (HostingEnvironment.IsHosted)
return HostingEnvironment.MapPath(path);
@@ -53,6 +53,8 @@ namespace Umbraco.Web.Hosting
return ApplicationPhysicalPath + path.TrimStart("~").EnsureStartsWith("/");
}
+ public string MapPathContentRoot(string path) => MapPathWebRoot(path);
+
public string ToAbsolute(string virtualPath) => VirtualPathUtility.ToAbsolute(virtualPath, ApplicationVirtualPath);
@@ -89,7 +91,7 @@ namespace Umbraco.Web.Hosting
//case LocalTempStorage.Default:
//case LocalTempStorage.Unknown:
default:
- return _localTempPath = MapPath("~/App_Data/TEMP");
+ return _localTempPath = MapPathContentRoot("~/App_Data/TEMP");
}
}
}
diff --git a/src/Umbraco.Web/Editors/UsersController.cs b/src/Umbraco.Web/Editors/UsersController.cs
index 843b7cc583..6cc48dffae 100644
--- a/src/Umbraco.Web/Editors/UsersController.cs
+++ b/src/Umbraco.Web/Editors/UsersController.cs
@@ -108,7 +108,7 @@ namespace Umbraco.Web.Editors
throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
}
- var root = hostingEnvironment.MapPath(Constants.SystemDirectories.TempFileUploads);
+ var root = hostingEnvironment.MapPathContentRoot(Constants.SystemDirectories.TempFileUploads);
//ensure it exists
Directory.CreateDirectory(root);
var provider = new MultipartFormDataStreamProvider(root);
diff --git a/src/Umbraco.Web/Mvc/RenderViewEngine.cs b/src/Umbraco.Web/Mvc/RenderViewEngine.cs
index 46ebf2f383..5f508e8d61 100644
--- a/src/Umbraco.Web/Mvc/RenderViewEngine.cs
+++ b/src/Umbraco.Web/Mvc/RenderViewEngine.cs
@@ -48,7 +48,7 @@ namespace Umbraco.Web.Mvc
///
private void EnsureFoldersAndFiles()
{
- var viewFolder = _hostingEnvironment.MapPath(Constants.ViewLocation);
+ var viewFolder = _hostingEnvironment.MapPathContentRoot(Constants.ViewLocation);
// ensure the web.config file is in the ~/Views folder
Directory.CreateDirectory(viewFolder);
diff --git a/src/Umbraco.Web/UmbracoApplicationBase.cs b/src/Umbraco.Web/UmbracoApplicationBase.cs
index 799b627f2c..1c447b38aa 100644
--- a/src/Umbraco.Web/UmbracoApplicationBase.cs
+++ b/src/Umbraco.Web/UmbracoApplicationBase.cs
@@ -96,11 +96,11 @@ namespace Umbraco.Web
// this is not critical right now and would require loading in some config before boot time so just leaving this as-is for now.
var runtimeHashPaths = new RuntimeHashPaths();
// the bin folder and everything in it
- runtimeHashPaths.AddFolder(new DirectoryInfo(hostingEnvironment.MapPath("~/bin")));
+ runtimeHashPaths.AddFolder(new DirectoryInfo(hostingEnvironment.MapPathContentRoot("~/bin")));
// the app code folder and everything in it
- runtimeHashPaths.AddFile(new FileInfo(hostingEnvironment.MapPath("~/App_Code")));
+ runtimeHashPaths.AddFile(new FileInfo(hostingEnvironment.MapPathContentRoot("~/App_Code")));
// global.asax (the app domain also monitors this, if it changes will do a full restart)
- runtimeHashPaths.AddFile(new FileInfo(hostingEnvironment.MapPath("~/global.asax")));
+ runtimeHashPaths.AddFile(new FileInfo(hostingEnvironment.MapPathContentRoot("~/global.asax")));
var runtimeHash = new RuntimeHash(new ProfilingLogger(logger, profiler), runtimeHashPaths);
return new TypeFinder(Logger, new DefaultUmbracoAssemblyProvider(
// GetEntryAssembly was actually an exposed API by request of the aspnetcore team which works in aspnet core because a website