Fixed RemoteWindowsDeployer for testing portable apps and temporary workaround for a dotnet cli issue

This commit is contained in:
Kiran Challa 2016-05-26 10:09:53 -07:00
parent 7f4e3645f2
commit be7069b198
3 changed files with 35 additions and 12 deletions

View File

@ -5,13 +5,16 @@ param(
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$accountName, [string]$accountName,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$accountPassword, [string]$accountPassword,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$executablePath, [string]$executablePath,
[Parameter(Mandatory=$false)]
[string]$executableParameters,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$serverType, [string]$serverType,
@ -37,7 +40,7 @@ if ($serverAction -eq "StartServer")
{ {
Write-Host "Starting the application on machine '$serverName'" Write-Host "Starting the application on machine '$serverName'"
$startServerScriptPath = "$PSScriptRoot\StartServer.ps1" $startServerScriptPath = "$PSScriptRoot\StartServer.ps1"
$remoteResult=Invoke-Command -Session $psSession -FilePath $startServerScriptPath -ArgumentList $executablePath, $serverType, $serverName, $applicationBaseUrl, $environmentVariables $remoteResult=Invoke-Command -Session $psSession -FilePath $startServerScriptPath -ArgumentList $executablePath, $executableParameters, $serverType, $serverName, $applicationBaseUrl, $environmentVariables
} }
else else
{ {
@ -50,6 +53,6 @@ else
Remove-PSSession $psSession Remove-PSSession $psSession
# NOTE: Currenty there is no straight forward way to get the exit code from a remotely executing session, so # NOTE: Currenty there is no straight forward way to get the exit code from a remotely executing session, so
# we print out the exit code in the remote script and capture it's output to get the exit code. # we print out the exit code in the remote script and capture it's output to get the exit code.
$finalExitCode=$remoteResult[$remoteResult.Length-1] $finalExitCode=$remoteResult[$remoteResult.Length-1]
exit $finalExitCode exit $finalExitCode

View File

@ -138,10 +138,12 @@ namespace Microsoft.AspNetCore.Server.Testing
var remotePSSessionHelperScript = _scripts.Value.RemotePSSessionHelper; var remotePSSessionHelperScript = _scripts.Value.RemotePSSessionHelper;
string executablePath = null; string executablePath = null;
string executableParameters = null;
var applicationName = new DirectoryInfo(DeploymentParameters.ApplicationPath).Name; var applicationName = new DirectoryInfo(DeploymentParameters.ApplicationPath).Name;
if (DeploymentParameters.ApplicationType == ApplicationType.Portable) if (DeploymentParameters.ApplicationType == ApplicationType.Portable)
{ {
executablePath = $"dotnet {applicationName}.dll"; executablePath = "dotnet.exe";
executableParameters = Path.Combine(_deployedFolderPathInFileShare, applicationName + ".dll");
} }
else else
{ {
@ -153,7 +155,13 @@ namespace Microsoft.AspNetCore.Server.Testing
parameterBuilder.Append($" -serverName {_deploymentParameters.ServerName}"); parameterBuilder.Append($" -serverName {_deploymentParameters.ServerName}");
parameterBuilder.Append($" -accountName {_deploymentParameters.ServerAccountName}"); parameterBuilder.Append($" -accountName {_deploymentParameters.ServerAccountName}");
parameterBuilder.Append($" -accountPassword {_deploymentParameters.ServerAccountPassword}"); parameterBuilder.Append($" -accountPassword {_deploymentParameters.ServerAccountPassword}");
parameterBuilder.Append($" -executablePath \'{executablePath}\'"); parameterBuilder.Append($" -executablePath \"{executablePath}\"");
if (!string.IsNullOrEmpty(executableParameters))
{
parameterBuilder.Append($" -executableParameters \"{executableParameters}\"");
}
parameterBuilder.Append($" -serverType {_deploymentParameters.ServerType}"); parameterBuilder.Append($" -serverType {_deploymentParameters.ServerType}");
parameterBuilder.Append($" -serverAction {serverAction}"); parameterBuilder.Append($" -serverAction {serverAction}");
parameterBuilder.Append($" -applicationBaseUrl {_deploymentParameters.ApplicationBaseUriHint}"); parameterBuilder.Append($" -applicationBaseUrl {_deploymentParameters.ApplicationBaseUriHint}");

View File

@ -2,7 +2,10 @@
param( param(
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$executablePath, [string]$executablePath,
[Parameter(Mandatory=$false)]
[string]$executableParameters,
[Parameter(Mandatory=$true)] [Parameter(Mandatory=$true)]
[string]$serverType, [string]$serverType,
@ -28,19 +31,28 @@ IF (-Not [string]::IsNullOrWhitespace($environmentVariables))
} }
} }
# Temporary workaround for issue https://github.com/dotnet/cli/issues/2967
if ($executablePath -ne "dotnet.exe"){
$destinationDir = Split-Path $executablePath
Copy-Item C:\Windows\System32\forwarders\shell32.dll $destinationDir
}
$command = $executablePath + " " + $executableParameters + " --server.urls " + $applicationBaseUrl
if ($serverType -eq "IIS") if ($serverType -eq "IIS")
{ {
throw [System.NotImplementedException] "IIS deployment scenarios not yet implemented." throw [System.NotImplementedException] "IIS deployment scenarios not yet implemented."
} }
elseif ($serverType -eq "Kestrel") elseif ($serverType -eq "Kestrel")
{ {
Write-Host "Starting the process '$executablePath'" $command = $command + " --server Microsoft.AspNetCore.Server.Kestrel"
& $executablePath --server.urls $applicationBaseUrl Write-Host "Executing the command '$command'"
Invoke-Expression $command
} }
elseif ($serverType -eq "WebListener") elseif ($serverType -eq "WebListener")
{ {
Write-Host "Starting the process '$executablePath'" $command = $command + " --server Microsoft.AspNetCore.Server.WebListener"
& $executablePath --server.urls $applicationBaseUrl --server "Microsoft.AspNetCore.Server.WebListener" Write-Host "Executing the command '$command'"
Invoke-Expression $command
} }
else else
{ {