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