Skip to content

Commit 449cc21

Browse files
committed
Migrate to netstandard2.0 and PSStandard (#741)
* Move PSES builds to netstandard and use PSStandard APIs * Add shim modules for Windows PowerShell and PowerShell Core 6.0 * Migrate tests to run on .NET Core and on *nix * Make build file more declarative * Use latest xunit * Exclude host integration tests * Clean out csproj files * Fix up Travis build * Retire compatibility APIs for PowerShell v3/4 * Introduce test hook for using InitialSessionState.CreateDefault2() when running on PowerShell Core SDK * Fix session details gathering in nested prompts To create a nested PowerShell instance you can't set the runspace because the target runspace is assumed to be the runspace in TLS. [Ignore] Fix test typos [Ignore] Use correct AppVeyor version
1 parent ca987b5 commit 449cc21

File tree

74 files changed

+811
-853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+811
-853
lines changed

.travis.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ language: cpp
33
git:
44
depth: 1000
55

6-
os:
7-
- linux
8-
- osx
9-
sudo: required
10-
dist: trusty
11-
osx_image: xcode8.3
6+
matrix:
7+
include:
8+
- os: linux
9+
dist: trusty
10+
sudo: required
11+
- os: osx
12+
osx_image: xcode9.4
1213

1314
before_install:
1415
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then

PowerShellEditorServices.Common.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>1.10.3</VersionPrefix>
3+
<VersionPrefix>2.0.0</VersionPrefix>
44
<Company>Microsoft</Company>
55
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
66
<PackageTags>PowerShell;editor;development;language;debugging</PackageTags>
@@ -9,6 +9,5 @@
99
<RepositoryType>git</RepositoryType>
1010
<RepositoryUrl>https://github.com/PowerShell/PowerShellEditorServices</RepositoryUrl>
1111
<DebugType>portable</DebugType>
12-
<RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
1312
</PropertyGroup>
1413
</Project>

PowerShellEditorServices.build.ps1

Lines changed: 213 additions & 92 deletions
Large diffs are not rendered by default.

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '1.10.3{build}'
1+
version: '2.0.0-{build}'
22
image: Visual Studio 2017
33
clone_depth: 10
44
skip_tags: true

module/PowerShellEditorServices.VSCode/PowerShellEditorServices.VSCode.psm1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
#
55

6-
if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") {
7-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.VSCode.dll"
8-
}
9-
else {
10-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.VSCode.dll"
11-
}
6+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.VSCode.dll"
127

138
if ($psEditor -is [Microsoft.PowerShell.EditorServices.Extensions.EditorObject]) {
149
[Microsoft.PowerShell.EditorServices.VSCode.ComponentRegistration]::Register($psEditor.Components)

module/PowerShellEditorServices/PowerShellEditorServices.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PowerShellEditorServices.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.10.3'
15+
ModuleVersion = '2.0.0'
1616

1717
# ID used to uniquely identify this module
1818
GUID = '9ca15887-53a2-479a-9cda-48d26bcb6c47'

module/PowerShellEditorServices/PowerShellEditorServices.psm1

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@
33
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
44
#
55

6-
if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") {
7-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.dll"
8-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.Host.dll"
9-
}
10-
else {
11-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.dll"
12-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Protocol.dll"
13-
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.Host.dll"
6+
# Need to load pipe handling shim assemblies in Windows PowerShell and PSCore 6.0 because they don't have WCP
7+
if ($PSEdition -eq 'Desktop') {
8+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/System.IO.Pipes.AccessControl.dll"
9+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/System.Security.AccessControl.dll"
10+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/System.Security.Principal.Windows.dll"
11+
} elseif ($PSVersionTable.PSVersion -ge '6.0' -and $PSVersionTable.PSVersion -lt '6.1' -and $IsWindows) {
12+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/6.0/System.IO.Pipes.AccessControl.dll"
13+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/6.0/System.Security.AccessControl.dll"
14+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/6.0/System.Security.Principal.Windows.dll"
1415
}
1516

17+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.dll"
18+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.Host.dll"
19+
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.Protocol.dll"
20+
1621
function Start-EditorServicesHost {
1722
[CmdletBinding()]
1823
param(

scripts/travis.ps1

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose
2-
powershell -Command { Install-Module -Name PowershellGet -MinimumVersion 1.6 -Scope CurrentUser -force -confirm:$false -verbose }
3-
powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Scope CurrentUser -Force -Confirm:$false -Verbose }
4-
Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force
5-
Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force
6-
Install-PackageProvider -Name NuGet -Force | Out-Null
7-
Import-PackageProvider NuGet -Force | Out-Null
8-
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
1+
$ErrorActionPreference = 'Stop'
92

103
# Install InvokeBuild
114
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force

src/PowerShellEditorServices.Host/EditorServicesHost.cs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ public EditorServicesHost(
125125
#endif
126126

127127
// Catch unhandled exceptions for logging purposes
128-
#if !CoreCLR
129128
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
130-
#endif
131129
}
132130

133131
#endregion
@@ -146,11 +144,8 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
146144
.AddLogFile(logFilePath)
147145
.Build();
148146

149-
#if CoreCLR
150-
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(this.GetType().GetTypeInfo().Assembly.Location);
151-
#else
152-
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(this.GetType().Assembly.Location);
153-
#endif
147+
FileVersionInfo fileVersionInfo =
148+
FileVersionInfo.GetVersionInfo(this.GetType().GetTypeInfo().Assembly.Location);
154149

155150
string osVersion = RuntimeInformation.OSDescription;
156151

@@ -239,7 +234,7 @@ private async void OnLanguageServiceClientConnect(
239234
await this.editorSession.PowerShellContext.ImportCommandsModule(
240235
Path.Combine(
241236
Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location),
242-
@"..\..\Commands"));
237+
@"..\Commands"));
243238

244239
this.languageServer.Start();
245240

@@ -454,19 +449,13 @@ private void ProtocolEndpoint_UnhandledException(object sender, Exception e)
454449
this.serverCompletedTask.SetException(e);
455450
}
456451

457-
#if !CoreCLR
458452
private void CurrentDomain_UnhandledException(
459453
object sender,
460454
UnhandledExceptionEventArgs e)
461455
{
462456
// Log the exception
463-
this.logger.Write(
464-
LogLevel.Error,
465-
string.Format(
466-
"FATAL UNHANDLED EXCEPTION:\r\n\r\n{0}",
467-
e.ExceptionObject.ToString()));
457+
this.logger.Write(LogLevel.Error, $"FATAL UNHANDLED EXCEPTION: {e.ExceptionObject}");
468458
}
469-
#endif
470459

471460
private IServerListener CreateServiceListener(MessageProtocolType protocol, EditorServiceTransportConfig config)
472461
{
@@ -504,7 +493,6 @@ private IServerListener CreateServiceListener(MessageProtocolType protocol, Edit
504493
/// <returns></returns>
505494
private string GetOSArchitecture()
506495
{
507-
#if !CoreCLR
508496
// If on win7 (version 6.1.x), avoid System.Runtime.InteropServices.RuntimeInformation
509497
if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version < new Version(6, 2))
510498
{
@@ -515,7 +503,7 @@ private string GetOSArchitecture()
515503

516504
return "X86";
517505
}
518-
#endif
506+
519507
return RuntimeInformation.OSArchitecture.ToString();
520508
}
521509

src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.csproj

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,19 @@
44
<PropertyGroup>
55
<AssemblyTitle>PowerShell Editor Services Host Process</AssemblyTitle>
66
<Description>Provides a process for hosting the PowerShell Editor Services library exposed by a JSON message protocol.</Description>
7-
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
7+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
88
<AssemblyName>Microsoft.PowerShell.EditorServices.Host</AssemblyName>
99
</PropertyGroup>
1010

11+
<!--<PropertyGroup>
12+
<WarningsAsErrors>1591,1573,1572</WarningsAsErrors>
13+
<DocumentationFile>bin\$(TargetFramework)\$(Configuration)\Microsoft.PowerShell.EditorServices.xml</DocumentationFile>
14+
</PropertyGroup>-->
15+
1116
<ItemGroup>
1217
<ProjectReference Include="..\PowerShellEditorServices\PowerShellEditorServices.csproj" />
1318
<ProjectReference Include="..\PowerShellEditorServices.Protocol\PowerShellEditorServices.Protocol.csproj" />
19+
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-preview-06" PrivateAssets="All"/>
1420
</ItemGroup>
1521

16-
<ItemGroup>
17-
<PackageReference Include="Newtonsoft.Json">
18-
<Version>10.0.3</Version>
19-
</PackageReference>
20-
<PackageReference Include="Microsoft.PowerShell.SDK">
21-
<Version>6.0.0-alpha13</Version>
22-
</PackageReference>
23-
</ItemGroup>
24-
25-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
26-
<DefineConstants>$(DefineConstants);CoreCLR</DefineConstants>
27-
</PropertyGroup>
28-
29-
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
30-
<Reference Include="System" />
31-
<Reference Include="Microsoft.CSharp" />
32-
</ItemGroup>
3322
</Project>

0 commit comments

Comments
 (0)