Fixed RemoteWindowsDeployer to copy dontet runtime to target server for enabling portable apps scenario

This commit is contained in:
Kiran Challa 2016-05-26 15:10:57 -07:00
parent f60aa7aa70
commit bb3555c3dc
4 changed files with 42 additions and 5 deletions

View File

@ -9,6 +9,9 @@ param(
[Parameter(Mandatory=$true)]
[string]$accountPassword,
[Parameter(Mandatory=$false)]
[string]$dotnetRuntimePath = "",
[Parameter(Mandatory=$true)]
[string]$executablePath,
@ -40,7 +43,7 @@ if ($serverAction -eq "StartServer")
{
Write-Host "Starting the application on machine '$serverName'"
$startServerScriptPath = "$PSScriptRoot\StartServer.ps1"
$remoteResult=Invoke-Command -Session $psSession -FilePath $startServerScriptPath -ArgumentList $executablePath, $executableParameters, $serverType, $serverName, $applicationBaseUrl, $environmentVariables
$remoteResult=Invoke-Command -Session $psSession -FilePath $startServerScriptPath -ArgumentList $dotnetRuntimePath, $executablePath, $executableParameters, $serverType, $serverName, $applicationBaseUrl, $environmentVariables
}
else
{
@ -54,5 +57,8 @@ Remove-PSSession $psSession
# 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.
$finalExitCode=$remoteResult[$remoteResult.Length-1]
exit $finalExitCode
if($remoteResult.Length > 0)
{
$finalExitCode=$remoteResult[$remoteResult.Length-1]
exit $finalExitCode
}

View File

@ -53,6 +53,13 @@ namespace Microsoft.AspNetCore.Server.Testing
" Account credentials are required to enable creating a powershell session to the remote server.");
}
if (_deploymentParameters.ApplicationType == ApplicationType.Portable
&& string.IsNullOrWhiteSpace(_deploymentParameters.DotnetRuntimePath))
{
throw new ArgumentException($"Invalid value '{_deploymentParameters.DotnetRuntimePath}' for {nameof(RemoteWindowsDeploymentParameters.DotnetRuntimePath)}. " +
"It must be non-empty for portable apps.");
}
if (string.IsNullOrWhiteSpace(_deploymentParameters.RemoteServerFileSharePath))
{
throw new ArgumentException($"Invalid value for {nameof(RemoteWindowsDeploymentParameters.RemoteServerFileSharePath)}." +
@ -155,6 +162,12 @@ namespace Microsoft.AspNetCore.Server.Testing
parameterBuilder.Append($" -serverName {_deploymentParameters.ServerName}");
parameterBuilder.Append($" -accountName {_deploymentParameters.ServerAccountName}");
parameterBuilder.Append($" -accountPassword {_deploymentParameters.ServerAccountPassword}");
if (!string.IsNullOrEmpty(_deploymentParameters.DotnetRuntimePath))
{
parameterBuilder.Append($" -dotnetRuntimePath \"{_deploymentParameters.DotnetRuntimePath}\"");
}
parameterBuilder.Append($" -executablePath \"{executablePath}\"");
if (!string.IsNullOrEmpty(executableParameters))

View File

@ -7,6 +7,7 @@ namespace Microsoft.AspNetCore.Server.Testing
{
public RemoteWindowsDeploymentParameters(
string applicationPath,
string dotnetRuntimePath,
ServerType serverType,
RuntimeFlavor runtimeFlavor,
RuntimeArchitecture runtimeArchitecture,
@ -20,6 +21,7 @@ namespace Microsoft.AspNetCore.Server.Testing
ServerName = remoteServerName;
ServerAccountName = remoteServerAccountName;
ServerAccountPassword = remoteServerAccountPassword;
DotnetRuntimePath = dotnetRuntimePath;
}
public string ServerName { get; }
@ -28,6 +30,8 @@ namespace Microsoft.AspNetCore.Server.Testing
public string ServerAccountPassword { get; }
public string DotnetRuntimePath { get; }
/// <summary>
/// The full path to the remote server's file share
/// </summary>

View File

@ -1,5 +1,8 @@
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)]
[string]$dotnetRuntimePath,
[Parameter(Mandatory=$true)]
[string]$executablePath,
@ -31,8 +34,19 @@ IF (-Not [string]::IsNullOrWhitespace($environmentVariables))
}
}
# Temporary workaround for issue https://github.com/dotnet/cli/issues/2967
if ($executablePath -ne "dotnet.exe"){
if ($executablePath -eq "dotnet.exe")
{
Write-Host "Setting the dotnet runtime path to the PATH environment variable"
[Environment]::SetEnvironmentVariable("PATH", "$dotnetRuntimePath")
}
Write-Host "Copying shell32.dll as a temporary workaround for issue https://github.com/dotnet/cli/issues/2967"
if ($executablePath -eq "dotnet.exe")
{
Copy-Item C:\Windows\System32\forwarders\shell32.dll $dotnetRuntimePath
}
else
{
$destinationDir = Split-Path $executablePath
Copy-Item C:\Windows\System32\forwarders\shell32.dll $destinationDir
}