diff --git a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 index b1173f82b..59ac70783 100644 --- a/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 +++ b/CompilerFolderHandling/Compile-AppWithBcCompilerFolder.ps1 @@ -323,22 +323,33 @@ try { } Write-Host "Compiling..." + $alcParameters = @() $binPath = Join-Path $compilerFolder 'compiler/extension/bin' - if ($isLinux) { - $alcPath = Join-Path $binPath 'linux' - $alcExe = 'alc' + $alcPath = Join-Path $binPath 'win32' + $alcExe = 'alc.exe' + $alcCmd = ".\$alcExe" + if (-not (Test-Path $alcPath)) { + $alcPath = $binPath } - else { - $alcPath = Join-Path $binPath 'win32' - $alcExe = 'alc.exe' - if (-not (Test-Path $alcPath)) { - $alcPath = $binPath + + if ($isLinux) { + $linuxPath = Join-Path $binPath 'linux' + if (Test-Path $linuxPath) { + $alcPath = $linuxPath + $alcExe = 'alc' + $alcCmd = "./$alcExe" + } + else { + $alcCmd = "dotnet" + $alcExe = 'alc.dll' + $alcParameters += @((Join-Path $alcPath $alcExe)) + Write-Host "No Linux version of alc found. Using dotnet to run alc.dll." } } $alcItem = Get-Item -Path (Join-Path $alcPath $alcExe) [System.Version]$alcVersion = $alcItem.VersionInfo.FileVersion - $alcParameters = @("/project:""$($appProjectFolder.TrimEnd('/\'))""", "/packagecachepath:""$($appSymbolsFolder.TrimEnd('/\'))""", "/out:""$appOutputFile""") + $alcParameters += @("/project:""$($appProjectFolder.TrimEnd('/\'))""", "/packagecachepath:""$($appSymbolsFolder.TrimEnd('/\'))""", "/out:""$appOutputFile""") if ($GenerateReportLayoutParam) { $alcParameters += @($GenerateReportLayoutParam) } @@ -411,8 +422,8 @@ try { Push-Location -Path $alcPath try { - Write-Host ".\$alcExe $([string]::Join(' ', $alcParameters))" - $result = & ".\$alcExe" $alcParameters | Out-String + Write-Host "$alcCmd $([string]::Join(' ', $alcParameters))" + $result = & $alcCmd $alcParameters | Out-String } finally { Pop-Location diff --git a/CompilerFolderHandling/New-BcCompilerFolder.ps1 b/CompilerFolderHandling/New-BcCompilerFolder.ps1 index f925a52ee..4a9f06dc5 100644 --- a/CompilerFolderHandling/New-BcCompilerFolder.ps1 +++ b/CompilerFolderHandling/New-BcCompilerFolder.ps1 @@ -217,8 +217,34 @@ try { if ($isLinux) { $alcExePath = Join-Path $containerCompilerPath 'extension/bin/linux/alc' - # Set execute permissions on alc - & /usr/bin/env sudo pwsh -command "& chmod +x $alcExePath" + if (Test-Path $alcExePath) { + # Set execute permissions on alc + Write-Host "Setting execute permissions on alc" + & /usr/bin/env sudo pwsh -command "& chmod +x $alcExePath" + } + else { + # Patch alc.runtimeconfig.json for use with Linux + Write-Host "Patching alc.runtimeconfig.json for use with Linux" + $alcConfigPath = Join-Path $containerCompilerPath 'extension/bin/win32/alc.runtimeconfig.json' + if (Test-Path $alcConfigPath) { + $oldAlcConfig = Get-Content -Path $alcConfigPath -Encoding UTF8 | ConvertFrom-Json + if ($oldAlcConfig.runtimeOptions.PSObject.Properties.Name -eq 'includedFrameworks') { + $newAlcConfig = @{ + "runtimeOptions" = @{ + "tfm" = "net6.0" + "framework" = @{ + "name" = "Microsoft.NETCore.App" + "version" = $oldAlcConfig.runtimeOptions.includedFrameworks[0].version + } + "configProperties" = @{ + "System.Reflection.Metadata.MetadataUpdater.IsSupported" = $false + } + } + } + $newAlcConfig | ConvertTo-Json | Set-Content -Path $alcConfigPath -Encoding utf8NoBOM + } + } + } } $compilerFolder }