x


[Closed] Build Player from Command Line

I've made a batch file with the following command line:

"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformBuild

Which calls the following method:

static void PerformBuild ()
{

        string[] scenes = { "1.unity","2.unity","3.unity","4.unity","5.unity" };
       BuildPipeline.BuildPlayer(scenes,"win.exe",BuildTarget.StandaloneWindows,BuildOptions.None);
       BuildPipeline.BuildPlayer(scenes,"osx.app",BuildTarget.StandaloneOSXUniversal,BuildOptions.None);
        BuildPipeline.BuildPlayer(scenes,"WebPlayer.unity3d",BuildTarget.WebPlayerStreamed,BuildOptions.None);
       scenes = null;

}

It does build the three players but unfortunately it only compiles one of them.

Is there anyway to force compile before building? Am I missing something?

EDIT:

I tried separating in different functions and different calls and the same thing happens, I get the 3 builds but only one has been compiled, the other 2 act as if there were no changes to the code.

"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformWebBuild
"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformWindowsBuild
"C:\Program Files (x86)\Unity\Editor\Unity.exe" -batchMode -quit -nographics -projectPath C:\project -executeMethod AutoBuilder.PerformWebBuild
more ▼

asked Aug 18 '11 at 06:43 PM

Senhor de todo o Mal gravatar image

Senhor de todo o Mal
733 4 8 21

which one is it compiling btw.?

Aug 18 '11 at 08:00 PM BerggreenDK

The last build platform I had selected on the build settings.

Aug 19 '11 at 08:26 AM Senhor de todo o Mal

have you had any success with this? What if you touch one of your code files between each call in the batch file?

Oct 26 '11 at 10:04 AM KvanteTore

Just as a note about C#, you don't need to null the scenes variable. It will be garbage collected the same way in either case. Nulling variables does NOT provide any hints to the garbage collector.

Jun 27 '12 at 12:21 AM Soviut
(comments are locked)
10|3000 characters needed characters left

The question has been closed Jun 27 '12 at 08:47 AM by Senhor de todo o Mal for the following reason:

The question is answered, right answer was accepted


2 answers: sort voted first

Presumably, you can use EditorUserBuildSettings.SwitchActiveBuildTarget to set the active build target before you build. I haven't tried it but I came across the method and thought about your problem :)

more ▼

answered Oct 26 '11 at 11:31 AM

KvanteTore gravatar image

KvanteTore
1.5k 9 15 33

I'll have to try that.

Oct 26 '11 at 12:43 PM Senhor de todo o Mal

It works :)

Oct 26 '11 at 02:49 PM Senhor de todo o Mal

May I know how it can work? Because I tried it in my build script by putting it right before the BuildPlayer call, and it doesn't work.

Jan 12 at 04:06 AM aksupport
(comments are locked)
10|3000 characters needed characters left

If you place the command in a command file, eg. "compileall.cmd" and then make a function for each platform.

Then you can auto compile all three just by clicking on the CMD file.

would that be enough?

more ▼

answered Aug 18 '11 at 07:59 PM

BerggreenDK gravatar image

BerggreenDK
2.4k 54 62 75

Won't that be the same as I have? I'll try it anyway.

Aug 19 '11 at 08:32 AM Senhor de todo o Mal

Same exact problem

Aug 19 '11 at 09:00 AM Senhor de todo o Mal
(comments are locked)
10|3000 characters needed characters left

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x74
x48
x21
x16

asked: Aug 18 '11 at 06:43 PM

Seen: 4093 times

Last Updated: Jan 12 at 04:06 AM