Unity windows store app command line build - unity3d

I'm trying to make a build by command line for WSA and not succeeding. I've tried with another project to make it for a windows standalone version and it's working.
Here is the command line:
C:\Unity\Editor\Unity.exe" -nographics -batchmode -projectPath "path
to project" -logFile "path to the file" -executeMethod
BuildScript.BuildGame
The BuildGame method is like this:
public static void BuildGame() {
string[] scenes = new string[] { "path to scene one",
"path to scene two" };
BuildPipeline.BuildPlayer(scenes, "path to the build\\Build.sln", BuildTarget.WSAPlayer, BuildOptions.None);
}
The weird thing is that the log says the compilation was successful, but it's not generating anything.
Thanks for the help.

Related

Build Unity Server under ubuntu via command line

I created a very simple Unity Server, which uses a simple script (taken from here).
I tried to build it through the ubuntu bash with the following command:
~/Unity/Hub/Editor/2019.4.30f1/Editor/Unity -batchmode -nographics -logfile stdout.log -projectPath /path/to/the/project -buildLinux64Player /project/build/destination -quit
And it worked! It's able to create a working build. The problem is that the 3D windows is displayed as well. I don't want to interact with any game object.
Is there a way to create or run the executable without GUI?
As you can see I used "batchmode" and "nographics" flags which were supposed to prevent the user interface to appear.
Which sort of mistake I have done?
Thanks for your time.
As you can see I used "batchmode" and "nographics" flags which were supposed to prevent the user interface to appear.
yes and it didn't!
However, these two flags only apply to this instance of the UnityEditor which performs the build ... they do not apply to the actual resulting built application ;)
Usually you would go to the BuildSettings and enable
Server Build
Enable this checkbox to build the Player for server use and with no visual elements (headless) without the need for any command line options. When you enable this option, Unity builds managed scripts
with the UNITY_SERVER define, which means you can write server-specific code for your applications. You can also build to the Windows version as a console app so that stdin and stdout are accessible. Unity logs go to stdout by default.
under CommandLine Arguments you can find for how to trigger a scripted build via the console. Instead of using -buildXYZ you could use -executeMethod and within that method define the exact player and build settings you want before starting the build process
#if UNITY_EDITOR
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
class ScriptedBuilds
{
// Invoked via command line only
static void PerformHeadlessLinuxBuild()
{
// As a fallback use <project root>/BUILD as output path
var buildPath = Path.Combine(Application.dataPath, "BUILD");
// read in command line arguments e.g. add "-buildPath some/Path" if you want a different output path
var args = Environment.GetCommandLineArgs();
for (var i = 0; i < args.Length; i++)
{
if (args[i] == "-buildPath")
{
buildPath = args[i + 1];
}
}
// if the output folder doesn't exist create it now
if (!Directory.Exists(buildPath))
{
Directory.CreateDirectory(buildPath);
}
BuildPipeline.BuildPlayer(
// Simply use the scenes from the build settings
// see https://docs.unity3d.com/ScriptReference/EditorBuildSettings-scenes.html
EditorBuildSettings.scenes,
// pass on the output folder
buildPath,
// Build for Linux 64 bit
BuildTarget.StandaloneLinux64,
// Use Headless mode
// see https://docs.unity3d.com/ScriptReference/BuildOptions.EnableHeadlessMode.html
// and make the build fail for any error
// see https://docs.unity3d.com/ScriptReference/BuildOptions.StrictMode.html
BuildOptions.EnableHeadlessMode | BuildOptions.StrictMode
);
}
}
#endif
and then e.g.
~/Unity/Hub/Editor/2019.4.30f1/Editor/Unity -batchmode -nographics -logfile stdout.log -projectPath /path/to/the/project -executeMethod ScriptedBuilds.PerformHeadlessLinuxBuild -quit
or with a custom build output path
~/Unity/Hub/Editor/2019.4.30f1/Editor/Unity -batchmode -nographics -logfile stdout.log -projectPath /path/to/the/project -buildPath path/to/build/destination -executeMethod ScriptedBuilds.PerformHeadlessLinuxBuild -quit
Maybe you could try to add the #define UNITY_SERVER directive to the top of your script. This will enable the server build and disable visual elements see 'Server Build' option in the 'Platform list' table

Cannot build Unity WebGL project from script

I have a problem with building Unity Project on WebGL target. This only appeares when I'm trying to build from script. When I build it from Unity project builds fine.
I think it can also be important, I'm running this methot from powershell script
PS Script:
$unityPath = "C:\Program Files\Unity\Editor\Unity.exe"
$unityParameters = "-batchmode -projectPath `"$($repo)\`" -username USERNAME -password PASS -executeMethod `"BuildScript.PerformBuild`""
$buildProcess = Start-Process -FilePath $unityPath -ArgumentList $unityParameters -Wait -PassThru
My code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Build.Reporting;
public class BuildScript
{
public static void PerformBuild()
{
var projectName = "scene_1";
Debug.Log("### BUILDING ###");
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL);
var report = BuildPipeline.BuildPlayer(
new[] {$"Assets/Scenes/{projectName}.unity"},
$"Build/Win/{projectName}.exe",
BuildTarget.WebGL,
BuildOptions.None);
Debug.Log("### DONE ###");
Debug.Log(report);
EditorApplication.Exit(1);
}
}
Error I get in report:
Switching to WebGL:WebGLSupport is disabled
...
DisplayProgressNotification: Build Failed Error building player
Error building player because build target was unsupported
Please check if you have WebGL support installed at eg: C:\Program Files\Unity\2020.1.5f1\Editor\Data\PlaybackEngines\WebGLSupport
This error Switching to WebGL:WebGLSupport is disabled says that WebGLSupport is probably missing from you Unity installation.
Please double check that you are using the same installation of Unity in the script and in the Editor. You can check your path in UnityHub via Show in Explorer option

Running java utility via command in azure pipelines does not pass parameters

I have created an utility (java jar-file) to generate a file upon the building process. And placed it into /tools folder in my source code root folder.
In azure-pipelines I am using this approach to run this jar-file upon building the project (Xamarin project).
- task: CmdLine#2
inputs:
script: "java -jar $(build.SourcesDirectory)/tools/version2image.jar $(fullVersionText) $(androidVersionFileLocation)"
The task launched ok, but in the logs I get the following:
2020-08-17T14:48:45.4688112Z java -jar D:\a\1\s/tools/version2image.jar 1.0.0.123 'D:\a\1\s/XamarinProject/XamarinProject.Android/Resources/drawable/version.png'
2020-08-17T14:48:45.5231861Z ========================== Starting Command Output ===========================
2020-08-17T14:48:45.5731945Z ##[command]"C:\windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "D:\a\_temp\d5706f7c-43cd-4d50-8f17-98a6ae0a3391.cmd""
2020-08-17T14:48:46.8000947Z Version 2 Image Utility. version 1.0
2020-08-17T14:48:46.8001744Z
2020-08-17T14:48:46.8002367Z
2020-08-17T14:48:46.8003059Z Usage:
2020-08-17T14:48:46.8004115Z
2020-08-17T14:48:46.8004468Z java -jar version2image.jar version_string output_file_location
2020-08-17T14:48:46.8004769Z
2020-08-17T14:48:46.8005096Z Example:
2020-08-17T14:48:46.8005464Z
2020-08-17T14:48:46.8005739Z java -jar version2image.jar 1.0.0.121 c:/myproject/images/version.png
2020-08-17T14:48:46.8005961Z
2020-08-17T14:48:46.8507661Z ##[section]Finishing: CmdLine
In other words Azure does not pass parameters properly to the jar file. My application thinks that it launched without parameters.
But when I run this utility locally on my computer it works ok.
If it helps, in the java utility I get command line parameters like that:
final int correctParamsCount = 2;
if (args.length != correctParamsCount) {
System.out.println("Usage:\n\njava -jar version2image.jar <version_string> <output_file_location>\n");
System.out.println("Example:\n\njava -jar version2image.jar 1.0.0.121 c:/myproject/images/version.png\n");
System.exit(0);
}
final String versionNumber = args[0];
final String outputFilePath = args[1];
How can I fix this issue?
To resolve this issue (thanks to #riQQ) I should update AndroidVersionFileLocation variable, and remove single quote symbols from the path.
And add double quotes to the utility command call:
It should look like this:
script: 'java -jar $(build.SourcesDirectory)/tools/version2image.jar "$(fullVersionText)" "$(androidVersionFileLocation)"'
instead of this:
script: "java -jar $(build.SourcesDirectory)/tools/version2image.jar $(fullVersionText) $(androidVersionFileLocation)"

How to execute an InDesign extendscript from command line?

I need to execute a .jsx script for InDesign from command line (Windows).
For Illustrator, it works easily with the following command:
"C:\Program Files\Adobe\Adobe Illustrator CS6 (64 Bit)\Support Files\Contents\Windows\Illustrator.exe" "...\myscript.jsx"
Both applications Illustrator and ExtendScript Toolkit CS6 open then the script is automatically launched.
When I try the same for InDesign, it doesn't work (InDesign says 'Unable to open myscript.jsx ...').
I also tried to launch ExtendScript Toolkit from command line as below:
"C:\Program Files (x86)\Adobe\Adobe Utilities - CS6\ExtendScript Toolkit CS6\ExtendScript Toolkit.exe" "...\myscript.jsx"
The result is ExtendScript Toolkit application is opened with the script loaded, but nothing is executed.
Does anyone know how to launch the script? Is there a -run or -cmd argument to add?
For me on Osx it works like this:
/Applications/Adobe\ ExtendScript\ Toolkit\ CC/ExtendScript\ Toolkit.app/Contents/MacOS/ExtendScript\ Toolkit -run test.jsx
On Windows it should be:
"\path\to\ExtendScript Toolkit.exe" -run test.jsx
content of test.jsx:
//#target indesign
alert(app.name);
It needs the -run flag. When using -cmd it still executes the script but from ESTK. The //#target indesign gets ignored. With the -run the script gets passed to InDesign. Unfortunately the ESTK brings up a dialogue that warns to execute scripts from untrusted sources.
a solution of yours could be to call a visualbasic script from command line. That VB would then call the indesign jsx file based on having referenced teh indesign application itself. Kind of tricky but should definitively work.
If you are trying to execute using node, these are the best two ways I have found to execute Indesign scripts.
Version Agnostic
Credit rendertom inside his vscode/atom plugins.
const outputFilePath = path.resolve(os.homedir(), 'Documents', 'Adobe Scripts', 'myscript.js');
const hostCommand = {
darwin: {
command: 'osascript',
args: [
'-e',
`tell application id "com.adobe.indesign" to do script "${outputFilePath}" language javascript`
],
options: {}
},
win32: {
command: 'powershell',
args: [
'-command',
`"$app = new-object -comobject InDesign.Application; $app.DoScript('${outputFilePath}', 1246973031)"`
],
options: {shell: true} // Windows requires a shell
}
};
if (typeof hostCommand[process.platform] == 'undefined') {
throw new Error('This platform is not supported');
}
const {command, args, options} = hostCommand[process.platform];
const p = spawn(command, args, options);
I don't have Windows at hand to actually test it but I would start by looking at those links:
Run VBS in command line : http://ss64.com/vb/cscript.html
Run InDesign in VB:https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjj9_3JoPXMAhVI1BoKHUKMBT8QFggfMAA&url=https%3A%2F%2Fwww.adobe.com%2Fcontent%2Fdam%2FAdobe%2Fen%2Fdevnet%2Findesign%2Fsdk%2Fcs6%2Fscripting%2FInDesign_ScriptingGuide_VB.pdf&usg=AFQjCNFP8M8i3xrOqLp0zw3BGcNpnyhEXQ&sig2=pfFYnsgxXDpCf1A573JTDQ&bvm=bv.122676328,d.d2s
Look at the DoScript method for calling a JSX script.
myInDesign.DoScript myJavaScript,
Without ExtendScript Toolkit and on a Mac, you can use AppleScript or JavaScript for Automation (JXA).
This is how it's done in the jasminejsx library to execute jasmine specs in ExtendScript.
osascript -l "JavaScript" -e "var app = new Application('com.adobe.indesign'); app.doScript('$EXTENDSCRIPT', {language: 'javascript'});" &
See code here.

Installing an exe with Powershell DSC Package resource gets return code 1619

I'm trying to use Powershell DSC's Package resource to install an exe... Perforce's P4V to be specific. Here's my code:
Configuration PerforceMachine
{
Node "SERVERNAME"
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "\\nas\share\p4vinst64.exe"
ProductId = ''
Arguments = "/S /V/qn" # args for silent mode
LogPath = "$env:ProgramData\p4v_install.log"
}
}
}
When running this, this is the error Powershell gives me:
PowerShell provider MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1619 was not expected. Configuration is likely not
correct
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : SERVERNAME
According to documentation, return code 1619 means the MSI package couldn't be opened. However, when I manually log in to the machine and run "\\nas\share\p4vinst64.exe /S /V/qn", the install works flawlessly.
Does anyone know why this is failing? Alternately, can anyone tell me how to troubleshoot this? I pasted all the error information I got from the terminal, my log file (p4v_install.log) is a 0 byte file, and there are no events in the event viewer. I don't know how to troubleshoot it any further!
EDIT: I should note that I also tried using the File resource to copy the file locally, and then install it from there. Sadly, that met with the same result.
Daniel over at the Powershell.org forums was able to figure this out for me.
The P4V InstallShield setup wrapper puts the MSI file into wrong path if you execute as LocalSystem.
I’ve managed to develop a Configuration that works, see below. The key is the /b switch here which puts the MSI file into a defined location. I’ve added ALLUSERS=1 to get the shortcuts visible to all users and REBOOT=ReallySuppress to avoid a sudden restart (which will happen otherwise).
Configuration PerforceMachine
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "C:\My\p4vinst64.exe"
ProductId = ''
Arguments = '/b"C:\Windows\Temp\PerforceClient" /S /V"/qn ALLUSERS=1 REBOOT=ReallySuppress"' # args for silent mode
}
}
Well, what happens here is that the package gets installed (not tested with p4vinst64.exe yet! So, not sure why it says pack cannot be opened as the error) but since you did not specify a ProductID value, the verification at the end of install fails. That is the error you are seeing. The Package resource is no good for installing .exe packages or even MSIs with no ProductID represented as a GUID.
You can use the WindowsProcess resource instead.