Skip to content

Compiler show error on Unity Editor for Windows  #16

Open
@khoint-uit

Description

@khoint-uit

NOTE: Your issue may already be reported! Please search on the issue tracker before creating one.

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'ProjectSettings',fill "Microsoft.Unity.Analyzers" and select version 1.12.0
  2. Select Compiler Type: BuiltIn
  3. Click on 'apply'
  4. Waiting progress endless.
  5. Restart UnityEditor, error report:
stdout:

stderr:

Specify which project file to use because this 'D:\GitHubs\example' contains more than one project file.

Environment

Platform: Editor(Windows)
Unity version: 2021.2.11f1
Build options:

Additional context
The BuiltIn Compiler worked perfect in Unity Editor for MacOs.
Suggest solution
Change the Setup function inside CompilerInfo to this:

 public void Setup(ProcessStartInfo psi, string responseFile, RuntimePlatform platform)
        {
            if (platform == RuntimePlatform.WindowsEditor
                && Path.EndsWith(".exe"))
            {
                psi.FileName  = System.IO.Path.GetFullPath(Path);
                psi.Arguments = "/shared /noconfig @" + responseFile;
            }
            else
            {
                psi.FileName  = System.IO.Path.GetFullPath(RuntimePath);
                psi.Arguments = "\"" + Path + "\"" + " /noconfig @" + responseFile;
            }
            psi.CreateNoWindow  = true;
            psi.UseShellExecute = false;
        }

I changed the Path to "\"" + Path + "\"" to avoid problem with Windows file path since C:\Program Files\Unity\Hub\Editor\2021.2.11f1\Editor\Data\DotNetSdkRoslyn\csc.dll has space in the path string.

I also found that CustomCompiler_2021 need to change in this function

private string GetOutDir(string dagName)
        {
            if (dagName.EndsWith("E")) return "Library/ScriptAssemblies";

            var unityVersions = Application.unityVersion.Split('.');
            if (int.Parse(unityVersions[0]) == 2021)
                //return "Library/PlayerScriptAssemblies";
                return "Library/ScriptAssemblies";
            else
                return "Library/Bee/PlayerScriptAssemblies";
        }

since the Library/PlayerScriptAssemblies was not found.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions