-
Notifications
You must be signed in to change notification settings - Fork 234
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
Changes from 64 commits
dc7cae2
624f7fe
3cda894
187aea6
bdf008e
3ba9c0a
3567a2d
15dcb61
e622473
a929752
05d2f44
f5114c8
e189f87
f220082
071b7e0
9304ba0
8fc5b68
7146a05
d9f3168
66bf56f
6fac967
7651f0f
f8f60bd
1525ff8
88639c5
d8f4b2e
32b770f
395771e
f5cfe42
02ee0e8
b8482c5
063dadc
25c322b
0a66601
d5cbd9a
e1d0ac3
e978b7c
3c13822
f8c462c
38bce43
12b4cb6
b47d915
8b86ac9
0bac8b6
4297563
59edb3c
865dc97
32e13fe
514ccf0
2f870b7
ff1b14d
05ed5b5
8677a7a
f08b6a9
da2e0b0
cdccf3a
354da07
6a60e46
e7a3cc9
6cc0fb3
3462b23
f9d3018
86601f4
3511ed6
c69610e
131e51f
271df79
d99fbb6
784cef5
71c9ee9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
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) | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
{ | ||
|
@@ -118,9 +119,7 @@ public EditorServicesHost( | |
#endif | ||
|
||
// Catch unhandled exceptions for logging purposes | ||
#if !CoreCLR | ||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; | ||
#endif | ||
} | ||
|
||
#endregion | ||
|
@@ -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; | ||
|
||
|
@@ -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> | ||
|
@@ -231,7 +217,7 @@ private async void OnLanguageServiceClientConnect( | |
await this.editorSession.PowerShellContext.ImportCommandsModule( | ||
Path.Combine( | ||
Path.GetDirectoryName(this.GetType().GetTypeInfo().Assembly.Location), | ||
@"..\..\Commands")); | ||
@"..\Commands")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here's the command module import @tylerl0706 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change should help a lot. :-) |
||
|
||
this.languageServer.Start(); | ||
|
||
|
@@ -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) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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>--> | ||
rjmholt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
<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"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious why we need the PrivateAssets There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #741 (comment) |
||
</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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆