#233 Create the wwwroot directory if it doesn't exist.

This commit is contained in:
Chris R 2015-06-15 11:11:08 -07:00
parent c2b638d85b
commit 736e6bee2b
1 changed files with 5 additions and 0 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using Microsoft.AspNet.FileProviders;
using Microsoft.AspNet.Hosting.Internal;
@ -11,6 +12,10 @@ namespace Microsoft.AspNet.Hosting
public static void Initialize(this IHostingEnvironment hostingEnvironment, string applicationBasePath, string environmentName)
{
hostingEnvironment.WebRootPath = HostingUtilities.GetWebRoot(applicationBasePath);
if (!Directory.Exists(hostingEnvironment.WebRootPath))
{
Directory.CreateDirectory(hostingEnvironment.WebRootPath);
}
hostingEnvironment.WebRootFileProvider = new PhysicalFileProvider(hostingEnvironment.WebRootPath);
hostingEnvironment.EnvironmentName = environmentName ?? hostingEnvironment.EnvironmentName;
}