Private/Resolve-CpmfUipsWorkflowCompiler.ps1
|
function Resolve-CpmfUipsWorkflowCompiler { <# .SYNOPSIS Resolves how to invoke UiPath.WorkflowCompiler for the workflowcompiler backend. .DESCRIPTION The module never downloads the compiler. The binary is supplied by the caller, by the publisher props file, or by the vendor's own environment variable, in that order of precedence: 1. -WorkflowCompilerPath 2. PublisherPackWorkflowCompilerPath (from the publisher props file) 3. $env:UIPATH_WORKFLOWCOMPILER_LOCATION A .dll value is invoked through a dotnet host; a .exe value is invoked directly and -DotnetPath is ignored. Flag names differ between concurrently installed copies of the compiler (for example --nuget-config vs --nuget-config-file), so the resolved path is deliberately pinned by configuration rather than discovered. .PARAMETER WorkflowCompilerPath Explicit path to UiPath.WorkflowCompiler.dll or .exe. .PARAMETER PublisherProps Hashtable returned by Get-CpmfUipsPublisherProps. .PARAMETER DotnetPath Dotnet host used for a .dll compiler. Defaults to the props value, then 'dotnet'. .OUTPUTS [hashtable] with keys FilePath and ArgumentPrefix. #> [CmdletBinding()] [OutputType([hashtable])] param( [string] $WorkflowCompilerPath = '', [hashtable]$PublisherProps = @{}, [string] $DotnetPath = '' ) $candidate = $WorkflowCompilerPath $source = '-WorkflowCompilerPath' if ([string]::IsNullOrWhiteSpace($candidate) -and $PublisherProps.ContainsKey('PublisherPackWorkflowCompilerPath')) { $candidate = $PublisherProps['PublisherPackWorkflowCompilerPath'] $source = 'PublisherPackWorkflowCompilerPath' } if ([string]::IsNullOrWhiteSpace($candidate)) { $candidate = [Environment]::GetEnvironmentVariable('UIPATH_WORKFLOWCOMPILER_LOCATION') $source = 'UIPATH_WORKFLOWCOMPILER_LOCATION' } if ([string]::IsNullOrWhiteSpace($candidate)) { throw @' The workflowcompiler backend needs a UiPath.WorkflowCompiler binary, and none was supplied. Set one of: -WorkflowCompilerPath <path to UiPath.WorkflowCompiler.dll|.exe> PublisherPackWorkflowCompilerPath in the publisher props file passed as -PublisherProps $env:UIPATH_WORKFLOWCOMPILER_LOCATION '@ } if (-not (Test-Path -LiteralPath $candidate)) { throw "UiPath.WorkflowCompiler not found at '$candidate' (resolved from $source)." } $resolved = (Resolve-Path -LiteralPath $candidate).Path if ($resolved -like '*.dll') { $host_ = $DotnetPath if ([string]::IsNullOrWhiteSpace($host_) -and $PublisherProps.ContainsKey('PublisherPackDotnetPath')) { $host_ = $PublisherProps['PublisherPackDotnetPath'] } if ([string]::IsNullOrWhiteSpace($host_)) { $host_ = 'dotnet' } Write-Verbose "[WorkflowCompiler] $host_ $resolved (from $source)" return @{ FilePath = $host_; ArgumentPrefix = @($resolved) } } Write-Verbose "[WorkflowCompiler] $resolved (from $source)" return @{ FilePath = $resolved; ArgumentPrefix = @() } } |