Search Unity

error CS0246 - Unity 2017.3.0.f3, Windows standalone build

Discussion in 'Windows' started by SergejsK, Jan 3, 2018.

  1. SergejsK

    SergejsK

    Joined:
    Jun 30, 2016
    Posts:
    5
    Trying to build my project and having errors stating that -
    "The type or namespace name `NUnit' could not be found."
    "The type or namespace name `UnityEditor' could not be found."

    I have tryed different Visual studio 2017 versions - ranging from most recent to 15.0, but nothing changed.

    Also even tryed to revert project to earlier unity version 2017.1.2f, but also nothing helped.

    Also I have same error when trying to build from MacOS to iOS.
    And I can't switch to build for UWP because of some error - not installed il2cpp.

    I'm building from Unity using Build button and added open scene for building.

    Last tested building setup:
    Unity 2017.3.0f3, Visual Studio 2017 15.4.5.
    Scripting Runtime Version: Stable (.NET 3.5)
    Backend - Mono
    Api - .NET 2.0 Subset.


    Errors:

    Assets/scripts/Entity/Npc/AI/Goals/AIGoalModifier.cs(4,7): error CS0246: The type or namespace name `NUnit' could not be found. Are you missing an assembly reference?

    Assets/scripts/Entity/Player/Environment/SurfaceProperties/SlippyProperty.cs(5,7): error CS0246: The type or namespace name `UnityEditor' could not be found. Are you missing an assembly reference?

    Error building Player because scripts had compiler errors

    Build completed with a result of 'Failed'
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


    UnityEditor.BuildPlayerWindow+BuildMethodException: 3 errors
    at UnityEditor.BuildPlayerWindow+DefaultBuildMethods.BuildPlayer (BuildPlayerOptions options) [0x0020e] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:181
    at UnityEditor.BuildPlayerWindow.CallBuildMethods (Boolean askForBuildLocation, BuildOptions defaultBuildOptions) [0x00065] in C:\buildslave\unity\build\Editor\Mono\BuildPlayerWindowBuildMethods.cs:88
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)


    Contrary to that, if I build empty project, it gets built and for iOS I have also built Simple Mobile Placeholder project, and that also got built to iPhone.

    Also this is first time I'm trying to build this project.
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,674
    I don't know where the NUnit part is supposed to come from (perhaps you have an editor only DLL in your project with that namespace/class?), but UnityEditor namespace cannot be used in builds (as its name suggests, it's editor only). You'll have to change the code there to not use these namespaces.
     
    shottogan likes this.
  3. SergejsK

    SergejsK

    Joined:
    Jun 30, 2016
    Posts:
    5
    Thanks it works now!

    I'm new to unity scripts and those where writen for me and never tested for builds.

    Commented those lines out and Build now works.