I’m trying to create a unity package from the command line, in an automatic build setup, but I’m scratching my head trying to do so. In more detail, I already have PKG #1, now I want to build a dependent PKG #2, but without having #1 integrated into #2 (it should be more like an optional add-on).
Now assume having set up the project for exporting PKG #2, which now does not build and run from the Editor because there is some assembly reference from #1 missing. In the Editor, I can still select the “Assets” folder and export it to a unitypackage without issues. However, now If I try doing this from the command line like this,
Unity.exe -batchmode -nographics -quit -exportPackage "Assets" "package.unitypackage"
it does not work - presumably because the assembly reference from #1 is missing.
Did I miss something here? Is there a switch from the command line to work around missing assembly references?
Hi @belveder_79. You need to write function that can build unitypackage file. And that function cannot have arguments. And Command line looks like this
“C:\Program Files\Unity\Editor\Unity.exe” -quit -batchmode -serial SB-XXXX-XXXX-XXXX-XXXX-XXXX -username “JoeBloggs@example.com” -password “MyPassw0rd” -projectPath “YourProjectPath” -executeMethod ScriptName.FunctionName;
If you want to send arguments with command line, then you need other function like this
public static void buildPackage()
var packageName = GetArg("-packageName");
// some code;
//getting arguments from command line by argument name;
private static string GetArg(string name)
var args = System.Environment.GetCommandLineArgs();
for (int i = 0; i < args.Length; i++)
if (args *== name && args.Length > i + 1)*
return args[i + 1];
And call function in command line like this
> “C:\Program Files\Unity\Editor\Unity.exe” -quit -batchmode -serial SB-XXXX-XXXX-XXXX-XXXX-XXXX -username “JoeBloggs@example.com” -password “MyPassw0rd” -projectPath “YourProjectPath” -executeMethod ScriptName.buildPackage -packageName “yourPackageName”;
Thanks a lot.
With your help I solved my problem by pushing assets that should not go into the unitypackage into a folder that is not passed to the exportPackage call.