# \`studio.project.build()\` does not build banks if the script is run from the command line tool

**URL:** <https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114>\
**Category:** FMOD Studio\
**Created:** [August 25, 2020, 6:55pm UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114 "2020-08-25T18:55:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JeffreyKumley](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@JeffreyKumley](https://qa.fmod.com/u/JeffreyKumley)\
**Post date:** [August 25, 2020, 6:55pm UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114/1 "2020-08-25T18:55:28Z")

</div>

Repro steps:

1. Create a new project
2. Add a “Scripts” directory to the project directory
3. Add a “build.js” file with the following contents to the “Scripts” directory with the following contents:

```javascript
function doBuild() {
    console.log("Build started");
    studio.project.build();
    console.log("Build finished");
}

var automation = {
    name: "Automation",
    execute: function(){ doBuild(); }
};

var automationMissing = true;
var menuItems = studio.menu.menuItems();
for (var i = 0; i < menuItems.length; ++i) {
    if (menuItems[i].name == automation.name) {
        automationMissing = false;
        break;
    }
}

if (automationMissing) {
    studio.menu.addMenuItem(automation);
}
else if (studio.system.question("Do you want to build?")) {
    doBuild();
}

```

1. Select “Scripts” and then “Reload” from the menu bar
2. Select “Scripts” and then “Automation” from the menu bar
3. Observe that the “Build” directory has been created and populated with banks
4. Delete the “Build” directory
5. Open a terminal and run the following commands:

```bash
cd <PathToFmodInstallation>
./fmodstudio.exe -build <PathToTestProject><ProjectName>.fspro

```

1. Observe that the “Build” directory has been created and populated with banks
2. Delete the “Build” directory
3. Open a terminal and run the following commands:

```bash
cd <PathToFmodInstallation>
./fmodstudio.exe -script <PathToTestProject>/Scripts/build.js <PathToTestProject><ProjectName>.fspro

```

1. Select yes on the popup
2. Observe that the “Build” directory was _NOT_ created or populated with banks

Note that the “Build” directory is still not created if adding the following code to the beginning of “build.js”:

```javascript
function getAbsolutePath(relativeFilePath) {
    var projectPath = studio.project.filePath.replace("\\", "/");
    var lastSlash = projectPath.lastIndexOf("/");
    var projectDir = studio.project.filePath.substring(0, lastSlash + 1);
    return projectDir + relativeFilePath;
}
studio.project.workspace.builtBanksOutputDirectory = getAbsolutePath("Build");
console.log(studio.project.workspace.builtBanksOutputDirectory);

```

---

<div class="post-metadata">

**Author:** ![JeffreyKumley](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@JeffreyKumley](https://qa.fmod.com/u/JeffreyKumley)\
**Post date:** [August 25, 2020, 7:03pm UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114/2 "2020-08-25T19:03:00Z")

</div>

Console output from the `-build` command:

```auto
Qt: Untested Windows version 10.0 detected!

Loading project "c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro"...
[Scripting] C:/dev/fmod/micro_test/command_line_script/Build
Successfully opened project.
Building project "c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro"...
Build Status: Preparing to build for Desktop...
Build Status: Loading "Master" objects...
Build Status: Building "Master" for Desktop...
Build completed successfully.

```

Console output from the `-script` command:

```auto
Qt: Untested Windows version 10.0 detected!

Loading project "c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro"...
[Scripting] C:/dev/fmod/micro_test/command_line_script/Build
Successfully opened project.
Running script "c:/dev/fmod/micro_test/command_line_script/Scripts/build.js"...
[Scripting] C:/dev/fmod/micro_test/command_line_script/Build
[Scripting] Build started
[Scripting] Build finished

```

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [August 31, 2020, 5:08am UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114/3 "2020-08-31T05:08:26Z")

</div>

If your script causes any kind of dialog or GUI to appear, then it will stop the script then and there. Can you try the same script without the `studio.system.question` condition?

---

<div class="post-metadata">

**Author:** ![JeffreyKumley](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@JeffreyKumley](https://qa.fmod.com/u/JeffreyKumley)\
**Post date:** [August 31, 2020, 5:34pm UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114/4 "2020-08-31T17:34:41Z")

</div>

Actually, the script did not stop in it’s tracks. It prompted me as one would expect, and after I answered, it successfully executed per the output I posted. See the “Build started” and “Build finished” in the output?

Also, even running this command from the install directory:

```bash
./fmodstudio.exe -script c:/dev/fmod/micro_test/command_line_script/build.js c:/dev/fmod/micro_test/command_line_script/command_line_script.fspro

```

with this project directory:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/9/9cfc06b8d5ec835fa776b6525f4fe4cacf492807.png)  
and this script:

```javascript
function getAbsolutePath(relativeFilePath) {
    var projectPath = studio.project.filePath.replace("\\", "/");
    var lastSlash = projectPath.lastIndexOf("/");
    var projectDir = studio.project.filePath.substring(0, lastSlash + 1);
    return projectDir + relativeFilePath;
}
studio.project.workspace.builtBanksOutputDirectory = getAbsolutePath("Build");
console.log(studio.project.workspace.builtBanksOutputDirectory);
console.log("Build started");
studio.project.build();
console.log("Build finished");

```

or even this script:

```javascript
studio.project.build();

```

will still not generate the “Build” directory.

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [September 7, 2020, 3:27am UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114/5 "2020-09-07T03:27:36Z")

</div>

My apologies over the delay in getting back to you. This does indeed seem to be a bug, we’ve raised a report and will investigate fixing it for a future release.

---

<div class="post-metadata">

**Author:** ![chemberz](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/chemberz/32/496_2.png) [@chemberz](https://qa.fmod.com/u/chemberz)\
**Post date:** [November 29, 2021, 11:01am UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114/7 "2021-11-29T11:01:56Z")

</div>

Hi everyone! It still doesn’t work.

---

<div class="post-metadata">

**Author:** ![richard\_simms](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/richard_simms/32/261_2.png) [@richard\_simms](https://qa.fmod.com/u/richard_simms)\
**Post date:** [November 29, 2021, 11:24pm UTC](https://qa.fmod.com/t/studio-project-build-does-not-build-banks-if-the-script-is-run-from-the-command-line-tool/16114/8 "2021-11-29T23:24:04Z")

</div>

This should have been fixed in a previously released version. Can you let me know which version you are experiencing this with?
