From ce2fb5159b123d4ed42b39a873d3bb6511e371bd Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 31 Aug 2018 11:38:40 -0700 Subject: [PATCH 1/7] update configs for beta36 of core tools and add windows if check --- examples/PSCoreApp/host.json | 1 + src/PowerShell/PowerShellManager.cs | 5 ++++- src/worker.config.json | 10 +++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/examples/PSCoreApp/host.json b/examples/PSCoreApp/host.json index 5553680f..c7c92e53 100644 --- a/examples/PSCoreApp/host.json +++ b/examples/PSCoreApp/host.json @@ -1,4 +1,5 @@ { + "version": "2.0", "logger": { "categoryFilter": { "defaultLevel": "Trace", diff --git a/src/PowerShell/PowerShellManager.cs b/src/PowerShell/PowerShellManager.cs index 1f30a760..713325d5 100644 --- a/src/PowerShell/PowerShellManager.cs +++ b/src/PowerShell/PowerShellManager.cs @@ -28,7 +28,10 @@ internal class PowerShellManager internal PowerShellManager(RpcLogger logger) { var initialSessionState = InitialSessionState.CreateDefault(); - initialSessionState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted; + if(Platform.IsWindows) + { + initialSessionState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted; + } _pwsh = PowerShell.Create(initialSessionState); _logger = logger; diff --git a/src/worker.config.json b/src/worker.config.json index c144335a..d5395f85 100644 --- a/src/worker.config.json +++ b/src/worker.config.json @@ -1,8 +1,8 @@ { - "Description":{ - "Language":"powershell", - "Extension":".ps1", - "DefaultExecutablePath":"dotnet", - "DefaultWorkerPath":"Azure.Functions.PowerShell.Worker.dll" + "description":{ + "language":"powershell", + "extensions":[".ps1"], + "defaultExecutablePath":"dotnet", + "defaultWorkerPath":"Azure.Functions.PowerShell.Worker.dll" } } From 71c33178b9c218b24461d5f59fe761d3a9c01f15 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 31 Aug 2018 16:27:46 -0700 Subject: [PATCH 2/7] add a comment to explain why execution policy is needed --- src/PowerShell/PowerShellManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PowerShell/PowerShellManager.cs b/src/PowerShell/PowerShellManager.cs index 713325d5..553b2bd1 100644 --- a/src/PowerShell/PowerShellManager.cs +++ b/src/PowerShell/PowerShellManager.cs @@ -28,8 +28,12 @@ internal class PowerShellManager internal PowerShellManager(RpcLogger logger) { var initialSessionState = InitialSessionState.CreateDefault(); + + // Setting the execution policy on macOS and Linux throws an exception so only update it on Windows if(Platform.IsWindows) { + // This sets the execution policy on Windows to Unrestricted which is required to run the user's function scripts on + // Windows client versions. This is needed if a user is testing their function locally with the func CLI initialSessionState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted; } _pwsh = PowerShell.Create(initialSessionState); From 746fe76e3e1c8f496de74eafbe8f9c81fea933ea Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 31 Aug 2018 18:07:27 -0700 Subject: [PATCH 3/7] nugetize the worker --- ....Functions.PowerShell.Worker.Package.props | 25 +++++++++++++++++++ src/Azure.Functions.PowerShell.Worker.csproj | 13 +++++----- test/Function/FunctionLoaderTests.cs | 2 +- 3 files changed, 33 insertions(+), 7 deletions(-) create mode 100644 src/Azure.Functions.PowerShell.Worker.Package.props diff --git a/src/Azure.Functions.PowerShell.Worker.Package.props b/src/Azure.Functions.PowerShell.Worker.Package.props new file mode 100644 index 00000000..254078b6 --- /dev/null +++ b/src/Azure.Functions.PowerShell.Worker.Package.props @@ -0,0 +1,25 @@ + + + + 0.1.0 + Azure.Functions.PowerShell.Worker + Microsoft + Microsoft + Microsoft Corporation + The Azure Function PowerShell Language Worker allows users to write Azure Function Apps using PowerShell. It leverages the PowerShell Core SDK. + Azure Function PowerShell Language Worker + © Microsoft Corporation. All rights reserved. + https://github.com/Azure/azure-functions-powershell-worker/blob/dev/LICENSE + https://github.com/Azure/azure-functions-powershell-worker + https://github.com/PowerShell/PowerShell/blob/master/assets/Powershell_64.png + azure,functions,powershell,worker + + # 0.1.0 + + Initial Release + + + \ No newline at end of file diff --git a/src/Azure.Functions.PowerShell.Worker.csproj b/src/Azure.Functions.PowerShell.Worker.csproj index 03feccdf..c89948ec 100644 --- a/src/Azure.Functions.PowerShell.Worker.csproj +++ b/src/Azure.Functions.PowerShell.Worker.csproj @@ -1,16 +1,17 @@ + - + Exe - netcoreapp2.1 - Azure Function PowerShell Language Worker - Microsoft Corporation - (c) Microsoft Corporation. All rights reserved. - + netcoreapp2.1 Latest true false true + true true en-US diff --git a/test/Function/FunctionLoaderTests.cs b/test/Function/FunctionLoaderTests.cs index a5b6bd3d..fa1d3cd3 100644 --- a/test/Function/FunctionLoaderTests.cs +++ b/test/Function/FunctionLoaderTests.cs @@ -127,7 +127,7 @@ public void TestFunctionLoaderGetInfo() Assert.Equal(directory, funcInfo.Directory); Assert.Equal(name, funcInfo.FunctionName); Assert.Equal(2, funcInfo.AllBindings.Count); - Assert.Equal(1, funcInfo.OutBindings.Count); + Assert.Equal(1, funcInfo.OutputBindings.Count); } } } From fd4e3402f1ee4e4cddf5ec36f358e63d08860349 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 31 Aug 2018 18:20:02 -0700 Subject: [PATCH 4/7] Assert.Equal to Assert.Single --- test/Function/FunctionLoaderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Function/FunctionLoaderTests.cs b/test/Function/FunctionLoaderTests.cs index fa1d3cd3..da6625c4 100644 --- a/test/Function/FunctionLoaderTests.cs +++ b/test/Function/FunctionLoaderTests.cs @@ -127,7 +127,7 @@ public void TestFunctionLoaderGetInfo() Assert.Equal(directory, funcInfo.Directory); Assert.Equal(name, funcInfo.FunctionName); Assert.Equal(2, funcInfo.AllBindings.Count); - Assert.Equal(1, funcInfo.OutputBindings.Count); + Assert.Single(funcInfo.OutputBindings); } } } From 79cc631548336001af468578c857e103ef4774ed Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 4 Sep 2018 14:52:41 -0700 Subject: [PATCH 5/7] Added PackageCopyToOutput --- src/Azure.Functions.PowerShell.Worker.csproj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Azure.Functions.PowerShell.Worker.csproj b/src/Azure.Functions.PowerShell.Worker.csproj index c89948ec..89083d95 100644 --- a/src/Azure.Functions.PowerShell.Worker.csproj +++ b/src/Azure.Functions.PowerShell.Worker.csproj @@ -12,6 +12,7 @@ Licensed under the MIT license. See LICENSE file in the project root for full li false true true + true true en-US @@ -25,13 +26,13 @@ Licensed under the MIT license. See LICENSE file in the project root for full li - + PreserveNewest - - + + Modules\%(RecursiveDir)\%(FileName)%(Extension) PreserveNewest - + From ac0655fae91d82e7260847db6cef241a82aa764c Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 4 Sep 2018 16:57:54 -0700 Subject: [PATCH 6/7] Add new line at end --- src/Azure.Functions.PowerShell.Worker.Package.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Azure.Functions.PowerShell.Worker.Package.props b/src/Azure.Functions.PowerShell.Worker.Package.props index 254078b6..14bd9668 100644 --- a/src/Azure.Functions.PowerShell.Worker.Package.props +++ b/src/Azure.Functions.PowerShell.Worker.Package.props @@ -22,4 +22,4 @@ Licensed under the MIT license. See LICENSE file in the project root for full li Initial Release - \ No newline at end of file + From 72a9e7c95a83a8c44ddfd75b9923374a8b41f6fc Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 4 Sep 2018 19:04:14 -0700 Subject: [PATCH 7/7] added Product --- src/Azure.Functions.PowerShell.Worker.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Azure.Functions.PowerShell.Worker.csproj b/src/Azure.Functions.PowerShell.Worker.csproj index 89083d95..922e7d58 100644 --- a/src/Azure.Functions.PowerShell.Worker.csproj +++ b/src/Azure.Functions.PowerShell.Worker.csproj @@ -7,6 +7,7 @@ Licensed under the MIT license. See LICENSE file in the project root for full li Exe netcoreapp2.1 + Azure Function PowerShell Language Worker Latest true false