When working with custom tools (like my Cook Tool) it can be daunting to build the game before publishing. In this tutorial, I’ll show you how to build your own build script so you can automate the chores (and have a custom executable).
Requirements
- PowerShell 7 or newer
- Node.js (either LTS or Stable)
- An MV project
- An icon in the .ico format.
Step 1: Build the exe script
Spoiler
- Download Node.js and PowerShell from the sites (or type winget install OpenJS.NodeJS and winget install Microsoft.PowerShell, if you have winget installed). If you are using Linux or macOS, look up if your package manager provides these.
- After exporting the game, edit the package.json file and add the “app_name” and “version” tags.
- Find a folder that you’ll put the exported project on. The project should be on in a folder inside it.
- Create two files: One called buildPackage.ps1 and another called buildExecutable.js
- Open the ps1 file. Then write the following:
Get-ChildItem -Path ‘.\<Game Folder>’ -Exclude “www”, “package.json” | Remove-Item -force -RecurseRemove-Item -Path “.\www\package.json”node buildExecutable.js
Important! If you have any folders outside of the www folder (and need to keep), add it to the exclude list.
- Save the .ps1 file.
- Open the command line (or the terminal) on the folder, then type npm install nw-builder --save-dev.
- Once the nw-builder is installed, open the js file and put this script:
var gameName = '<Game Name>';var gameVersion = '<Game Version>';var gameTag = '<GameName>';var NwBuilder = require('nw-builder');var nw = new NwBuilder({files: '<Game Folder>/**', // use the glob formatflavor: 'normal',version: '0.22.0', //Specifies the version of nwjs. Remove this to get the latest version.appVersion: gameVersion,platforms: ['win64', 'linux64'], //Change this if you want to target more or less platformszip: false, //Only turn this to true. This may affect startup times on WindowsappName: gameTag,//Windows SpecificwinVersionString: {'FileVersion': gameVersion,'InternalName': gameTag,'ProductVersion': gameVersion,'CompanyName': '<Dev Name>','FileDescription': gameName,'ProductName': '<Game or Series Name>','OriginalFilename': '<GameName>.exe','LegalCopyright': '<Insert copyright here>',},winIco: "Game.ico" //It should be in the same folder as this script});// Log stuff you wantnw.on('log', console.log);nw.build().then(function () {console.log('all done!');}).catch(function (error) {console.error(error);});
That’s all. Save the file, run PowerShell and then execute the ps1 script (after you navigate to the folder where both scripts live) with .\buildPackage.ps1.
Step 2: Chaining the other tools
SpoilerIn order to get the tools working with the script, it’s a simple line add before or after the js line. In the ps1 script, add this line:
Start-Process <tool executable> -NoNewWindow -PassThru -Wait -Arguments ‘<Arguments for the tool go here>’
Step 3: Customizing and expanding the script
SpoilerThis step is left up to you. PowerShell is pretty powerful and you can do a lot of stuff with it. Want to create a zip file? You can. Want to edit a few files before creating? That too. Take a look at the documentation of PowerShell. Look on some tutorials. Experiment.
本贴来自国际rpgmaker官方论坛作者:AceOfAces处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:
https://forums.rpgmakerweb.com/threads/writing-an-automated-build-script-for-mv-games.140125/