Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by drhawley · Jan 13, 2018 at 09:54 PM · linuxlinux editor

System.Windows.Forms.dll assembly is referenced by user code, but is not supported on StandaloneLinuxUniversal platform

I'm trying to build my Unity project on Linux (Ubuntu 16.04), using the command

 Editor/Unity -batchmode -nographics -projectPath MyProjectPath -logFile mylog  -buildLinuxUniversalPlayer MyProjectApp -enableIncompatibleAssetDowngrade -quit

...and it's not working. In the log file, I see the line:

 System.Windows.Forms.dll assembly is referenced by user code, but is not supported on StandaloneLinuxUniversal platform. Various failures might follow.

Why is it even trying to apply a Windows dll when I'm building for Linux?

More importantly, how can I get around this?

.

EDIT: My project does include a Newtonsoft.Json.dll file, which references many System*.dll files, but... I find it 'a bit of a stretch' that Unity on Linux can't parse JSON without Windows-specific System driver files.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by GabLeRoux · Jan 13, 2018 at 10:44 PM

Maybe you're missing the -buildTarget parameter. Did you try building with the application first? It could be related to using command line to build. I personally had success building from the command line using something that looks like this:

 export UNITY_PATH=/Applications/Unity/Unity.app/Contents/MacOS/unity
 
 export BUILD_TARGET=StandaloneLinuxUniversal
 export BUILD_TARGET_GROUP=Standalone
 
   ${UNITY_PATH} \
   -projectPath $(pwd) \
   -quit \
   -batchmode \
   -buildTarget ${BUILD_TARGET} \
   -customBuildTarget ${BUILD_TARGET} \
   -customBuildTargetGroup ${BUILD_TARGET_GROUP} \
   -customBuildOptions AcceptExternalModificationsToPlayer \
   -executeMethod BuildCommand.PerformBuild \
   -logFile

I had to write my own build script Assets/Editor/BuildCommand.cs with method PerformBuild which sets BuildTarget and BuildTargetGroup taken from arguments. I mostly started from examples given in https://docs.unity3d.com/Manual/CommandLineArguments.html

It looks something like this:

 using UnityEngine;
 using UnityEditor;
 using System.Linq;
 using System;
 
 static class BuildCommand
 {
     static string GetArgument (string name)
     {
         string[] args = Environment.GetCommandLineArgs ();
         for (int i = 0; i < args.Length; i++) {
             if (args [i].Contains (name)) {
                 return args [i + 1];
             }
         }
         return null;
     }
 
     static string[] EnabledScenes ()
     {
         return (
             from scene in EditorBuildSettings.scenes
             where scene.enabled
             select scene.path
         ).ToArray ();
     }
 
     static BuildTarget GetBuildTarget ()
     {
         string target = GetArgument ("customBuildTarget");
         Console.WriteLine (":: Received customBuildTarget " + target);
 
         return (BuildTarget)Enum.Parse (typeof(BuildTarget), target);
     }
 
     static BuildTargetGroup GetBuildTargetGroup ()
     {
         string targetGroup = GetArgument ("customBuildTargetGroup");
         Console.WriteLine (":: Received customBuildTargetGroup " + targetGroup);
         return (BuildTargetGroup)Enum.Parse (typeof(BuildTargetGroup), targetGroup);
     }
 
     static string GetBuildPath ()
     {
         string buildPath = GetArgument ("customBuildPath");
         Console.WriteLine (":: Received customBuildPath " + buildPath);
         if (buildPath == "") {
             throw new Exception ("customBuildPath argument is missing");
         }
         return buildPath;
     }
 
     static BuildOptions GetBuildOptions ()
     {
         string buildOptions = GetArgument ("customBuildOptions");
         return buildOptions == "AcceptExternalModificationsToPlayer" ? BuildOptions.AcceptExternalModificationsToPlayer : BuildOptions.None;
     }
 
     static string getEnv(string key, bool secret = false, bool verbose = true) {
         var env_var = Environment.GetEnvironmentVariable(key);
         if (verbose) {
             if (env_var != null) {
                 if (secret) {
                     Console.WriteLine(":: env['" + key + "'] set");
                 } else {
                     Console.WriteLine(":: env['" + key + "'] set to '" + env_var + "'");
                 }
             } else {
                 Console.WriteLine(":: env['" + key + "'] is null");
             }
         }
         return env_var;
     }
 
     static void PerformBuild ()
     {
         Console.WriteLine (":: Preparing build");
         BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions ();
         buildPlayerOptions.locationPathName = GetBuildPath ();
         buildPlayerOptions.options = GetBuildOptions ();
         buildPlayerOptions.scenes = EnabledScenes ();
         buildPlayerOptions.target = GetBuildTarget ();
         buildPlayerOptions.targetGroup = GetBuildTargetGroup ();
 
         Console.WriteLine ("locationPathName: " + buildPlayerOptions.locationPathName);
         Console.WriteLine ("target: " + buildPlayerOptions.target);
         Console.WriteLine ("targetGroup: " + buildPlayerOptions.targetGroup);
         Console.WriteLine ("scenes: " + buildPlayerOptions.scenes);
         Console.WriteLine ("assetBundleManifestPath: " + buildPlayerOptions.assetBundleManifestPath);
 
         Console.WriteLine (":: Performing build");
         BuildPipeline.BuildPlayer (buildPlayerOptions);
         Console.WriteLine (":: Done with build");
     }
 }

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image drhawley · Jan 13, 2018 at 10:54 PM 0
Share

Thanks I'll give this a shot. Just adding buildTarget had no effect though. Not sure what you mean by " Did you try building with the application first?". If you mean, did I try building via the GUI, it gives me the error "Failed to initialize unity graphics" upon startup, presumably because I'm connected remotely via "ssh -X". That's why I was trying the command-line build. I can create a directory called Assets/Editor and put your text in there, but... how to get Unity to recognize its existence? ...alternatively, if there's a way to get the Unity GUI to stop crashing when forwarding X11, well, my numerous searches haven't found anything useful yet! (e.g. https://forum.unity.com/threads/running-a-linux-build-on-a-remote-x-server.466295/)

avatar image GabLeRoux drhawley · Jan 13, 2018 at 11:33 PM 1
Share

Oh I see, yes I meant building via the GUI. $$anonymous$$aybe you can setup a dual boot on your machine and try the project for linux there first. You'll at least have some clues of why your project isn't building correctly.

how to get Unity to recognize its existence?

From the above shell commands, it's the -execute$$anonymous$$ethod BuildCommand.PerformBuild parameter that says execute PerformBuild from BuildCommand file. This file goes here: Assets/Editor/BuildCommand.cs. I am personally creating builds from $$anonymous$$acOS and use the script to build for Windows, Linux and $$anonymous$$ac with only a few command lines, using same command, but with different environment variables each time.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

79 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Lightmapping through Command Line 0 Answers

Unity Editor reliable on Linux? 0 Answers

My project won't open after installing Vulkan graphics in project settings 0 Answers

Unity3d editor on Linux shows OpenGL 2.1 (Deprecated) in the title bar 1 Answer

Start a process in Linux Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges