Skip to content

Commit

Permalink
Fix powershell path add and also add powershell core to path
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchcapper committed Jan 11, 2025
1 parent a63cea0 commit 0df9893
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/do_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ env:
MSYS2_PATH_TYPE: inherit
WLB_BASE_FOLDER: "d:/WLB"
MSYSTEM: UCRT64
BLD_CONFIG_LOG_COPY_LOGS_TO_INFODIR: 1 #copy logs to the info dir in final build, only happens for debug builds
MSYS_PATH: d:/msys64

jobs:
Expand Down
1 change: 1 addition & 0 deletions default_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ LOG_RAW_BUILD_FILE_POST_PROCESS=1 # This will call the dotnet bat_cleanup.csx sc

LOG_EXPAND_VARS=0 #This is a safeish way to expand the variables in commands but it is pretty slow, also note expanding the command manually is not error proof, any bash vars declared local won't be avail, and if there is a global var with the same name it will appear instead. This is for the LOG_FILE file.
LOG_FILE_AUTOTAIL=0
LOG_COPY_LOGS_TO_INFODIR=0 #if we should copy the *-.log and bat files etc to the final/info dir. Off by default and only for debug builds
LOG_IGNORE_REPEAT_LINES=1
STACKTRACE_ON_FAIL=1
EXPAND_FAILED_CMD_ON_STACKTRACE=1 #Note expanding the command manually is not error proof, any bash vars declared local won't be avail, and if there is a global var with the same name it will appear instead.
Expand Down
13 changes: 13 additions & 0 deletions helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,21 @@ function make_install(){
if [[ $BLD_CONFIG_BUILD_DEBUG -eq 1 ]]; then
mkdir -p "${BLD_CONFIG_INSTALL_FOLDER}/bin"
copy_pdbs
if [[ $BLD_CONFIG_LOG_COPY_LOGS_TO_INFODIR -eq 1 ]]; then
copy_infos
fi

fi
}
function copy_infos(){
mkdir -p "${BLD_CONFIG_INSTALL_FOLDER}/info"
declare -a POS_COPY=( "${BLD_CONFIG_LOG_FILE}" "${BLD_CONFIG_LOG_MAKE_CMD_FILE}" "${BLD_CONFIG_LOG_CONFIG_ENV_FILE}" "${BLD_CONFIG_LOG_CONFIGURE_FILE}" "${BLD_CONFIG_LOG_RAW_BUILD_FILE}" )
for file in "${POS_COPY[@]}"; do
if [[ -f "$file" ]]; then
cp "$file" "${BLD_CONFIG_INSTALL_FOLDER}/info"
fi
done
}
function copy_pdbs(){
ex find -name "*.pdb" | grep -v vc1 | xargs cp -t "${BLD_CONFIG_INSTALL_FOLDER}/bin" &>/dev/null || true
}
Expand Down
14 changes: 13 additions & 1 deletion vs_msys_shell_launch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ if (! $env:VS_ENV_INITIALIZED) {
Enter-VsDevShell $VS_INSTANCE_ID -SkipAutomaticLocation -DevCmdArguments "-arch=x64 -host_arch=x64";
if (! $env:WLB_NO_PATH_CLEAN ){ #this is similar to what msys2 does when -full-path is not used but we want to preserve the VS additions (plus any WLB_PATH_ADD The user might want)
$path_after=$env:PATH;
$pathAdd="${env:SystemRoot};${env:SystemRoot}/system32;${env:SystemRoot}/Wbem;${env:SystemRoot};WindowsPowerShell/v1.0"
# pwsh powershell location attempt

$pwshPath = ""
$versions = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\PowerShellCore\InstalledVersions\"
foreach ($version in $versions) {
$installedDir = Get-ItemPropertyValue -Path $version.PSPath -Name "InstallDir" -ErrorAction SilentlyContinue
if ($installedDir -and (Test-Path "$installedDir\pwsh.exe")) {
$pwshPath = ";$installedDir"
break
}
}

$pathAdd="${env:SystemRoot};${env:SystemRoot}/system32;${env:SystemRoot}/Wbem;${env:SystemRoot}/WindowsPowerShell/v1.0${pwshPath}"
if ( $env:WLB_PATH_ADD ){
$pathAdd="$env:WLB_PATH_ADD;$pathAdd"
}
Expand Down

0 comments on commit 0df9893

Please sign in to comment.