Skip to content

Migrate to netstandard2.0 and PSStandard #741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 70 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
dc7cae2
Move PSES builds to netstandard and use PSStandard APIs
rjmholt Aug 29, 2018
624f7fe
Fix missed net451 reference in build file
rjmholt Aug 29, 2018
3cda894
First test fixes
rjmholt Aug 29, 2018
187aea6
Add PowerShell SDK references to tests where needed
rjmholt Aug 29, 2018
bdf008e
Converted test paths, removed #ifs from src/
rjmholt Aug 30, 2018
3ba9c0a
Add restore to build rule
rjmholt Sep 3, 2018
3567a2d
Unskip some tests, use non-Windows specific tests, lose hash key orde…
rjmholt Sep 3, 2018
15dcb61
Fix alias tests
rjmholt Sep 3, 2018
e622473
Fix platform specific tests, move build to netcoreapp2.1, break things
rjmholt Sep 4, 2018
a929752
Use latest xunit
rjmholt Sep 5, 2018
05d2f44
Use PrivateAssets to make PS SDK binding work
rjmholt Sep 5, 2018
f5114c8
Exclude host integration tests
rjmholt Sep 5, 2018
e189f87
Change dotnet xunit to dotnet test in test invocation
rjmholt Sep 5, 2018
f220082
Improve test support on Windows
rjmholt Sep 5, 2018
071b7e0
Move project references
rjmholt Sep 5, 2018
9304ba0
Drop unsupported msbuild switches for net461 builds
rjmholt Sep 5, 2018
8fc5b68
Fix net461 test bugs
Sep 6, 2018
7146a05
Add net461 shim binaries for Windows PowerShell
Sep 12, 2018
d9f3168
Build in single dir
Sep 12, 2018
66bf56f
Clean up build script
Sep 12, 2018
6fac967
Skip failing AsyncDebouncer test
Sep 12, 2018
7651f0f
Update build tooling
Sep 12, 2018
f8f60bd
Use correct Newtonsoft.Json version for PSCore 6.0
Sep 12, 2018
1525ff8
Address some PR feedback
Sep 13, 2018
88639c5
Fix casing typos
Sep 13, 2018
d8f4b2e
Make travis fail when errors occur
Sep 13, 2018
32b770f
Merge branch '2.0.0' into migrate-netstandard2.0
rjmholt Sep 13, 2018
395771e
Fix travis build
Sep 13, 2018
f5cfe42
Fix command module import path
Sep 13, 2018
02ee0e8
Try another travis fix
Sep 13, 2018
b8482c5
Restore travis build with verbose flags
Sep 13, 2018
063dadc
Try new travis script
Sep 13, 2018
25c322b
Travis
Sep 13, 2018
0a66601
Another travis try
Sep 13, 2018
d5cbd9a
TRAVIS!!!!!!
Sep 13, 2018
e1d0ac3
travis
Sep 13, 2018
e978b7c
travis >:(
Sep 13, 2018
3c13822
Suspect Save-Module is lying about the prerelease param
Sep 13, 2018
f8c462c
Never check for AllowPrerelease parameter
Sep 13, 2018
38bce43
Add ridiculous psget update dance back in
Sep 13, 2018
12b4cb6
Use newer PowerShell version in Travis
Sep 13, 2018
b47d915
Use newer powershell version
Sep 13, 2018
8b86ac9
Update dotnet CLI download
Sep 13, 2018
0bac8b6
Update dotnet SDK to latest release
Sep 13, 2018
4297563
Fix nuget bin declaration schema
Sep 13, 2018
59edb3c
Move restore to clean rule
Sep 13, 2018
865dc97
Clean up code
rjmholt Sep 14, 2018
32e13fe
Optimise encoding setting
rjmholt Sep 14, 2018
514ccf0
Update travis platforms
rjmholt Sep 14, 2018
2f870b7
Reformat travis.yml
rjmholt Sep 14, 2018
ff1b14d
Update travis config
rjmholt Sep 14, 2018
05ed5b5
Fix travis.yml
rjmholt Sep 14, 2018
8677a7a
Use CreateDefault2() again
rjmholt Sep 14, 2018
f08b6a9
Test for correct platforms
rjmholt Sep 14, 2018
da2e0b0
Move back to net461 for testing
rjmholt Sep 14, 2018
cdccf3a
Test appveyor pwsh path
Sep 14, 2018
354da07
Remove PSHome from appveyor
Sep 14, 2018
6a60e46
Try to set the module path with a config file
rjmholt Sep 17, 2018
e7a3cc9
Actually make the tests work
Sep 17, 2018
6cc0fb3
Enable writing to the config path
Sep 17, 2018
3462b23
Use sudo
Sep 17, 2018
f9d3018
Try different permissions set
Sep 17, 2018
86601f4
Give up and use a CreateDefault test hook instead
Sep 17, 2018
3511ed6
Use dotnet xunit instead of dotnet test
Sep 18, 2018
c69610e
Use simple pwsh process name
Sep 20, 2018
131e51f
Change test paths back to ensure backslack supported on *nix
Sep 20, 2018
271df79
Fix session details gathering in nested prompts
SeeminglyScience Sep 26, 2018
d99fbb6
Fix session details gathering in nested prompts
rjmholt Sep 26, 2018
784cef5
Address @tylerl0706's feedback
Oct 1, 2018
71c9ee9
Clean up temp file for nupkgs
Oct 1, 2018
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
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ language: cpp
git:
depth: 1000

os:
- linux
- osx
sudo: required
dist: trusty
osx_image: xcode8.3
matrix:
include:
- os: linux
dist: trusty
sudo: required
- os: osx
osx_image: xcode9.4

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
Expand All @@ -26,4 +27,4 @@ install:

script:
- ulimit -n 4096
- powershell -File scripts/travis.ps1
- pwsh -File scripts/travis.ps1
3 changes: 1 addition & 2 deletions PowerShellEditorServices.Common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>1.8.2</VersionPrefix>
<VersionPrefix>2.0.0</VersionPrefix>
<Company>Microsoft</Company>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>PowerShell;editor;development;language;debugging</PackageTags>
Expand All @@ -9,6 +9,5 @@
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/PowerShell/PowerShellEditorServices</RepositoryUrl>
<DebugType>portable</DebugType>
<RuntimeFrameworkVersion>1.0.3</RuntimeFrameworkVersion>
</PropertyGroup>
</Project>
305 changes: 213 additions & 92 deletions PowerShellEditorServices.build.ps1

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#

if (!$PSVersionTable.PSEdition -or $PSVersionTable.PSEdition -eq "Desktop") {
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Desktop/Microsoft.PowerShell.EditorServices.VSCode.dll"
}
else {
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Core/Microsoft.PowerShell.EditorServices.VSCode.dll"
}
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.VSCode.dll"

if ($psEditor -is [Microsoft.PowerShell.EditorServices.Extensions.EditorObject]) {
[Microsoft.PowerShell.EditorServices.VSCode.ComponentRegistration]::Register($psEditor.Components)
Expand Down
21 changes: 13 additions & 8 deletions module/PowerShellEditorServices/PowerShellEditorServices.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#

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

Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.dll"
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.Host.dll"
Microsoft.PowerShell.Utility\Add-Type -Path "$PSScriptRoot/bin/Microsoft.PowerShell.EditorServices.Protocol.dll"

function Start-EditorServicesHost {
[CmdletBinding()]
param(
Expand Down
152 changes: 1 addition & 151 deletions scripts/download.sh
Original file line number Diff line number Diff line change
@@ -1,153 +1,3 @@
#!/usr/bin/env bash

# Let's quit on interrupt of subcommands
trap '
trap - INT # restore default INT handler
echo "Interrupted"
kill -s INT "$$"
' INT

get_url() {
fork=$2
release=v6.0.0-beta.1
echo "https://github.com/$fork/PowerShell/releases/download/$release/$1"
}

fork="PowerShell"
# Get OS specific asset ID and package name
case "$OSTYPE" in
linux*)
source /etc/os-release
# Install curl and wget to download package
case "$ID" in
centos*)
if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
sudo yum install -y curl
fi

package=powershell-6.0.0_beta.1-1.el7.centos.x86_64.rpm
;;
ubuntu)
if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
sudo apt-get install -y curl
fi

case "$VERSION_ID" in
14.04)
package=powershell_6.0.0-beta.1-1ubuntu1.14.04.1_amd64.deb
;;
16.04)
package=powershell_6.0.0-beta.1-1ubuntu1.16.04.1_amd64.deb
;;
*)
echo "Ubuntu $VERSION_ID is not supported!" >&2
exit 2
esac
;;
opensuse)
if ! hash curl 2>/dev/null; then
echo "curl not found, installing..."
sudo zypper install -y curl
fi


case "$VERSION_ID" in
42.1)
# TODO during next release remove fork and fix package name
fork=TravisEz13
package=powershell-6.0.0_beta.1-1.suse.42.1.x86_64.rpm
;;
*)
echo "OpenSUSE $VERSION_ID is not supported!" >&2
exit 2
esac
;;
*)
echo "$NAME is not supported!" >&2
exit 2
esac
;;
darwin*)
# We don't check for curl as macOS should have a system version
package=powershell-6.0.0-beta.1-osx.10.12-x64.pkg
;;
*)
echo "$OSTYPE is not supported!" >&2
exit 2
;;
esac

curl -L -o "$package" $(get_url "$package" "$fork")

if [[ ! -r "$package" ]]; then
echo "ERROR: $package failed to download! Aborting..." >&2
exit 1
fi

# Installs PowerShell package
case "$OSTYPE" in
linux*)
source /etc/os-release
# Install dependencies
echo "Installing PowerShell with sudo..."
case "$ID" in
centos)
# yum automatically resolves dependencies for local packages
sudo yum install "./$package"
;;
ubuntu)
# dpkg does not automatically resolve dependencies, but spouts ugly errors
sudo dpkg -i "./$package" &> /dev/null
# Resolve dependencies
sudo apt-get install -f
;;
opensuse)
# Install the Microsoft public key so that zypper trusts the package
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
# zypper automatically resolves dependencies for local packages
sudo zypper --non-interactive install "./$package" &> /dev/null
;;
*)
esac
;;
darwin*)
patched=0
if hash brew 2>/dev/null; then
brew update
if [[ ! -d $(brew --prefix openssl) ]]; then
echo "Installing OpenSSL with brew..."
if ! brew install openssl; then
echo "ERROR: OpenSSL failed to install! Crypto functions will not work..." >&2
# Don't abort because it is not fatal
elif ! brew install curl --with-openssl; then
echo "ERROR: curl failed to build against OpenSSL; SSL functions will not work..." >&2
# Still not fatal
else
# OpenSSL installation succeeded; reme mber to patch System.Net.Http after PowerShell installation
patched=1
fi
fi

else
echo "ERROR: brew not found! OpenSSL may not be available..." >&2
# Don't abort because it is not fatal
fi

echo "Installing $package with sudo ..."
sudo installer -pkg "./$package" -target /
if [[ $patched -eq 1 ]]; then
echo "Patching System.Net.Http for libcurl and OpenSSL..."
find /usr/local/microsoft/powershell -name System.Net.Http.Native.dylib | xargs sudo install_name_tool -change /usr/lib/libcurl.4.dylib /usr/local/opt/curl/lib/libcurl.4.dylib
fi
;;
esac

powershell -noprofile -c '"Congratulations! PowerShell is installed at $PSHOME"'
success=$?

if [[ "$success" != 0 ]]; then
echo "ERROR: PowerShell failed to install!" >&2
exit "$success"
fi
bash <(curl -s https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh)
Copy link
Member

Choose a reason for hiding this comment

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

😆

9 changes: 1 addition & 8 deletions scripts/travis.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose
powershell -Command { Install-Module -Name PowershellGet -MinimumVersion 1.6 -Scope CurrentUser -force -confirm:$false -verbose }
powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Scope CurrentUser -Force -Confirm:$false -Verbose }
Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force
Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force
Install-PackageProvider -Name NuGet -Force | Out-Null
Import-PackageProvider NuGet -Force | Out-Null
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
$ErrorActionPreference = 'Stop'

# Install InvokeBuild
Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force
Expand Down
32 changes: 6 additions & 26 deletions src/PowerShellEditorServices.Host/EditorServicesHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Management.Automation.Runspaces;
using System.Reflection;
using System.Threading.Tasks;
using System.Runtime.InteropServices;

namespace Microsoft.PowerShell.EditorServices.Host
{
Expand Down Expand Up @@ -118,9 +119,7 @@ public EditorServicesHost(
#endif

// Catch unhandled exceptions for logging purposes
#if !CoreCLR
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
#endif
}

#endregion
Expand All @@ -139,21 +138,12 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
.AddLogFile(logFilePath)
.Build();

#if CoreCLR
FileVersionInfo fileVersionInfo =
FileVersionInfo.GetVersionInfo(this.GetType().GetTypeInfo().Assembly.Location);

// TODO #278: Need the correct dependency package for this to work correctly
//string osVersionString = RuntimeInformation.OSDescription;
//string processArchitecture = RuntimeInformation.ProcessArchitecture == Architecture.X64 ? "64-bit" : "32-bit";
//string osArchitecture = RuntimeInformation.OSArchitecture == Architecture.X64 ? "64-bit" : "32-bit";
#else
FileVersionInfo fileVersionInfo =
FileVersionInfo.GetVersionInfo(this.GetType().Assembly.Location);
string osVersionString = Environment.OSVersion.VersionString;
string processArchitecture = Environment.Is64BitProcess ? "64-bit" : "32-bit";
string osArchitecture = Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit";
#endif
string osVersionString = RuntimeInformation.OSDescription;
string processArchitecture = RuntimeInformation.ProcessArchitecture == Architecture.X64 ? "64-bit" : "32-bit";
string osArchitecture = RuntimeInformation.OSArchitecture == Architecture.X64 ? "64-bit" : "32-bit";

string newLine = Environment.NewLine;

Expand All @@ -165,14 +155,10 @@ public void StartLogging(string logFilePath, LogLevel logLevel)
$" Name: {this.hostDetails.Name}" + newLine +
$" ProfileId: {this.hostDetails.ProfileId}" + newLine +
$" Version: {this.hostDetails.Version}" + newLine +
#if !CoreCLR
$" Arch: {processArchitecture}" + newLine + newLine +
" Operating system details:" + newLine + newLine +
$" Version: {osVersionString}" + newLine +
$" Arch: {osArchitecture}"));
#else
""));
#endif
}

/// <summary>
Expand Down Expand Up @@ -231,7 +217,7 @@ private async void OnLanguageServiceClientConnect(
await this.editorSession.PowerShellContext.ImportCommandsModule(
Path.Combine(
Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location),
@"..\..\Commands"));
@"..\Commands"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's the command module import @tylerl0706

Copy link
Contributor

Choose a reason for hiding this comment

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

This change should help a lot. :-)


this.languageServer.Start();

Expand Down Expand Up @@ -441,19 +427,13 @@ private void ProtocolEndpoint_UnhandledException(object sender, Exception e)
this.serverCompletedTask.SetException(e);
}

#if !CoreCLR
private void CurrentDomain_UnhandledException(
object sender,
UnhandledExceptionEventArgs e)
{
// Log the exception
this.logger.Write(
LogLevel.Error,
string.Format(
"FATAL UNHANDLED EXCEPTION:\r\n\r\n{0}",
e.ExceptionObject.ToString()));
this.logger.Write(LogLevel.Error, $"FATAL UNHANDLED EXCEPTION: {e.ExceptionObject}");
}
#endif
private IServerListener CreateServiceListener(MessageProtocolType protocol, EditorServiceTransportConfig config)
{
switch (config.TransportType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,19 @@
<PropertyGroup>
<AssemblyTitle>PowerShell Editor Services Host Process</AssemblyTitle>
<Description>Provides a process for hosting the PowerShell Editor Services library exposed by a JSON message protocol.</Description>
<TargetFrameworks>netstandard1.6;net451</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>Microsoft.PowerShell.EditorServices.Host</AssemblyName>
</PropertyGroup>

<!--<PropertyGroup>
<WarningsAsErrors>1591,1573,1572</WarningsAsErrors>
<DocumentationFile>bin\$(TargetFramework)\$(Configuration)\Microsoft.PowerShell.EditorServices.xml</DocumentationFile>
</PropertyGroup>-->

<ItemGroup>
<ProjectReference Include="..\PowerShellEditorServices\PowerShellEditorServices.csproj" />
<ProjectReference Include="..\PowerShellEditorServices.Protocol\PowerShellEditorServices.Protocol.csproj" />
<PackageReference Include="PowerShellStandard.Library" Version="5.1.0-preview-06" PrivateAssets="All"/>
Copy link
Member

Choose a reason for hiding this comment

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

just curious why we need the PrivateAssets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>10.0.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.PowerShell.SDK">
<Version>6.0.0-alpha13</Version>
</PackageReference>
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<DefineConstants>$(DefineConstants);CoreCLR</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>
Loading