diff --git a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs
index cd17ba1d..b0b77079 100644
--- a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs
+++ b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs
@@ -69,6 +69,8 @@ public DeploymentParameters(
public string ApplicationPath { get; set; }
+ public string TargetFramework { get; set; }
+
///
/// To publish the application before deployment.
///
@@ -76,8 +78,6 @@ public DeploymentParameters(
public ApplicationType ApplicationType { get; set; }
- public string PublishTargetFramework { get; set; }
-
public string PublishedApplicationRootPath { get; set; }
///
diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs
index 5c3c710c..4b49e777 100644
--- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs
+++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs
@@ -40,7 +40,7 @@ public ApplicationDeployer(DeploymentParameters deploymentParameters, ILogger lo
protected void DotnetPublish(string publishRoot = null)
{
- if (string.IsNullOrEmpty(DeploymentParameters.PublishTargetFramework))
+ if (string.IsNullOrEmpty(DeploymentParameters.TargetFramework))
{
throw new Exception($"A target framework must be specified in the deployment parameters for applications that require publishing before deployment");
}
@@ -49,7 +49,7 @@ protected void DotnetPublish(string publishRoot = null)
var parameters = $"publish \"{DeploymentParameters.ApplicationPath}\""
+ $" -o \"{DeploymentParameters.PublishedApplicationRootPath}\""
- + $" --framework {DeploymentParameters.PublishTargetFramework}";
+ + $" --framework {DeploymentParameters.TargetFramework}";
Logger.LogInformation($"Executing command {DotnetCommandName} {parameters}");
diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs
index 210a61cf..976a0689 100644
--- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs
+++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs
@@ -74,8 +74,10 @@ protected CancellationToken StartSelfHost(Uri uri)
}
else
{
+ var targetFramework = DeploymentParameters.TargetFramework ?? (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.Clr ? "net451" : "netcoreapp1.0");
+
executableName = DotnetCommandName;
- executableArgs = $"run -p \"{DeploymentParameters.ApplicationPath}\" {DotnetArgumentSeparator}";
+ executableArgs = $"run -p \"{DeploymentParameters.ApplicationPath}\" --framework {targetFramework} {DotnetArgumentSeparator}";
}
executableArgs += $" --server.urls {uri} "