Revert ApplicationBasePath default resolution #641

This commit is contained in:
John Luo 2016-03-14 10:31:08 -07:00
parent 8888cfb059
commit 9ade9da2f7
2 changed files with 0 additions and 23 deletions

View File

@ -230,23 +230,6 @@ namespace Microsoft.AspNetCore.Hosting
private string ResolveApplicationBasePath(string applicationBasePath, string basePath) private string ResolveApplicationBasePath(string applicationBasePath, string basePath)
{ {
if (_startup != null)
{
var startupAssemblyLocation = _startup.ConfigureDelegate.Target.GetType().GetTypeInfo().Assembly.Location;
if (!string.IsNullOrEmpty(startupAssemblyLocation))
{
return Path.GetDirectoryName(startupAssemblyLocation);
}
}
else if (_startupType != null)
{
var startupAssemblyLocation = _startupType.GetTypeInfo().Assembly.Location;
if (!string.IsNullOrEmpty(startupAssemblyLocation))
{
return Path.GetDirectoryName(startupAssemblyLocation);
}
}
if (string.IsNullOrEmpty(applicationBasePath)) if (string.IsNullOrEmpty(applicationBasePath))
{ {
return basePath; return basePath;

View File

@ -352,12 +352,10 @@ namespace Microsoft.AspNetCore.Hosting
var host = new WebHostBuilder() var host = new WebHostBuilder()
.UseServer(new TestServer()) .UseServer(new TestServer())
.UseStartup("Microsoft.AspNetCore.Hosting.Tests") .UseStartup("Microsoft.AspNetCore.Hosting.Tests")
.UseApplicationBasePath("/foo/bar")
.Build(); .Build();
var appEnv = host.Services.GetService<IApplicationEnvironment>(); var appEnv = host.Services.GetService<IApplicationEnvironment>();
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", appEnv.ApplicationName); Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", appEnv.ApplicationName);
Assert.Equal("/foo/bar", appEnv.ApplicationBasePath);
} }
[Fact] [Fact]
@ -368,12 +366,10 @@ namespace Microsoft.AspNetCore.Hosting
.UseServer(new TestServer()) .UseServer(new TestServer())
.UseStartup<StartupNoServices>() .UseStartup<StartupNoServices>()
.UseStartup("Microsoft.AspNetCore.Hosting.Tests.NonExistent") .UseStartup("Microsoft.AspNetCore.Hosting.Tests.NonExistent")
.UseApplicationBasePath("/foo/bar")
.Build(); .Build();
var appEnv = host.Services.GetService<IApplicationEnvironment>(); var appEnv = host.Services.GetService<IApplicationEnvironment>();
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", appEnv.ApplicationName); Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", appEnv.ApplicationName);
Assert.Equal(Path.GetDirectoryName(typeof(WebHostBuilderTests).GetTypeInfo().Assembly.Location), appEnv.ApplicationBasePath);
} }
[Fact] [Fact]
@ -384,12 +380,10 @@ namespace Microsoft.AspNetCore.Hosting
.UseServer(new TestServer()) .UseServer(new TestServer())
.Configure(app => { }) .Configure(app => { })
.UseStartup("Microsoft.AspNetCore.Hosting.Tests.NonExistent") .UseStartup("Microsoft.AspNetCore.Hosting.Tests.NonExistent")
.UseApplicationBasePath("/foo/bar")
.Build(); .Build();
var appEnv = host.Services.GetService<IApplicationEnvironment>(); var appEnv = host.Services.GetService<IApplicationEnvironment>();
Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", appEnv.ApplicationName); Assert.Equal("Microsoft.AspNetCore.Hosting.Tests", appEnv.ApplicationName);
Assert.Equal(Path.GetDirectoryName(typeof(WebHostBuilderTests).GetTypeInfo().Assembly.Location), appEnv.ApplicationBasePath);
} }
private IWebHostBuilder CreateWebHostBuilder() private IWebHostBuilder CreateWebHostBuilder()