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
1 change: 1 addition & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ writingpestertests.md
WSMan
wsmansessionoption.cs
xUnit
0-powershell-crossplatform
#endregion

#region ./tools/install-powershell.readme.md Overrides
Expand Down
16 changes: 10 additions & 6 deletions docs/host-powershell/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Host PowerShell Core in .NET Core Applications

## PowerShell Core v6.0.1 and Later

The runtime assemblies for Windows, Linux and OSX are now published in NuGet package version 6.0.1.1 and above.

Please see the [.NET Core Sample Application](#net-core-sample-application) section for an example that uses PowerShell Core `6.0.1.1` NuGet packages.

## PowerShell Core v6.0.0-beta.3 and Later

PowerShell Core is refactored in v6.0.0-beta.3 to remove the dependency on a customized `AssemblyLoadContext`.
Expand Down Expand Up @@ -138,6 +144,7 @@ namespace Application.Test
.NET Core SDK `2.0.0-preview1-005952` or higher is required.
- [sample-dotnet2.0-powershell.beta.3](./sample-dotnet2.0-powershell.beta.3) - .NET Core `2.0.0` + PowerShell Core `beta.3` NuGet packages.
.NET Core SDK `2.0.0-preview1-005952` or higher is required.
- [sample-dotnet2.0-powershell-crossplatform](./sample-dotnet2.0-powershell-crossplatform) - .Net Core `2.0.0` + PowerShell Core `6.0.1.1` NuGet packages.

You can find the sample application project `"MyApp"` in each of the above 3 sample folders.
To build the sample project, run the following commands (make sure the required .NET Core SDK is in use):
Expand All @@ -147,6 +154,9 @@ dotnet restore .\MyApp\MyApp.csproj
dotnet publish .\MyApp -c release -r win10-x64
```

For cross platform project there is no need to specify `-r win10-x64`.
The runtime for the build machine's platform will automatically be selected.

Then you can run `MyApp.exe` from the publish folder and see the results:

```none
Expand All @@ -161,9 +171,3 @@ Evaluating '([S.M.A.ActionPreference], [S.M.A.AliasAttribute]).FullName' in PS C
System.Management.Automation.ActionPreference
System.Management.Automation.AliasAttribute
```

## Remaining Issue

PowerShell Core builds separately for Windows and Unix, so the assemblies are different between Windows and Unix platforms.
Unfortunately, all PowerShell NuGet packages that have been published so far only contain PowerShell assemblies built specifically for Windows.
The issue [#3417](https://github.com/PowerShell/PowerShell/issues/3417) was opened to track publishing PowerShell NuGet packages for Unix platforms.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a readme.md for this sample

Copy link
Member

Choose a reason for hiding this comment

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

make sure it's covered by the markdown tests.

Copy link
Member

Choose a reason for hiding this comment

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

Don't add a new readme.md. Instead, add a new section to https://github.com/PowerShell/PowerShell/blob/master/docs/host-powershell/README.md

The new section should be the first section, called PowerShell Core v6.0.1.1 and Later

Copy link
Member Author

Choose a reason for hiding this comment

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

Added new section.


<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<AssemblyName>MyApp</AssemblyName>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win10-x64;linux-x64;osx.10.12-x64</RuntimeIdentifiers>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.0.1.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Management.Automation;

namespace Application.Test
{
public class Program
{
/// <summary>
/// Managed entry point shim, which starts the actual program
/// </summary>
public static int Main(string[] args)
{
using (PowerShell ps = PowerShell.Create())
{
Console.WriteLine("\nEvaluating 'Get-Command Write-Output' in PS Core Runspace\n");
var results = ps.AddScript("Get-Command Write-Output").Invoke();
Console.WriteLine(results[0].ToString());
}
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<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" />
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
</packageSources>
</configuration>
13 changes: 3 additions & 10 deletions docs/maintainers/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,9 @@ Start-PSPackage -Type zip -ReleaseTag v6.0.0-beta.1 -WindowsRuntime 'win7-x64'

## NuGet Packages

In the `release` branch, run `Publish-NuGetFeed` to generate PowerShell NuGet packages:

```powershell
# Assume the to-be-used release tag is 'v6.0.0-beta.1'
Publish-NuGetFeed -ReleaseTag 'v6.0.0-beta.1'
```

PowerShell NuGet packages and the corresponding symbol packages will be generated at `PowerShell/nuget-artifacts` by default.
Currently the NuGet packages published to [powershell-core feed][ps-core-feed] only contain assemblies built for Windows.
Maintainers are working on including the assemblies built for non-Windows platforms.
The NuGet packages for hosting PowerShell for Windows and non-Windows are being built in our release build pipeline.
The assemblies from the individual Windows and Linux builds are consumed and packed into NuGet packages.
These are then released to [powershell-core feed][ps-core-feed].

[ps-core-feed]: https://powershell.myget.org/gallery/powershell-core

Expand Down
2 changes: 1 addition & 1 deletion tools/packaging/packaging.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CompanyName="Microsoft Corporation"
Copyright="Copyright (c) Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.0"
PowerShellVersion="5.0"
CmdletsToExport=@("Start-PSPackage",'New-PSSignedBuildZip')
CmdletsToExport=@("Start-PSPackage",'New-PSSignedBuildZip', 'New-UnifiedNugetPackage')
RootModule="packaging.psm1"
RequiredModules = @("build")
}
Loading