-
+
diff --git a/Microsoft.DotNet.Interactive.Tests/Language.cs b/Microsoft.DotNet.Interactive.Tests/Language.cs
index 5dfb7b0711..8eb24c7526 100644
--- a/Microsoft.DotNet.Interactive.Tests/Language.cs
+++ b/Microsoft.DotNet.Interactive.Tests/Language.cs
@@ -6,6 +6,7 @@ namespace Microsoft.DotNet.Interactive.Tests
public enum Language
{
CSharp = 0,
- FSharp = 1
+ FSharp = 1,
+ PowerShell = 2,
}
}
diff --git a/Microsoft.DotNet.Interactive.Tests/LanguageKernelFormattingTests.cs b/Microsoft.DotNet.Interactive.Tests/LanguageKernelFormattingTests.cs
index f39341fffd..5e16e1cbc8 100644
--- a/Microsoft.DotNet.Interactive.Tests/LanguageKernelFormattingTests.cs
+++ b/Microsoft.DotNet.Interactive.Tests/LanguageKernelFormattingTests.cs
@@ -274,5 +274,27 @@ void f()
.And
.Contain("the-outer-exception");
}
+
+ [Theory()]
+ [InlineData("Write-Warning 'I am a warning message'", "WARNING: I am a warning message
")]
+ [InlineData("Write-Verbose 'I am a verbose message' -Verbose", "VERBOSE: I am a verbose message
")]
+ [InlineData("'I am output'", "I am output
")]
+ [InlineData("Write-Debug 'I am a debug message' -Debug", "DEBUG: I am a debug message
")]
+ [InlineData("Write-Host 'I am an information message'", "I am an information message
")]
+ [InlineData("Write-Error 'I am a non-terminating error'", "Write-Error: I am a non-terminating error
")]
+ public async Task powershell_stream_formatting(string code, string output)
+ {
+ var kernel = CreateKernel(Language.PowerShell);
+ var command = new SubmitCode(code);
+ await kernel.SendAsync(command);
+
+ KernelEvents
+ .Should()
+ .ContainSingle()
+ .Which
+ .FormattedValues
+ .Should()
+ .Contain(i => i.Value == output + Environment.NewLine);
+ }
}
}
\ No newline at end of file
diff --git a/Microsoft.DotNet.Interactive.Tests/LanguageKernelTestBase.cs b/Microsoft.DotNet.Interactive.Tests/LanguageKernelTestBase.cs
index 4c0aab6e59..d7208c20a6 100644
--- a/Microsoft.DotNet.Interactive.Tests/LanguageKernelTestBase.cs
+++ b/Microsoft.DotNet.Interactive.Tests/LanguageKernelTestBase.cs
@@ -9,6 +9,7 @@
using Microsoft.DotNet.Interactive.Events;
using Microsoft.DotNet.Interactive.FSharp;
using Microsoft.DotNet.Interactive.Jupyter;
+using Microsoft.DotNet.Interactive.PowerShell;
using Pocket;
using Recipes;
using Xunit.Abstractions;
@@ -86,6 +87,7 @@ protected KernelBase CreateKernel(Language language)
.UseNugetDirective()
.UseKernelHelpers()
.UseWho(),
+ Language.PowerShell => new PowerShellKernel(),
_ => throw new InvalidOperationException("Unknown language specified")
};
diff --git a/Microsoft.DotNet.Interactive.Tests/LanguageKernelTests.cs b/Microsoft.DotNet.Interactive.Tests/LanguageKernelTests.cs
index e0136b130c..711afdbbe6 100644
--- a/Microsoft.DotNet.Interactive.Tests/LanguageKernelTests.cs
+++ b/Microsoft.DotNet.Interactive.Tests/LanguageKernelTests.cs
@@ -3,6 +3,7 @@
using System;
using System.Linq;
+using System.Management.Automation;
using System.Reactive.Linq;
using System.Threading.Tasks;
using FluentAssertions;
@@ -246,6 +247,7 @@ void f()
[Theory(Timeout = 45000)]
[InlineData(Language.CSharp)]
[InlineData(Language.FSharp)]
+ [InlineData(Language.PowerShell)]
public async Task it_returns_diagnostics(Language language)
{
var kernel = CreateKernel(language);
@@ -262,7 +264,11 @@ public async Task it_returns_diagnostics(Language language)
{
"using System;",
"aaaadd"
- }
+ },
+ Language.PowerShell => new[]
+ {
+ "$x ="
+ },
};
await SubmitCode(kernel, source);
@@ -271,19 +277,26 @@ public async Task it_returns_diagnostics(Language language)
{
Language.FSharp => "input.fsx (1,1)-(1,7) typecheck error The value or constructor 'aaaadd' is not defined.",
Language.CSharp => "(1,1): error CS0103: The name 'aaaadd' does not exist in the current context",
+ Language.PowerShell => @"At line:1 char:5
++ $x =
++ ~
+You must provide a value expression following the '=' operator.",
};
KernelEvents
.Should()
.ContainSingle()
.Which
- .Message
+ // Unfortunately, PowerShell's ParseError type's ToString() hardcoded a \n which means we have
+ // mixed newlines in PowerShell... So we replace \r\n with \n so we have consistant newlines.
+ .Message.Replace("\r\n", "\n")
.Should()
- .Be(error);
+ .Be(error.Replace("\r\n", "\n"));
}
[Theory(Timeout = 45000)]
[InlineData(Language.CSharp)]
+ [InlineData(Language.PowerShell)]
// no F# equivalent, because it doesn't have the concept of complete/incomplete submissions
public async Task it_can_analyze_incomplete_submissions(Language language)
{
@@ -291,13 +304,13 @@ public async Task it_can_analyze_incomplete_submissions(Language language)
var source = language switch
{
- Language.CSharp => "var a ="
+ Language.CSharp => "var a =",
+ Language.PowerShell => "$a ="
};
await SubmitCode(kernel, source, submissionType: SubmissionType.Diagnose);
KernelEvents
-
.Single(e => e is IncompleteCodeSubmissionReceived);
KernelEvents
@@ -307,6 +320,7 @@ public async Task it_can_analyze_incomplete_submissions(Language language)
[Theory(Timeout = 45000)]
[InlineData(Language.CSharp)]
+ [InlineData(Language.PowerShell)]
// no F# equivalent, because it doesn't have the concept of complete/incomplete submissions
public async Task it_can_analyze_complete_submissions(Language language)
{
@@ -314,7 +328,8 @@ public async Task it_can_analyze_complete_submissions(Language language)
var source = language switch
{
- Language.CSharp => "25"
+ Language.CSharp => "25",
+ Language.PowerShell => "25",
};
await SubmitCode(kernel, source, submissionType: SubmissionType.Diagnose);
@@ -552,6 +567,7 @@ public async Task kernel_captures_stderr(Language language)
[Theory(Skip = "flaky")]
[InlineData(Language.CSharp)]
[InlineData(Language.FSharp)]
+ [InlineData(Language.PowerShell)]
public async Task it_can_cancel_execution(Language language)
{
var kernel = CreateKernel(language);
@@ -559,7 +575,8 @@ public async Task it_can_cancel_execution(Language language)
var source = language switch
{
Language.FSharp => "System.Threading.Thread.Sleep(3000)\r\n2",
- Language.CSharp => "System.Threading.Thread.Sleep(3000);2"
+ Language.CSharp => "System.Threading.Thread.Sleep(3000);2",
+ Language.PowerShell => "Start-Sleep -Seconds 3; 2"
};
var submitCodeCommand = new SubmitCode(source);
@@ -763,14 +780,16 @@ public async Task it_returns_completion_list_for_types(Language language)
[Theory(Timeout = 45000)]
[InlineData(Language.CSharp)]
[InlineData(Language.FSharp)]
- public async Task it_returns_completion_list_for_previously_declared_variables(Language language)
+ [InlineData(Language.PowerShell)]
+ public async Task it_returns_completion_list_for_previously_declared_items(Language language)
{
var kernel = CreateKernel(language);
var source = language switch
{
Language.FSharp => @"let alpha = new Random()",
- Language.CSharp => @"var alpha = new Random();"
+ Language.CSharp => @"var alpha = new Random();",
+ Language.PowerShell => @"function alpha { 5 }",
};
await SubmitCode(kernel, source);
@@ -829,5 +848,76 @@ public async Task When_submission_is_split_then_CommandHandled_is_published_only
.Should()
.Be(command);
}
+
+ [Fact()]
+ public async Task PowerShell_streams_handled_in_correct_order()
+ {
+ var kernel = CreateKernel(Language.PowerShell);
+
+ var warningMessage = "I am a warning message";
+ var verboseMessage = "I am a verbose message";
+ var outputMessage = "I am output";
+ var debugMessage = "I am a debug message";
+ var infoMessage = "I am a information message";
+ var errorMessage = "I am a non-terminating error";
+
+ var command = new SubmitCode($@"
+Write-Warning '{warningMessage}'
+Write-Verbose '{verboseMessage}' -Verbose
+'{outputMessage}'
+Write-Debug '{debugMessage}' -Debug
+Write-Host '{infoMessage}'
+Write-Error '{errorMessage}'
+");
+
+ await kernel.SendAsync(command);
+
+ Assert.Collection(KernelEvents,
+ e => e.Should().BeOfType(),
+ e => e.Should().BeOfType(),
+ e => e.Should().BeOfType().Which
+ .Value.ToString().Should().Be(warningMessage),
+ e => e.Should().BeOfType().Which
+ .Value.ToString().Should().Be(verboseMessage),
+ e => e.Should().BeOfType().Which
+ .Value.ToString().Should().Be(outputMessage),
+ e => e.Should().BeOfType().Which
+ .Value.ToString().Should().Be(debugMessage),
+ e => e.Should().BeOfType().Which
+ .Value.ToString().Should().Be(infoMessage),
+ e => e.Should().BeOfType().Which
+ .Value.ToString().Should().Be(errorMessage),
+ e => e.Should().BeOfType());
+ }
+
+ [Fact()]
+ public async Task PowerShell_progress_sends_updated_display_values()
+ {
+ var kernel = CreateKernel(Language.PowerShell);
+ var command = new SubmitCode(@"
+for ($j = 1; $j -le 4; $j++ ) {
+ Write-Progress -Id 1 -Activity 'Search in Progress' -Status ""$($j*25)% Complete"" -PercentComplete $j;
+ Start-Sleep -Milliseconds 10
+}
+");
+ await kernel.SendAsync(command);
+
+ Assert.Collection(KernelEvents,
+ e => e.Should().BeOfType(),
+ e => e.Should().BeOfType(),
+ e => e.Should().BeOfType().Which
+ .Value.Should().BeOfType().Which
+ .StatusDescription.Should().Be("25% Complete"),
+ e => e.Should().BeOfType().Which
+ .Value.Should().BeOfType().Which
+ .StatusDescription.Should().Be("50% Complete"),
+ e => e.Should().BeOfType().Which
+ .Value.Should().BeOfType().Which
+ .StatusDescription.Should().Be("75% Complete"),
+ e => e.Should().BeOfType().Which
+ .Value.Should().BeOfType().Which
+ .StatusDescription.Should().Be("100% Complete"),
+ e => e.Should().BeOfType());
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Microsoft.DotNet.Interactive.Tests/Microsoft.DotNet.Interactive.Tests.csproj b/Microsoft.DotNet.Interactive.Tests/Microsoft.DotNet.Interactive.Tests.csproj
index 401f2dbd34..4848ad3da1 100644
--- a/Microsoft.DotNet.Interactive.Tests/Microsoft.DotNet.Interactive.Tests.csproj
+++ b/Microsoft.DotNet.Interactive.Tests/Microsoft.DotNet.Interactive.Tests.csproj
@@ -48,6 +48,7 @@
+
diff --git a/dotnet-interactive.sln b/dotnet-interactive.sln
index 6d05c8696c..8eaaf97815 100644
--- a/dotnet-interactive.sln
+++ b/dotnet-interactive.sln
@@ -39,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XPlot.DotNet.Interactive.Ke
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnet-interactive.Profiler", "dotnet-interactive.Profiler\dotnet-interactive.Profiler.csproj", "{71098504-D54D-4F2B-AF1F-FD54C471067B}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.Interactive.PowerShell", "Microsoft.DotNet.Interactive.PowerShell\Microsoft.DotNet.Interactive.PowerShell.csproj", "{CE412E28-8660-43CA-8E0B-293EAC624623}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DotNet.Interactive.PowerShell.Tests", "Microsoft.DotNet.Interactive.PowerShell.Tests\Microsoft.DotNet.Interactive.PowerShell.Tests.csproj", "{30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -241,6 +245,30 @@ Global
{71098504-D54D-4F2B-AF1F-FD54C471067B}.Release|x64.Build.0 = Release|Any CPU
{71098504-D54D-4F2B-AF1F-FD54C471067B}.Release|x86.ActiveCfg = Release|Any CPU
{71098504-D54D-4F2B-AF1F-FD54C471067B}.Release|x86.Build.0 = Release|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Debug|x64.Build.0 = Debug|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Debug|x86.Build.0 = Debug|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Release|x64.ActiveCfg = Release|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Release|x64.Build.0 = Release|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Release|x86.ActiveCfg = Release|Any CPU
+ {CE412E28-8660-43CA-8E0B-293EAC624623}.Release|x86.Build.0 = Release|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Debug|x64.Build.0 = Debug|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Debug|x86.Build.0 = Debug|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Release|x64.ActiveCfg = Release|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Release|x64.Build.0 = Release|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Release|x86.ActiveCfg = Release|Any CPU
+ {30DE6920-EA82-4E4F-BFCA-1FF179FAA2DA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/dotnet-interactive/CommandLine/CommandLineParser.cs b/dotnet-interactive/CommandLine/CommandLineParser.cs
index c44d1e6688..9478198842 100644
--- a/dotnet-interactive/CommandLine/CommandLineParser.cs
+++ b/dotnet-interactive/CommandLine/CommandLineParser.cs
@@ -15,6 +15,7 @@
using Microsoft.DotNet.Interactive.CSharp;
using Microsoft.DotNet.Interactive.FSharp;
using Microsoft.DotNet.Interactive.Jupyter;
+using Microsoft.DotNet.Interactive.PowerShell;
using Microsoft.DotNet.Interactive.Server;
using Microsoft.DotNet.Interactive.Telemetry;
using Microsoft.Extensions.DependencyInjection;
@@ -217,7 +218,8 @@ private static IKernel CreateKernel(string defaultKernelName)
.UseWho()
.UseDefaultNamespaces()
.UseXplot()
- .UseMathAndLaTeX()
+ .UseMathAndLaTeX(),
+ new PowerShellKernel()
}
.UseDefaultMagicCommands()
.UseAbout();
diff --git a/dotnet-interactive/ContentFiles/kernels/.net-powershell/kernel.json b/dotnet-interactive/ContentFiles/kernels/.net-powershell/kernel.json
new file mode 100644
index 0000000000..dc5a10f956
--- /dev/null
+++ b/dotnet-interactive/ContentFiles/kernels/.net-powershell/kernel.json
@@ -0,0 +1,12 @@
+{
+ "argv": [
+ "dotnet",
+ "interactive",
+ "jupyter",
+ "--default-kernel",
+ "powershell",
+ "{connection_file}"
+ ],
+ "display_name": ".NET (PowerShell)",
+ "language": "PowerShell"
+}
diff --git a/dotnet-interactive/build-and-install-dotnet-interactive.ps1 b/dotnet-interactive/build-and-install-dotnet-interactive.ps1
index b223b635ec..f5290b855a 100644
--- a/dotnet-interactive/build-and-install-dotnet-interactive.ps1
+++ b/dotnet-interactive/build-and-install-dotnet-interactive.ps1
@@ -19,5 +19,7 @@ if (Test-Path 'env:DisableArcade') {
$script:toolVersion = "1.0.44142.42"
}
-dotnet tool uninstall -g Microsoft.dotnet-interactive
+if (Get-Command dotnet-interactive -ErrorAction SilentlyContinue) {
+ dotnet tool uninstall -g Microsoft.dotnet-interactive
+}
dotnet tool install -g --add-source "$toolLocation" --version $toolVersion Microsoft.dotnet-interactive
diff --git a/dotnet-interactive/dotnet-interactive.csproj b/dotnet-interactive/dotnet-interactive.csproj
index 308b3f7f93..565f2fb81b 100644
--- a/dotnet-interactive/dotnet-interactive.csproj
+++ b/dotnet-interactive/dotnet-interactive.csproj
@@ -68,7 +68,7 @@
all
runtime; build; native; contentfiles; analyzers
-
+
@@ -79,6 +79,7 @@
+
diff --git a/eng/AfterSolutionBuild.targets b/eng/AfterSolutionBuild.targets
index 6ccbfdc594..db46129a6d 100644
--- a/eng/AfterSolutionBuild.targets
+++ b/eng/AfterSolutionBuild.targets
@@ -5,23 +5,46 @@
This file is a terrible hack.
- The `dotnet-*.nupkg` packages are never rebuilt to have a stable version because that's handled manually. The fix
- is to not allow it to be picked up by the repack targets by temporarily renaming it before the
- `PackageReleasePackages` target and restoring it's name after.
+ The `Microsoft.dotnet-*.nupkg` packages are only built with stable versions and that makes the repack step panic
+ because there's no expected `-beta.*` infix. The fix is to not allow it to be picked up by the repack targets by
+ temporarily renaming it before the `PackageReleasePackages` target and restoring it's name after. The same thing
+ is done for the symbol packages (`*.symbols.nupkg`), too.
-->
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(TEMP)\$([System.Guid]::NewGuid())
+
+
+
+
+
+
+
diff --git a/eng/Signing.props b/eng/Signing.props
index 869c7877d6..8a947fdc4a 100644
--- a/eng/Signing.props
+++ b/eng/Signing.props
@@ -4,7 +4,11 @@
+
+
+
+
diff --git a/eng/Versions.props b/eng/Versions.props
index a07b501e02..2247b70f73 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -21,28 +21,6 @@
true
https://github.com/dotnet/interactive
-
- false
- release
-
-
-
- 42424242.42
- <_BuildNumber>$(OfficialBuildId)
- <_BuildNumberYY>$(_BuildNumber.Substring(2, 2))
- <_BuildNumberMM>$(_BuildNumber.Substring(4, 2))
- <_BuildNumberDD>$(_BuildNumber.Substring(6, 2))
- <_BuildNumberR>$(_BuildNumber.Substring(9))
- $([MSBuild]::Add($([MSBuild]::Add($([MSBuild]::Multiply($(_BuildNumberYY), 1000)), $([MSBuild]::Multiply($(_BuildNumberMM), 50)))), $(_BuildNumberDD)))
-
- $(MajorVersion).$(MinorVersion).$(VersionSuffixDateStamp)
- $(VersionPrefix).$(_BuildNumberR)
- $(VersionPrefix).$(_BuildNumberR)
- $(AssemblyVersion)
-
$(RestoreSources);
diff --git a/eng/targets/Settings.props b/eng/targets/Settings.props
index 30d64eeb60..5ec05ee7b3 100644
--- a/eng/targets/Settings.props
+++ b/eng/targets/Settings.props
@@ -5,5 +5,10 @@
Microsoft
$(ArtifactsBinDir)
$(CopyrightMicrosoft)
+
+
+ portable
+ true
+