@@ -63,24 +63,28 @@ $skipCliDownload = $args[0]
6363Write-Host " skipCliDownload" $skipCliDownload
6464if (! $skipCliDownload )
6565{
66- Write-Host " Deleting Functions Core Tools if exists...."
67- Remove-Item - Force ./ Azure.Functions.Cli.zip - ErrorAction Ignore
68- Remove-Item - Recurse - Force ./ Azure.Functions.Cli - ErrorAction Ignore
69-
70- Write-Host " Downloading Functions Core Tools...."
71- Invoke-RestMethod - Uri " https://functionsclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION /latest/version.txt" - OutFile version.txt
72- Write-Host " Using Functions Core Tools version: $ ( Get-Content - Raw version.txt) "
73- Remove-Item version.txt
74-
75- $url = " https://functionsclibuilds.blob.core.windows.net/builds/$FUNC_RUNTIME_VERSION /latest/Azure.Functions.Cli.$os -$arch .zip"
76- $output = " $currDir \Azure.Functions.Cli.zip"
77- $wc = New-Object System.Net.WebClient
78- $wc.DownloadFile ($url , $output )
79-
80- Write-Host " Extracting Functions Core Tools...."
81- Expand-Archive " .\Azure.Functions.Cli.zip" - DestinationPath " .\Azure.Functions.Cli"
66+ $FUNC_RUNTIME_VERSION = ' latest'
67+
68+ Write-Host " Installing Core Tools globlally using npm, version: $FUNC_RUNTIME_VERSION ..."
69+
70+ $FUNC_CLI_DIRECTORY = Join-Path $currDir ' Azure.Functions.Cli'
71+
72+ # 1. Clean previous install
73+ Remove-Item - Recurse - Force $FUNC_CLI_DIRECTORY - ErrorAction Ignore
74+ New-Item - ItemType Directory - Path $FUNC_CLI_DIRECTORY - ErrorAction Ignore
75+
76+ # 2. Locate the global prefix and module root that npm just used
77+ $globalNode = (npm root - g | Out-String ).Trim() # e.g. /usr/local/lib/node_modules
78+ $moduleRoot = Join-Path $globalNode ' azure-functions-core-tools'
79+
80+ # 3. npm install → temp folder
81+ npm install - g azure- functions- core- tools@$FUNC_RUNTIME_VERSION -- unsafe- perm true -- foreground- scripts -- loglevel verbose
82+
83+ # 4. Copy CLI payload into the layout required tests
84+ Copy-Item " $moduleRoot \bin\*" $FUNC_CLI_DIRECTORY - Recurse - Force
8285}
8386$Env: Path = $Env: Path + " ;$currDir \Azure.Functions.Cli"
87+ func -- version
8488
8589# Clone and build azure-functions-java-worker
8690git clone https:// github.com / azure/ azure- functions- java- worker - b dev
0 commit comments