armake icon indicating copy to clipboard operation
armake copied to clipboard

error: Failed to create temp folder.

Open Saborknight opened this issue 6 years ago • 3 comments

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

Saborknight avatar Feb 15 '19 03:02 Saborknight

The same happens when I try and manually run armake:

.\armake.exe build --force -k "D:\[...]\.build\@2BNB Framework\keys\bnb_f_v0.0.1-gd55a5e7.biprivatekey" -e prefix=x\bnb_f\addons\core "D:\[...]\addons\core" "D:\[...]\2bnb_framework\.build\@2BNB Framework\addons\bnb_f_core.pbo"

The error message:

error: Failed to create temp folder.

Saborknight avatar Feb 15 '19 03:02 Saborknight

I've found that omitting the -e prefix=... header allows the command to work seamlessly... I don't understand what I'm doing wrong with the prefix header then?

My problem is solved, per-se

Saborknight avatar Feb 15 '19 05:02 Saborknight

Turns out I need that header, otherwise the mod isn't using the correct prefixes. So, what is it I'm doing wrong?

Saborknight avatar Feb 17 '19 10:02 Saborknight