Run self-host tests with no-build. #1399
This commit is contained in:
parent
9e36855d2f
commit
1717b97444
|
|
@ -4,6 +4,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
||||
{
|
||||
|
|
@ -45,6 +46,12 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
ServerType = serverType;
|
||||
RuntimeFlavor = runtimeFlavor;
|
||||
EnvironmentVariables["ASPNETCORE_DETAILEDERRORS"] = "true";
|
||||
|
||||
var configAttribute = Assembly.GetCallingAssembly().GetCustomAttribute<AssemblyConfigurationAttribute>();
|
||||
if (configAttribute != null && !string.IsNullOrEmpty(configAttribute.Configuration))
|
||||
{
|
||||
Configuration = configAttribute.Configuration;
|
||||
}
|
||||
}
|
||||
|
||||
public ServerType ServerType { get; }
|
||||
|
|
|
|||
|
|
@ -93,9 +93,7 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting
|
|||
var targetFramework = DeploymentParameters.TargetFramework ?? (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr ? "net461" : "netcoreapp2.0");
|
||||
|
||||
executableName = DotnetCommandName;
|
||||
// Set VerifyMatchingImplicitPackageVersion to disable errors when Microsoft.NETCore.App's version is overridden externally
|
||||
// This verification doesn't matter if we are skipping restore during tests.
|
||||
executableArgs = $"run --no-restore --framework {targetFramework} /p:VerifyMatchingImplicitPackageVersion=false {DotnetArgumentSeparator}";
|
||||
executableArgs = $"run --no-build -c {DeploymentParameters.Configuration} --framework {targetFramework} {DotnetArgumentSeparator}";
|
||||
}
|
||||
|
||||
executableArgs += $" --server.urls {hintUrl} "
|
||||
|
|
|
|||
|
|
@ -13,13 +13,16 @@ namespace IStartupInjectionAssemblyName
|
|||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var server = new TestServer(CreateWebHostBuilder(args));
|
||||
|
||||
Task.Run(async () => Console.WriteLine(await server.CreateClient().GetStringAsync(""))).GetAwaiter().GetResult();
|
||||
var webHost = CreateWebHostBuilder(args).Build();
|
||||
var applicationName = webHost.Services.GetRequiredService<IHostingEnvironment>().ApplicationName;
|
||||
Console.WriteLine(applicationName);
|
||||
Console.ReadKey();
|
||||
}
|
||||
|
||||
// Do not change the signature of this method. It's used for tests.
|
||||
private static IWebHostBuilder CreateWebHostBuilder(string [] args) =>
|
||||
new WebHostBuilder().SuppressStatusMessages(true).ConfigureServices(services => services.AddSingleton<IStartup, Startup>());
|
||||
new WebHostBuilder()
|
||||
.SuppressStatusMessages(true)
|
||||
.ConfigureServices(services => services.AddSingleton<IStartup, Startup>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ namespace IStartupInjectionAssemblyName
|
|||
{
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
var applicationName = app.ApplicationServices.GetRequiredService<IHostingEnvironment>().ApplicationName;
|
||||
app.Run(context =>
|
||||
{
|
||||
return context.Response.WriteAsync(applicationName);
|
||||
});
|
||||
}
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
|
|
|
|||
Loading…
Reference in New Issue