Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/hosting/test_HostingBasic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Management.Automation;
using System.Security;
using Microsoft.Management.Infrastructure;
using Microsoft.PowerShell;
using Xunit;

namespace PowerShell.Hosting.SDK.Tests
Expand Down Expand Up @@ -174,5 +175,12 @@ public Foo(string name, string path)
Assert.Equal("Unknown", foo.Path);
}
}

[Fact]
public static void TestConsoleShellScenario()
{
int ret = ConsoleShell.Start("Hello", string.Empty, new string[] { "-noprofile", "-c", "exit 42" });
Assert.Equal(42, ret);
}
}
}
21 changes: 12 additions & 9 deletions tools/packaging/packaging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1745,11 +1745,15 @@ function CopyReferenceAssemblies
[string[]] $assemblyFileList
)

$supportedRefList = @(
"Microsoft.PowerShell.Commands.Utility",
"Microsoft.PowerShell.ConsoleHost")

switch ($assemblyName) {
"Microsoft.PowerShell.Commands.Utility" {
$ref_Utility = Join-Path -Path $refBinPath -ChildPath Microsoft.PowerShell.Commands.Utility.dll
Copy-Item $ref_Utility -Destination $refNugetPath -Force
Write-Log "Copied file $ref_Utility to $refNugetPath"
{ $_ -in $supportedRefList } {
$refDll = Join-Path -Path $refBinPath -ChildPath "$assemblyName.dll"
Copy-Item $refDll -Destination $refNugetPath -Force
Write-Log "Copied file $refDll to $refNugetPath"
}

"Microsoft.PowerShell.SDK" {
Expand Down Expand Up @@ -1931,7 +1935,8 @@ function New-ReferenceAssembly
$SMAReferenceAssembly = $null
$assemblyNames = @(
"System.Management.Automation",
"Microsoft.PowerShell.Commands.Utility"
"Microsoft.PowerShell.Commands.Utility",
"Microsoft.PowerShell.ConsoleHost"
)

foreach ($assemblyName in $assemblyNames) {
Expand Down Expand Up @@ -2119,10 +2124,8 @@ function GenerateBuildArguments
$arguments += "/p:RefAsmVersion=$RefAssemblyVersion"
$arguments += "/p:SnkFile=$SnkFilePath"

switch ($AssemblyName) {
"Microsoft.PowerShell.Commands.Utility" {
$arguments += "/p:SmaRefFile=$SMAReferencePath"
}
if ($AssemblyName -ne "System.Management.Automation") {
$arguments += "/p:SmaRefFile=$SMAReferencePath"
}

return $arguments
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Version>$(RefAsmVersion)</Version>
<DelaySign>true</DelaySign>
<AssemblyOriginatorKeyFile>$(SnkFile)</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<LangVersion>Latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Management.Automation">
<HintPath>$(SmaRefFile)</HintPath>
</Reference>
</ItemGroup>
</Project>