Skip to content

error: Failed to create temp folder. #102

@Saborknight

Description

@Saborknight

This issue has already been highlighted in #16 and #76 where @KoffeinFlummi said, in both cases, that the issue was fixed... and yet I am getting this error on a new computer with the latest armake version on Windows.

The full error:

  [14:28:48] Creating PBO core
error: Failed to create temp folder.
Build-Directory : [14:28:48] Failed to build core.
At D:\[...]\tools\make.ps1:152 char:17
+                 Build-Directory $component
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Build-Directory

I get this error on two separate projects using the same build script. In both cases absolutely all addons fail to build because of this error. I'm running the script on an elevated powershell prompt.

The build script I'm using:

$projectRoot    = Split-Path -Parent $PSScriptRoot
$buildPath      = "$projectRoot\.build\@2BNB Framework"
$releasePage    = "https://github.com/KoffeinFlummi/armake/releases"
$downloadPage   = "https://github.com/KoffeinFlummi/armake/releases/download/v{0}/armake_v{0}.zip"
$armake         = "$projectRoot\tools\armake.exe"
$tag            = git describe --tag | %{$_ -replace "-.*-", "-"}
$privateKeyFile = "$buildPath\keys\bnb_f_$tag.biprivatekey"
$timestamp      = Get-Date -UFormat "%T"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12


function Compare-VersionNewerThan {
    param(
        [Parameter(Mandatory=$True)]
        $version1,

        [Parameter(Mandatory=$True)]
        $version2
    )

    $version1 = $version1.Split(".") | % {[int] $_}
    $version2 = $version2.Split(".") | % {[int] $_}

    $newer = $False
    for ($i = 0; $i -lt $version1.Length; $i++) {
        if ($version1[$i] -gt $version2[$i]) {
            $newer = $True
            break
        }
    }

    $newer
}


function Get-InstalledArmakeVersion {
    if (Test-Path $armake) {
        $version = & $armake --version
        $version = $version.Substring(1)
    } else {
        $version = "0.0.0"
    }

    $version
}


function Get-LatestArmakeVersion {
    $client = New-Object Net.WebClient
    $content = $client.DownloadString($releasePage)
    $client.dispose()

    $match = $content -match "<a href="".*?/releases/download/v(.*?)/.*?.zip"".*?>"
    if (!$match) {
        Write-Error "[$timestamp] Failed to find valid armake download link."
        $version = "0.0.0"
    } else {
        $version = $matches[1]
    }

    $version
}


function Update-Armake {
    param(
        [Parameter(Mandatory=$True)]
        $url
    )

    New-Item "$PSScriptRoot\temp" -ItemType "directory" -Force | Out-Null

    Write-Output "Downloading armake..."
    $client = New-Object Net.WebClient
    $client.DownloadFile($url, "$PSScriptRoot\temp\armake.zip")
    $client.dispose()

    Write-Output "Download complete, unpacking..."
    Expand-Archive "$PSScriptRoot\temp\armake.zip" "$PSScriptRoot\temp\armake"
    Remove-Item "$PSScriptRoot\temp\armake.zip"

    if ([Environment]::Is64BitProcess) {
        $binary = Get-ChildItem -Path "$PSScriptRoot\temp\armake" -Include "*.exe" -Recurse | Where-Object {$_.Name -match ".*w64.exe"}
    } else {
        $binary = Get-ChildItem -Path "$PSScriptRoot\temp\armake" -Include "*.exe" -Recurse | Where-Object {$_.Name -match ".*w64.exe"}
    }
    Move-Item $binary.FullName $armake -Force

    Remove-Item "$PSScriptRoot\temp" -Recurse -Force
}


function Create-Private-Key {
    Write-Output "  [$timestamp] Creating key pairs for $tag"
    & $armake keygen -f "keys\bnb_f_$tag"

    if (!(Test-Path -Path $privateKeyFile)) {
        Write-Error "[$timestamp] Failed to generate key pairs $privateKeyFile"
        return $False
    }

    return $True
}


function Build-Directory {
    param(
        [Parameter(Mandatory=$True)]
        $directory
    )

    $component = $directory.Name
    $fullPath  = $directory.FullName
    $parent    = $directory.Parent
    $binPath   = "$buildPath\$parent\bnb_f_$component.pbo"
    $prefix    = Get-Content $fullPath'\$PREFIX$'

    if (Test-Path -Path $binPath) {
        Remove-Item $binPath
        Write-Output "  [$timestamp] Updating PBO $component"
        & $armake build --force -k $privateKeyFile -e prefix=$prefix $fullPath $binPath
    } else {
        Write-Output "  [$timestamp] Creating PBO $component"
        & $armake build --force -k $privateKeyFile -e prefix=$prefix $fullPath $binPath
    }

    if ($LastExitCode -ne 0) {
        Write-Error "[$timestamp] Failed to build $component."
    }
}


function Main {
    $installed = Get-InstalledArmakeVersion
    $latest    = Get-LatestArmakeVersion

    if (Compare-VersionNewerThan $latest $installed) {
        Write-Output "Found newer version of armake:" "  Installed: $installed" "  Latest: $latest"
        Update-Armake ($downloadPage -f $latest)
        Write-Output "Update complete, armake up-to-date."
    }

    $origLocation = Get-Location
    New-Item "$buildPath" -ItemType "directory" -Force | Out-Null
    New-Item "$buildPath\keys" -ItemType "directory" -Force | Out-Null
    Set-Location -Path $buildPath

    if (Create-Private-Key) {
        foreach ($folder in "addons") {
            New-Item "$buildPath\$folder" -ItemType "directory" -Force | Out-Null
            foreach ($component in Get-ChildItem -Directory "$PSScriptRoot\..\$folder") {
                Build-Directory $component
            }
        }
    }

    Set-Location $origLocation
}
Main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions