Skip to content

Commit 274e079

Browse files
update configs for beta36+ of core tools and add windows if check (#23)
* update configs for beta36 of core tools and add windows if check * add a comment to explain why execution policy is needed
1 parent fec8b11 commit 274e079

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

examples/PSCoreApp/host.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"version": "2.0",
23
"logger": {
34
"categoryFilter": {
45
"defaultLevel": "Trace",

src/PowerShell/PowerShellManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ internal class PowerShellManager
2828
internal PowerShellManager(RpcLogger logger)
2929
{
3030
var initialSessionState = InitialSessionState.CreateDefault();
31-
initialSessionState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted;
31+
32+
// Setting the execution policy on macOS and Linux throws an exception so only update it on Windows
33+
if(Platform.IsWindows)
34+
{
35+
// This sets the execution policy on Windows to Unrestricted which is required to run the user's function scripts on
36+
// Windows client versions. This is needed if a user is testing their function locally with the func CLI
37+
initialSessionState.ExecutionPolicy = Microsoft.PowerShell.ExecutionPolicy.Unrestricted;
38+
}
3239
_pwsh = PowerShell.Create(initialSessionState);
3340
_logger = logger;
3441

src/worker.config.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"Description":{
3-
"Language":"powershell",
4-
"Extension":".ps1",
5-
"DefaultExecutablePath":"dotnet",
6-
"DefaultWorkerPath":"Azure.Functions.PowerShell.Worker.dll"
2+
"description":{
3+
"language":"powershell",
4+
"extensions":[".ps1"],
5+
"defaultExecutablePath":"dotnet",
6+
"defaultWorkerPath":"Azure.Functions.PowerShell.Worker.dll"
77
}
88
}

0 commit comments

Comments
 (0)