Enable building with dotnet cli for non-Windows (#692)

* Enable building with PSCore6
* Fix tests to work on non-Windows
* Added clipboard capability for non-Windows
This commit is contained in:
Steve Lee
2018-09-29 22:17:03 -07:00
committed by Jason Shirk
parent e1c5b51486
commit f92ecfe085
20 changed files with 346 additions and 483 deletions
+19
View File
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": true,
"symbolOptions": {
"searchMicrosoftSymbolServer": true
}
}
]
}
+3 -2
View File
@@ -14,7 +14,8 @@ $t ='Microsoft.PowerShell.PSConsoleReadLine' -as [type]
if ($null -ne $t -and $t.Assembly.Location -ne $ourAssembly)
{
# Make sure we're runnning in a non-interactive session by relaunching
powershell -NoProfile -NonInteractive -File $PSCommandPath $Configuration $OutFile
$powershell = [System.AppDomain]::CurrentDomain.FriendlyName
& $powershell -NoProfile -NonInteractive -File $PSCommandPath $Configuration $OutFile
exit $LASTEXITCODE
}
@@ -22,7 +23,7 @@ try {
Import-Module "$PSScriptRoot\bin\$Configuration\PSReadLine\PSReadLine.psd1"
$helpContent = [xml](Get-Content "$PSScriptRoot\PSReadLine\bin\$Configuration\Microsoft.PowerShell.PSReadLine.xml")
$helpContent = [xml](Get-Content "$PSScriptRoot\bin\$Configuration\PSReadLine\en-US\Microsoft.PowerShell.PSReadLine2.dll-help.xml")
Set-PSReadLineOption -EditMode Windows
$cmdKeyBindings = Get-PSReadLineKeyHandler -Bound
+107 -62
View File
@@ -18,11 +18,43 @@
param([switch]$Install,
[string]$Configuration = (property Configuration Release))
use 15.0 MSBuild
# Final bits to release go here
$targetDir = "bin/$Configuration/PSReadLine"
if ($PSVersionTable.PSEdition -eq "Core")
{
$target = "netcoreapp2.1"
}
else
{
$target = "net461"
}
Write-Verbose "Building for '$target'" -Verbose
<#
Synopsis: Ensure dotnet is installed
#>
task CheckDotnetInstalled `
{
$script:dotnet = (Get-Command dotnet -ErrorAction Ignore).Path
if ($script:dotnet -eq $null)
{
$searchPaths = "~/.dotnet/dotnet", "~\AppData\Local\Microsoft\dotnet\dotnet.exe"
$foundDotnet = $false
foreach ($path in $searchPaths)
{
if (Test-Path $path)
{
$foundDotnet = $true
$script:dotnet = $path
break
}
}
if (!$foundDotnet)
{
throw "Could not find 'dotnet' command. Install DotNetCore SDK and ensure it is in the path."
}
}
}
<#
Synopsis: Ensure nuget is installed
@@ -52,21 +84,6 @@ task CheckPlatyPSInstalled `
}
}
$restoreNugetParameters = @{
Inputs = "PSReadLine/packages.config"
# We could look for other files, but this is probably good enough.
Outputs = "PSReadLine/packages/Microsoft.PowerShell.5.ReferenceAssemblies.1.0.0/Microsoft.PowerShell.5.ReferenceAssemblies.1.0.0.nupkg"
}
<#
Synopsis: Restore PowerShell reference assemblies
#>
task RestoreNugetPackages @restoreNugetParameters CheckNugetInstalled,{
exec { & $nugetExe restore PSReadLine/PSReadLine.sln }
}
$buildMamlParams = @{
Inputs = { Get-ChildItem docs/*.md }
Outputs = "$targetDir/en-US/Microsoft.PowerShell.PSReadLine2.dll-help.xml"
@@ -82,7 +99,7 @@ task BuildMamlHelp @buildMamlParams {
$buildAboutTopicParams = @{
Inputs = {
Get-ChildItem docs/about_PSReadLine.help.txt
"PSReadLine/bin/$Configuration/Microsoft.PowerShell.PSReadLine2.dll"
"PSReadLine/bin/$Configuration/$target/Microsoft.PowerShell.PSReadLine2.dll"
"$PSScriptRoot/GenerateFunctionHelp.ps1"
"$PSScriptRoot/CheckHelp.ps1"
}
@@ -97,7 +114,8 @@ task BuildAboutTopic @buildAboutTopicParams {
# so the file isn't locked in any way for the rest of the build.
$generatedFunctionHelpFile = New-TemporaryFile
powershell -NoProfile -NonInteractive -File $PSScriptRoot/GenerateFunctionHelp.ps1 $Configuration $generatedFunctionHelpFile.FullName
$powershell = [System.Diagnostics.Process]::GetCurrentProcess().MainModule.Filename
& $powershell -NoProfile -NonInteractive -File $PSScriptRoot/GenerateFunctionHelp.ps1 $Configuration $generatedFunctionHelpFile.FullName
assert ($LASTEXITCODE -eq 0) "Generating function help failed"
$functionDescriptions = Get-Content -Raw $generatedFunctionHelpFile
@@ -106,20 +124,20 @@ task BuildAboutTopic @buildAboutTopicParams {
$newAboutTopic = $newAboutTopic -replace "`r`n","`n"
$newAboutTopic | Out-File -FilePath $targetDir\en-US\about_PSReadLine.help.txt -NoNewline -Encoding ascii
powershell -NoProfile -NonInteractive -File $PSScriptRoot/CheckHelp.ps1 $Configuration
& $powershell -NoProfile -NonInteractive -File $PSScriptRoot/CheckHelp.ps1 $Configuration
assert ($LASTEXITCODE -eq 0) "Checking help and function signatures failed"
}
$binaryModuleParams = @{
Inputs = { Get-ChildItem PSReadLine/*.cs, PSReadLine/PSReadLine.csproj, PSReadLine/PSReadLineResources.resx }
Outputs = "PSReadLine/bin/$Configuration/Microsoft.PowerShell.PSReadLine2.dll"
Outputs = "PSReadLine/bin/$Configuration/$target/Microsoft.PowerShell.PSReadLine2.dll"
}
<#
Synopsis: Build main binary module
#>
task BuildMainModule @binaryModuleParams RestoreNugetPackages, {
exec { msbuild PSReadLine/PSReadLine.csproj /t:Rebuild /p:Configuration=$Configuration /p:Platform=AnyCPU }
task BuildMainModule @binaryModuleParams CheckDotnetInstalled, {
exec { & $script:dotnet publish -f $target -c $Configuration PSReadLine }
}
<#
@@ -139,49 +157,49 @@ $buildTestParams = @{
Outputs = "TestPSReadLine/bin/$Configuration/TestPSReadLine.exe"
}
<#
Synopsis: Build executable for interactive testing/development
#>
task BuildTestHost @buildTestParams BuildMainModule, {
exec { msbuild TestPSReadLine/TestPSReadLine.csproj /t:Rebuild /p:Configuration=$Configuration /p:Platform=AnyCPU }
}
$buildUnitTestParams = @{
Inputs = { Get-ChildItem test/*.cs, test/PSReadLine.Tests.csproj }
Outputs = "test/bin/$Configuration/PSReadLine.Tests.dll"
}
<#
Synopsis: Build the unit tests
#>
task BuildTests @buildUnitTestParams BuildMainModule, {
exec { msbuild test/PSReadLine.tests.csproj /t:Rebuild /p:Configuration=$Configuration /p:Platform=AnyCPU }
}
<#
Synopsis: Run the unit tests
#>
task RunTests BuildTests, {
exec {
$env:PSREADLINE_TESTRUN = 1
$runner = "$PSScriptRoot\PSReadLine\packages\xunit.runner.console.2.3.1\tools\net452\xunit.console.exe"
if ($env:APPVEYOR)
task RunTests BuildMainModule, {
$env:PSREADLINE_TESTRUN = 1
$runner = $script:dotnet
# need to copy implemented assemblies so test code can host powershell otherwise we have to build for a specific runtime
if ($PSVersionTable.PSEdition -eq "Core")
{
$psAssemblies = "System.Management.Automation.dll", "Newtonsoft.Json.dll", "System.Management.dll", "System.DirectoryServices.dll"
foreach ($assembly in $psAssemblies)
{
$outXml = "$PSScriptRoot\xunit-results.xml"
& $runner $PSScriptRoot\test\bin\$Configuration\PSReadLine.Tests.dll -appveyor -xml $outXml
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/xunit/$($env:APPVEYOR_JOB_ID)", $outXml)
}
else
{
& $runner $PSScriptRoot\test\bin\$Configuration\PSReadLine.Tests.dll
if (Test-Path "$PSHOME\$assembly")
{
Copy-Item "$PSHOME\$assembly" "test\bin\$configuration\$target"
}
else
{
throw "Could not find '$PSHOME\$assembly'"
}
}
}
if ($env:APPVEYOR)
{
$outXml = "$PSScriptRoot\xunit-results.xml"
Push-Location test
exec { & $runner test --no-build -c $configuration -f $target --logger "trx;LogFileName=$outXml" }
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/xunit/$($env:APPVEYOR_JOB_ID)", $outXml)
Pop-Location
}
else
{
Push-Location test
exec { & $runner test --no-build -c $configuration -f $target }
Pop-Location
}
Remove-Item env:PSREADLINE_TESTRUN
}
}
<#
Synopsis: Copy all of the files that belong in the module to one place in the layout for installation
@@ -199,15 +217,35 @@ task LayoutModule BuildMainModule, BuildMamlHelp, {
Copy-Item $file $targetDir
}
$binPath = "PSReadLine/bin/$Configuration/$target/publish"
Copy-Item $binPath/Microsoft.PowerShell.PSReadLine2.dll $targetDir
Copy-Item PSReadLine/bin/$Configuration/Microsoft.PowerShell.PSReadLine2.dll $targetDir
Copy-Item PSReadLine/bin/$Configuration/System.Runtime.InteropServices.RuntimeInformation.dll $targetDir
if (Test-Path $binPath/System.Runtime.InteropServices.RuntimeInformation.dll)
{
Copy-Item $binPath/System.Runtime.InteropServices.RuntimeInformation.dll $targetDir
}
else
{
Write-Warning "Build using $target is not sufficient to be downlevel compatible"
}
# Copy module manifest, but fix the version to match what we've specified in the binary module.
$version = (Get-ChildItem -Path $targetDir/Microsoft.PowerShell.PSReadLine2.dll).VersionInfo.FileVersion
$moduleManifestContent = Get-Content -Path 'PSReadLine/PSReadLine.psd1' -Raw
$b = Get-Content -Encoding Byte -Raw ./bin/$Configuration/PSReadLine/Microsoft.PowerShell.PSReadLine2.dll
$getContentArgs = @{
Raw = $true;
Path = "./bin/$Configuration/PSReadLine/Microsoft.PowerShell.PSReadLine2.dll"
}
if ($PSVersionTable.PSEdition -eq 'Core')
{
$getContentArgs += @{AsByteStream = $true}
}
else
{
$getContentArgs += @{Encoding = "Byte"}
}
$b = Get-Content @getContentArgs
$a = [System.Reflection.Assembly]::Load($b)
$semVer = ($a.GetCustomAttributes([System.Reflection.AssemblyInformationalVersionAttribute], $false)).InformationalVersion
@@ -235,7 +273,7 @@ task LayoutModule BuildMainModule, BuildMamlHelp, {
<#
Synopsis: Zip up the binary for release.
#>
task ZipRelease RunTests, LayoutModule, {
task ZipRelease CheckDotNetInstalled, LayoutModule, RunTests, {
Compress-Archive -Force -LiteralPath $targetDir -DestinationPath "bin/$Configuration/PSReadLine.zip"
}
@@ -307,6 +345,13 @@ task Publish -If ($Configuration -eq 'Release') LayoutModule, {
Publish-Module @publishParams
}
<#
Synopsis: Remove temporary items.
#>
task Clean {
git clean -fdx
}
<#
Synopsis: Default build rule - build and create module layout
#>
+97 -7
View File
@@ -3,6 +3,7 @@ Copyright (c) Microsoft Corporation. All rights reserved.
--********************************************************************/
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
@@ -10,31 +11,120 @@ namespace Microsoft.PowerShell.Internal
{
static class Clipboard
{
private static bool? _clipboardSupported;
private static string StartProcess(
string tool,
string args,
string stdin = ""
)
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
startInfo.FileName = tool;
startInfo.Arguments = args;
string stdout;
using (Process process = new Process())
{
process.StartInfo = startInfo;
try
{
process.Start();
}
catch (System.ComponentModel.Win32Exception)
{
_clipboardSupported = false;
PSConsoleReadLine.Ding();
return "";
}
if (stdin != "")
{
process.StandardInput.Write(stdin);
process.StandardInput.Close();
}
stdout = process.StandardOutput.ReadToEnd();
process.WaitForExit(250);
_clipboardSupported = process.ExitCode == 0;
}
return stdout;
}
public static string GetText()
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (_clipboardSupported == false)
{
PSConsoleReadLine.Ding();
return "";
}
string clipboardText = "";
ExecuteOnStaThread(() => GetTextImpl(out clipboardText));
string tool = "";
string args = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
string clipboardText = "";
ExecuteOnStaThread(() => GetTextImpl(out clipboardText));
return clipboardText;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
tool = "xclip";
args = "-selection clipboard -out";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
tool = "pbpaste";
}
else
{
_clipboardSupported = false;
PSConsoleReadLine.Ding();
return "";
}
return clipboardText;
return StartProcess(tool, args);
}
public static void SetText(string text)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (string.IsNullOrEmpty(text)) return;
if (_clipboardSupported == false)
{
PSConsoleReadLine.Ding();
return;
}
if (string.IsNullOrEmpty(text)) return;
string tool = "";
string args = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
ExecuteOnStaThread(() => SetClipboardData(Tuple.Create(text, CF_UNICODETEXT)));
return;
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
tool = "xclip";
args = "-selection clipboard -in";
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
tool = "pbcopy";
}
else
{
_clipboardSupported = false;
PSConsoleReadLine.Ding();
return;
}
ExecuteOnStaThread(() => SetClipboardData(Tuple.Create(text, CF_UNICODETEXT)));
StartProcess(tool, args, text);
}
public static void SetRtf(string plainText, string rtfText)
+2
View File
@@ -12,7 +12,9 @@ namespace Microsoft.PowerShell.Internal
// These two fields are used by PowerShellEditorServices to inject a
// custom ReadKey implementation. This is not a public API, but it is
// part of a private contract with that project.
#pragma warning disable CS0649
private static Func<bool, ConsoleKeyInfo> _readKeyOverride;
#pragma warning restore CS0649
private static Lazy<Func<bool, ConsoleKeyInfo>> _readKeyMethod = new Lazy<Func<bool, ConsoleKeyInfo>>(
() => _readKeyOverride == null ? Console.ReadKey : _readKeyOverride);
+15 -113
View File
@@ -1,107 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{615788CB-1B9A-4B34-97B3-4608686E59CA}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.PowerShell.PSReadLine</RootNamespace>
<AssemblyName>Microsoft.PowerShell.PSReadLine2</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\Debug\Microsoft.PowerShell.PSReadLine.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\Release\Microsoft.PowerShell.PSReadLine.xml</DocumentationFile>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<FileVersion>2.0.0</FileVersion>
<InformationalVersion>2.0.0-beta3</InformationalVersion>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.0.0\lib\net4\System.Management.Automation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<PackageReference Include="PowerShellStandard.Library" version="5.1.0-*" />
<PackageReference Include="Microsoft.CSharp" version="4.5.0-*" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="BasicEditing.cs" />
<Compile Include="CharMap.cs" />
<Compile Include="Clipboard.cs" />
<Compile Include="Cmdlets.cs" />
<Compile Include="Completion.cs" />
<Compile Include="Completion.vi.cs" />
<Compile Include="ConsoleKeyChordConverter.cs" />
<Compile Include="ConsoleLib.cs" />
<Compile Include="Disposable.cs" />
<Compile Include="History.cs" />
<Compile Include="HistoryQueue.cs" />
<Compile Include="KeyBindings.cs" />
<Compile Include="KeyBindings.vi.cs" />
<Compile Include="Keys.cs" />
<Compile Include="KillYank.cs" />
<Compile Include="Movement.cs" />
<Compile Include="Movement.vi.cs" />
<Compile Include="Options.cs" />
<Compile Include="PlatformWindows.cs" />
<Compile Include="PSReadLineResources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>PSReadLineResources.resx</DependentUpon>
</Compile>
<Compile Include="PublicAPI.cs" />
<Compile Include="ReadLine.cs" />
<Compile Include="Replace.vi.cs" />
<Compile Include="ReadLine.vi.cs" />
<Compile Include="Render.cs" />
<Compile Include="ScreenCapture.cs" />
<Compile Include="UndoRedo.vi.cs" />
<Compile Include="UndoRedo.cs" />
<Compile Include="VisualEditing.vi.cs" />
<Compile Include="Words.cs" />
<Compile Include="Words.vi.cs" />
<Compile Include="YankPaste.vi.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="PSReadLineResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LogicalName>Microsoft.PowerShell.PSReadLine.PSReadLineResources.resources</LogicalName>
<LastGenOutput>PSReadLineResources.Designer.cs</LastGenOutput>
<CustomToolNamespace>Microsoft.PowerShell.PSReadLine</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="PSReadLine.psd1" />
<None Include="PSReadLine.psm1" />
<None Include="SamplePSReadLineProfile.ps1" />
@@ -109,23 +21,13 @@
<None Include="License.txt" />
</ItemGroup>
<ItemGroup>
<None Include="..\docs\about_PSReadLine.help.txt" />
<None Include="..\docs\Get-PSReadLineKeyHandler.md" />
<None Include="..\docs\Get-PSReadLineOption.md" />
<None Include="..\docs\Set-PSReadLineKeyHandler.md" />
<None Include="..\docs\Set-PSReadLineOption.md" />
<None Include="docs\about_PSReadLine.help.txt" />
<None Include="docs\Get-PSReadLineKeyHandler.md" />
<None Include="docs\Get-PSReadLineOption.md" />
<None Include="docs\Set-PSReadLineKeyHandler.md" />
<None Include="docs\Set-PSReadLineOption.md" />
</ItemGroup>
<ItemGroup Condition=" '$(IsWindows)' != 'true' ">
<Compile Remove="AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>IF EXIST ..\..\CopyDLL.cmd (
..\..\CopyDLL.cmd $(TargetPath)
)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
-5
View File
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.0.0" targetFramework="net461" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net461" />
</packages>
+21
View File
@@ -164,6 +164,27 @@ If you want to change the command line in some unimplmented way in your custom k
[Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition
```
## Building
### Prerequisites
To build PSReadLine on Windows, Linux, or macOS, you must have [.NET Core SDK 2.1.400 or newer](https://www.microsoft.com/net/download) installed.
The build script also depends on [InvokeBuild](https://www.powershellgallery.com/packages/InvokeBuild) which can be installed using:
```powershell
install-module invokebuild -scope currentuser
```
### Building and running tests
You can create a new build and run tests by simply running within PowerShell:
```powershell
invoke-build
```
After a successful build, the tests are automatically run.
## Change Log
The change log is available [here](https://github.com/lzybkr/PSReadLine/blob/master/PSReadLine/Changes.txt).
-6
View File
@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
</configuration>
-35
View File
@@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TestPSReadLine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TestPSReadLine")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2892ed9f-6820-48a0-819b-0452c3b5401b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+7 -54
View File
@@ -1,59 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{08218B1A-8B85-4722-9E3F-4D6C0BF58AD8}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestPSReadLine</RootNamespace>
<AssemblyName>TestPSReadLine</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\PSReadLine\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.0.0\lib\net4\System.Management.Automation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Program.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
<PackageReference Include="System.Xml.XDocument" version="4.3.0" />
<PackageReference Include="System.Data.DataSetExtensions" version="4.5.0" />
<PackageReference Include="Microsoft.CSharp" version="4.5.0" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.1.0" />
<PackageReference Include="Microsoft.PowerShell.Commands.Management" Version="6.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PSReadLine\PSReadLine.csproj">
@@ -64,12 +25,4 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
-4
View File
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.0.0" targetFramework="net461" />
</packages>
+9
View File
@@ -1,6 +1,15 @@
image: Visual Studio 2017
install:
- ps: |
$env:DOTNET_INSTALL_DIR = "$pwd\.dotnet"
$env:CLI_VERSION = "2.1.300"
mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/dotnet/cli/release/2.1/scripts/obtain/dotnet-install.ps1" -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1"
'& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version $env:CLI_VERSION -InstallDir $env:DOTNET_INSTALL_DIR'
$env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path"
before_build:
- ps: |
nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory . -ExcludeVersion
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
</packageSources>
</configuration>
-35
View File
@@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UnitTestPSReadLine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnitTestPSReadLine")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("78ace245-ec04-43f0-b817-334ed4560845")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+17 -6
View File
@@ -1,6 +1,7 @@
using System;
using Microsoft.PowerShell;
using System;
using System.Linq;
using Microsoft.PowerShell;
using System.Runtime.InteropServices;
using Xunit;
namespace Test
@@ -77,16 +78,26 @@ namespace Test
[Fact]
public void ForwardDeleteLine()
{
TestSetup(KeyMode.Cmd);
ConsoleKeyInfo deleteToEnd;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
TestSetup(KeyMode.Cmd);
deleteToEnd = _.CtrlEnd;
}
else
{
TestSetup(KeyMode.Emacs);
deleteToEnd = _.CtrlK;
}
// Empty input (does nothing but don't crash)
Test("", Keys("", _.CtrlEnd));
Test("", Keys("", deleteToEnd));
// at end of input - doesn't change anything
Test("abc", Keys("abc", _.CtrlEnd));
Test("abc", Keys("abc", deleteToEnd));
// More normal usage - actually delete stuff
Test("a", Keys("abc", _.LeftArrow, _.LeftArrow, _.CtrlEnd));
Test("a", Keys("abc", _.LeftArrow, _.LeftArrow, deleteToEnd));
}
[Fact]
+8 -7
View File
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.ObjectModel;
using System.IO;
using System.Management.Automation;
using System.Reflection;
using Microsoft.PowerShell;
@@ -164,17 +165,17 @@ namespace Test
Test("", Keys(
"Get-Directory", _.Tab,
CheckThat(() => AssertLineIs("abc\\")),
CheckThat(() => AssertLineIs("abc" + Path.DirectorySeparatorChar)),
_.Tab,
CheckThat(() => AssertLineIs("'e f\\'")),
CheckThat(() => AssertLineIs("'e f" + Path.DirectorySeparatorChar + "'")),
CheckThat(() => AssertCursorLeftIs(5)),
_.Tab,
CheckThat(() => AssertLineIs("a\\")),
CheckThat(() => AssertLineIs("a" + Path.DirectorySeparatorChar)),
_.Tab,
CheckThat(() => AssertLineIs("'a b\\'")),
CheckThat(() => AssertLineIs("'a b" + Path.DirectorySeparatorChar + "'")),
CheckThat(() => AssertCursorLeftIs(5)),
_.Tab,
CheckThat(() => AssertLineIs("\"a b\\\"")),
CheckThat(() => AssertLineIs("\"a b" + Path.DirectorySeparatorChar + "\"")),
CheckThat(() => AssertCursorLeftIs(5)),
_.CtrlC, InputAcceptedNow));
}
@@ -234,8 +235,8 @@ namespace Test
completions.Add(new CompletionResult("abc", "abc", CompletionResultType.ProviderContainer, "abc"));
completions.Add(new CompletionResult("'e f'", "'e f'", CompletionResultType.ProviderContainer, "'e f'"));
completions.Add(new CompletionResult("a", "a", CompletionResultType.ProviderContainer, "a"));
completions.Add(new CompletionResult("'a b\\'", "a b\\'", CompletionResultType.ProviderContainer, "a b\\'"));
completions.Add(new CompletionResult("\"a b\\\"", "\"a b\\\"", CompletionResultType.ProviderContainer, "\"a b\\\""));
completions.Add(new CompletionResult("'a b" + Path.DirectorySeparatorChar + "'", "a b" + Path.DirectorySeparatorChar + "'", CompletionResultType.ProviderContainer, "a b" + Path.DirectorySeparatorChar + "'"));
completions.Add(new CompletionResult("\"a b" + Path.DirectorySeparatorChar + "\"", "\"a b" + Path.DirectorySeparatorChar + "\"", CompletionResultType.ProviderContainer, "\"a b" + Path.DirectorySeparatorChar + "\""));
break;
case "invalid result 1":
replacementIndex = -1;
+7 -6
View File
@@ -4,6 +4,7 @@ using System.Linq;
using System.Windows;
using Microsoft.PowerShell;
using Xunit;
using Microsoft.PowerShell.Internal;
namespace Test
{
@@ -304,10 +305,10 @@ namespace Test
{
TestSetup(KeyMode.Cmd);
ExecuteOnSTAThread(() => Clipboard.SetText("pastetest1"));
Clipboard.SetText("pastetest1");
Test("pastetest1", Keys(_.CtrlV));
ExecuteOnSTAThread(() => Clipboard.SetText("pastetest2"));
Clipboard.SetText("pastetest2");
Test("echo pastetest2", Keys(
"echo foobar", _.CtrlShiftLeftArrow, _.CtrlV));
}
@@ -317,7 +318,7 @@ namespace Test
{
TestSetup(KeyMode.Cmd);
ExecuteOnSTAThread(() => Clipboard.SetText(""));
Clipboard.SetText("");
Test("", Keys(
"cuttest1", _.CtrlShiftLeftArrow, _.CtrlX));
AssertClipboardTextIs("cuttest1");
@@ -328,12 +329,12 @@ namespace Test
{
TestSetup(KeyMode.Cmd);
ExecuteOnSTAThread(() => Clipboard.SetText(""));
Clipboard.SetText("");
Test("copytest1", Keys(
"copytest1", _.CtrlShiftC));
AssertClipboardTextIs("copytest1");
ExecuteOnSTAThread(() => Clipboard.SetText(""));
Clipboard.SetText("");
Test("echo copytest2", Keys(
"echo copytest2", _.CtrlShiftLeftArrow, _.CtrlShiftC));
AssertClipboardTextIs("copytest2");
@@ -344,7 +345,7 @@ namespace Test
{
TestSetup(KeyMode.Cmd);
ExecuteOnSTAThread(() => Clipboard.SetText(""));
Clipboard.SetText("");
Test("echo copytest2", Keys(
"echo copytest2", _.CtrlShiftLeftArrow, _.CtrlC));
AssertClipboardTextIs("copytest2");
+24 -124
View File
@@ -1,104 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\PSReadLine\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\PSReadLine\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" />
<Import Project="..\PSReadLine\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props" Condition="Exists('..\PSReadLine\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" />
<Import Project="..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.props" Condition="Exists('..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.props')" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8ED51D01-158C-4B29-824A-35B9B861E45A}</ProjectGuid>
<OutputType>Library</OutputType>
<OutputType>library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UnitTestPSReadLine</RootNamespace>
<AssemblyName>PSReadLine.Tests</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="System" />
<Reference Include="System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\PSReadLine\packages\Microsoft.PowerShell.5.ReferenceAssemblies.1.0.0\lib\net4\System.Management.Automation.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\PSReadLine\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll</HintPath>
</Reference>
<Reference Include="xunit.assert, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\PSReadLine\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll</HintPath>
</Reference>
<Reference Include="xunit.core, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\PSReadLine\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll</HintPath>
</Reference>
<Reference Include="xunit.execution.desktop, Version=2.3.1.3858, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
<HintPath>..\PSReadLine\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll</HintPath>
<PackageReference Include="System.Xml.XDocument" version="4.3.0" />
<PackageReference Include="System.Data.DataSetExtensions" version="4.5.0" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" />
<PackageReference Include="Microsoft.CSharp" version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<!--DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" /-->
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.1.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="System.Management.Automation">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(windir)\Microsoft.NET\assembly\GAC_MSIL\System.Management.Automation\v4.0_3.0.0.0__31bf3856ad364e35\System.Management.Automation.dll</HintPath>
</Reference>
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
<Otherwise />
</Choose>
<ItemGroup>
<ItemGroup>
<Compile Include="..\PSReadLine\Keys.cs">
<Link>Keys.cs</Link>
</Compile>
<Compile Include="..\PSReadLine\CharMap.cs">
<Link>CharMap.cs</Link>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="BasicEditingTest.VI.cs" />
<Compile Include="CompletionTest.cs" />
<Compile Include="DigitArgumentTest.cs" />
<Compile Include="HistoryTest.VI.cs" />
<Compile Include="HistoryTest.cs" />
<Compile Include="KeyBindingsTest.cs" />
<Compile Include="KeyInfoTest.cs" />
<Compile Include="BasicEditingTest.cs" />
<Compile Include="KillYankTest.cs" />
<Compile Include="MovementTest.VI.cs" />
<Compile Include="MovementTest.cs" />
<Compile Include="OptionsTest.VI.cs" />
<Compile Include="OptionsTest.cs" />
<Compile Include="PublicAPIsTest.cs" />
<Compile Include="RenderTest.cs" />
<Compile Include="ScreenCaptureTest.cs" />
<Compile Include="UndoRedoTest.cs" />
<Compile Include="UnitTestReadLine.cs" />
<Compile Include="WindowsAnsiInputTest.cs" />
<Compile Include="WordsTest.cs" />
<Compile Include="WordsTests.VI.cs" />
<Compile Include="YankPasteTest.VI.cs" />
<Compile Include="..\PSReadLine\Clipboard.cs">
<Link>Clipboard.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PSReadLine\PSReadLine.csproj">
@@ -109,47 +52,4 @@
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\PSReadLine\packages\xunit.analyzers.0.7.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
</ItemGroup>
</When>
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.props'))" />
<Error Condition="!Exists('..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.targets'))" />
<Error Condition="!Exists('..\PSReadLine\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props')" Text="$([System.String]::Format('$(ErrorText)', '..\PSReadLine\packages\xunit.runner.console.2.3.1\build\xunit.runner.console.props'))" />
<Error Condition="!Exists('..\PSReadLine\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\PSReadLine\packages\xunit.runner.visualstudio.2.3.1\build\net20\xunit.runner.visualstudio.props'))" />
</Target>
<Import Project="..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.targets" Condition="Exists('..\PSReadLine\packages\xunit.core.2.3.1\build\xunit.core.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+2 -17
View File
@@ -408,7 +408,7 @@ namespace Test
{
static ReadLine()
{
var iss = InitialSessionState.CreateDefault2();
var iss = InitialSessionState.CreateDefault();
var rs = RunspaceFactory.CreateRunspace(iss);
rs.Open();
Runspace.DefaultRunspace = rs;
@@ -528,22 +528,7 @@ namespace Test
private static string GetClipboardText()
{
string fromClipboard = null;
ExecuteOnSTAThread(() =>
{
for (int i = 0; i < 5; i++)
{
try
{
Assert.True(Clipboard.ContainsText());
fromClipboard = Clipboard.GetText();
}
catch (System.Runtime.InteropServices.COMException)
{
}
}
});
return fromClipboard;
return Clipboard.GetText();
}
private void AssertClipboardTextIs(string text)