[String]$File = "C:\msys64\home\vagrant\styrene\substrate-complete"
[Int]$MaxRetries = 100

$Retries = 0
$Found = $false

Start-Process "C:\msys64\usr\bin\bash.exe" "--login /c/vagrant-substrate/cache/substrate_builder.sh" -Wait

while (-not $Found) {
  if (Test-Path -LiteralPath $File) {
    $Found = $true
  }
  else {
    if ($Retries -ge $MaxRetries) {
      throw "Failed to detect substrate build completion!"
    }
    else {
      Start-Sleep 5
      $Retries++
    }
  }
}

Remove-Item -Path $File
[String]$File = "C:\msys64\home\vagrant\styrene\substrate-complete"
[Int]$MaxRetries = 100

$Retries = 0
$Found = $false

if (Test-Path -LiteralPath $File) {
  Remove-Item -Path $File
}

Start-Process "c:\msys64\msys2_shell.cmd" "-msys2 -where <%= @builder_cwd %> -no-start -f <%= @builder_path %>" -Wait -NoNewWindow

while (-not $Found) {
  if (Test-Path -LiteralPath $File) {
    $Found = $true
  }
  else {
    if ($Retries -ge $MaxRetries) {
      throw "Failed to detect substrate build completion!"
    }
    else {
      Start-Sleep 5
      $Retries++
    }
  }
}

Remove-Item -Path $File
Build through msys2 and remove asset if it already exists
Build through msys2 and remove asset if it already exists
