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
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
<!-- the following package(s) are from the powershell org -->
<PackageReference Include="Microsoft.Management.Infrastructure" Version="1.0.0-alpha*" />
<PackageReference Include="PowerShell.Core.Instrumentation" Version="6.0.0-beta*" />
<PackageReference Include="Microsoft.Management.Infrastructure" Version="1.0.0" />
<PackageReference Include="Microsoft.PowerShell.Native" Version="6.1.0-rc.1" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 0 additions & 2 deletions src/powershell-unix/powershell-unix.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="libpsl" Version="6.0.0-*" />
<PackageReference Include="psrp" Version="1.4.5-*" />
<PackageReference Include="PSDesiredStateConfiguration" Version="6.0.0-beta.8" />
<PackageReference Include="PowerShellHelpFiles" Version="1.0.0-*" />
</ItemGroup>
Expand Down
9 changes: 4 additions & 5 deletions src/powershell-win-core/powershell-win-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="..\powershell-win-core\pwsh-preview.cmd">
<Link>preview\pwsh-preview.cmd</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\powershell-win-core\pwsh-preview.cmd">
<Link>preview\pwsh-preview.cmd</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>

<ItemGroup>
Expand All @@ -40,7 +40,6 @@
<ItemGroup>
<PackageReference Include="PSDesiredStateConfiguration" Version="6.0.0-beta.8" />
<PackageReference Include="PowerShellHelpFiles" Version="1.0.0-*" />
<PackageReference Include="psrp.windows" Version="6.1.0-*" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion test/hosting/NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<configuration>
<packageSources>
<clear />
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
</packageSources>
Expand Down
4 changes: 3 additions & 1 deletion test/hosting/hosting.tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
<PackageReference Include="xunit" Version="2.4.0" />
<!-- DotNetCliToolReference element specifies the CLI tool that the user wants to restore in the context of the project. -->
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.0.2" />
<!-- The version of Microsoft.PowerShell.SDK should be the version we are releasing, so the tests use the correct SDK before publishing to NuGet.org -->
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.1.0-rc.1" />
<PackageReference Include="Xunit.SkippableFact" Version="1.3.6" />
</ItemGroup>

</Project>
90 changes: 89 additions & 1 deletion test/hosting/test_HostingBasic.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Xunit;
using System;
using System.IO;
using System.Management.Automation;
using System.Security;
using Microsoft.Management.Infrastructure;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't M come before S?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All System* namespaces must be listed at top.

using Xunit;

namespace PowerShell.Hosting.SDK.Tests
{
Expand Down Expand Up @@ -51,5 +54,90 @@ public static void TestCommandFromCore()
}
}
}

[SkippableFact]
public static void TestCommandFromMMI()
{
// Test is disabled since we do not have a CimCmdlets module released in the SDK.
Skip.IfNot(Platform.IsWindows);
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
var results = ps.AddScript("[Microsoft.Management.Infrastructure.CimInstance]::new('Win32_Process')").Invoke();
Assert.True(results.Count > 0);
}
}

[SkippableFact]
public static void TestCommandFromDiagnostics()
{
Skip.IfNot(Platform.IsWindows);
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
var results = ps.AddScript("Get-WinEvent -ListLog Application").Invoke();

foreach (dynamic item in results)
{
Assert.Equal("Application", item.LogName);
}
}
}

[SkippableFact]
public static void TestCommandFromSecurity()
{
Skip.IfNot(Platform.IsWindows);
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
var results = ps.AddScript("ConvertTo-SecureString -String test -AsPlainText -Force").Invoke<SecureString>();
Assert.IsType<SecureString>(results[0]);
}
}

[SkippableFact]
public static void TestCommandFromWSMan()
{
Skip.IfNot(Platform.IsWindows);
using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
var results = ps.AddScript("Test-WSMan").Invoke();

foreach (dynamic item in results)
{
Assert.Equal("Microsoft Corporation", item.ProductVendor);
}
}
}

[Fact]
public static void TestCommandFromNative()
{
var fs = File.Create(Path.GetTempFileName());
fs.Close();

string target = fs.Name;
string path = Path.GetTempFileName();

using (System.Management.Automation.PowerShell ps = System.Management.Automation.PowerShell.Create())
{
// New-Item -ItemType SymbolicLink uses libpsl-native, hence using it for validating native dependencies.
string command = $"New-Item -ItemType SymbolicLink -Path {path} -Target {target}";
var results = ps.AddScript(command).Invoke<FileInfo>();

foreach (var item in results)
{
Assert.Equal(path, item.FullName);
}
}

if (File.Exists(path))
{
File.Delete(path);
}

if (File.Exists(target))
{
File.Delete(target);
}
}
}
}