generated from ni/github-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f940193
commit c10b8d1
Showing
1 changed file
with
35 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,50 @@ | ||
# Example: .\AddTokenToLabVIEW.ps1 -MinimumSupportedLVVersion "2021" -SupportedBitness "64" -RelativePath "C:\labview-icon-editor" | ||
|
||
param( | ||
[Parameter(Mandatory=$true)] | ||
[string]$MinimumSupportedLVVersion, | ||
[Parameter(Mandatory=$true)] | ||
[string]$SupportedBitness, | ||
[Parameter(Mandatory=$true)] | ||
[string]$RelativePath | ||
) | ||
|
||
# Construct the command | ||
$script = @" | ||
g-cli --lv-ver $MinimumSupportedLVVersion --arch $SupportedBitness -v "$RelativePath\Tooling\deployment\Create_LV_INI_Token.vi" -- "LabVIEW" "Localhost.LibraryPaths" "$RelativePath" | ||
"@ | ||
Set-StrictMode -Version Latest | ||
$ErrorActionPreference = 'Stop' | ||
$DebugPreference = 'Continue' | ||
|
||
Write-Debug "AddTokenToLabVIEW.ps1: Starting" | ||
Write-Debug "Parameters:" | ||
Write-Debug " MinimumSupportedLVVersion: $MinimumSupportedLVVersion" | ||
Write-Debug " SupportedBitness: $SupportedBitness" | ||
Write-Debug " RelativePath: $RelativePath" | ||
Write-Debug "PowerShell Version: $($PSVersionTable.PSVersion)" | ||
|
||
Write-Output "Executing the following command:" | ||
Write-Output $script | ||
# Construct the command as a list of arguments to avoid using Invoke-Expression | ||
$command = 'g-cli' | ||
$args = @( | ||
'--lv-ver', $MinimumSupportedLVVersion, | ||
'--arch', $SupportedBitness, | ||
'-v', "$RelativePath\Tooling\deployment\Create_LV_INI_Token.vi", | ||
'--', 'LabVIEW', 'Localhost.LibraryPaths', $RelativePath | ||
) | ||
|
||
Write-Host "Executing the following command:" | ||
Write-Host "$command $($args -join ' ')" | ||
|
||
# Execute the command and check for errors | ||
try { | ||
Invoke-Expression $script | ||
# Execute the command directly | ||
& $command $args | ||
|
||
# Check the exit code of the executed command | ||
if ($LASTEXITCODE -eq 0) { | ||
Write-Host "Create localhost.library path from ini file" | ||
} else { | ||
Write-Error "Command failed with exit code: $LASTEXITCODE" | ||
exit 1 | ||
} | ||
} catch { | ||
Write-Host "" | ||
exit 0 | ||
} | ||
Write-Error "An unexpected error occurred while executing g-cli." | ||
Write-Error "Error Details: $($_.Exception.Message)" | ||
exit 1 | ||
} | ||
|
||
Write-Debug "AddTokenToLabVIEW.ps1: Completed Successfully." |