$ErrorActionPreference = 'Stop' $root = Split-Path -Parent $MyInvocation.MyCommand.Path $bin = Join-Path $root 'bin' New-Item -ItemType Directory -Path $bin -Force | Out-Null $vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe' $installation = if (Test-Path $vswhere) { & $vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath } else { $null } if (-not $installation) { $installation = Get-ChildItem 'C:\Program Files\Microsoft Visual Studio' -Directory -Recurse -ErrorAction SilentlyContinue | Where-Object { Test-Path (Join-Path $_.FullName 'VC\Auxiliary\Build\vcvars64.bat') } | Select-Object -First 1 -ExpandProperty FullName } $vcvars = if ($installation) { Join-Path $installation 'VC\Auxiliary\Build\vcvars64.bat' } else { $null } if (-not $vcvars -or -not (Test-Path $vcvars)) { throw 'Visual Studio C++ x64 build tools were not found.' } Push-Location $root try { $commands = @( ('call "{0}" >nul' -f $vcvars), 'cl /nologo /O2 /W4 /TC /MT /LD /Fo:bin\wallet_callback_shell.obj /Fe:bin\wallet_callback_shell.dll src\wallet_callback_shell.c /link advapi32.lib', 'cl /nologo /O2 /W4 /TC /MT /Fo:bin\shell_broker.obj /Fe:bin\shell_broker.exe src\shell_broker.c /link advapi32.lib userenv.lib wtsapi32.lib', 'cl /nologo /O2 /W4 /TC /MT /Fo:bin\wallet_ese_seed.obj /Fe:bin\wallet_ese_seed.exe src\wallet_ese_seed.c /link esent.lib', 'cl /nologo /O2 /W4 /TC /MT /Fo:bin\documents_path.obj /Fe:bin\documents_path.exe src\documents_path.c /link shell32.lib ole32.lib uuid.lib' ) -join ' && ' & $env:ComSpec /d /s /c $commands if ($LASTEXITCODE -ne 0) { throw "Compilation failed: $LASTEXITCODE" } Remove-Item (Join-Path $bin '*.obj'),(Join-Path $bin '*.lib'), (Join-Path $bin '*.exp') -Force -ErrorAction SilentlyContinue } finally { Pop-Location } Get-FileHash -Algorithm SHA256 (Join-Path $bin 'wallet_callback_shell.dll'), (Join-Path $bin 'shell_broker.exe'), (Join-Path $bin 'wallet_ese_seed.exe'),(Join-Path $bin 'documents_path.exe') | Format-Table -AutoSize