Search Unity

Error CS0246 when building on CI Azure Devops build agent with plugin dlls

Discussion in 'Editor & General Support' started by Pawciu, Mar 18, 2021.

  1. Pawciu

    Pawciu

    Joined:
    Jun 21, 2015
    Posts:
    16
    Hi
    In my application that uses Pimax SDK and Leap Motion Modules I have an error on automatic build (on Azure Devops Agent hosted on my local machine).

    When building from Editor everything is fine. There are no errors I can run the built app etc.
    When builing with agent as CI build task have errors.


    I think the problem is that when building on build agent scripts don't seem to see the classes and structs from plugin Managed-PVR.dll
    (when opening project solution in Visual Studio the reference to this dll is there and solution builds without errors)

    Erros in logs starts at line 2479
    Assets\Packages\Pimax\PVRUnity\src\PVRInputEvent.cs(52,20): error CS0246: The type or namespace name 'pvrButton' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Packages\Pimax\PVRUnity\src\PVRInputEvent.cs(41,21): error CS0246: The type or namespace name 'pvrButton' could not be found (are you missing a using directive or an assembly reference?)
    ...


    I've attached UnityBuildTask log.
    Pipeline definition and source code can be found here:
    https://github.com/paweltruong/Cyclops-VR

    Automated started failing when i pushed the commit 7f05d345
    (after added Pimax SDK and Leap Motion)
    After this commit I was trying to fix the problem but without success. Current commit is 30f494c, still has errors.

    Things I've tried:
    • moved Pimax plugins to Assets\Plugins
    • changed build from WIN_64 to Standalone
    • added ".plugin" suffix to PVR plugins folder
    • added parameter to pipeline definition , unity build task:
      additionalCmdArgs: '-importPackage "$(Build.Repository.LocalPath)\CyclopsVR\Plugins\Managed-PVR.dll"'
    • added Managed-PVR.dll to C:\Program Files\2020.2.1f1\Editor\Data\Managed\UnityEngine


    Found this link to documentation that I think could help but no success for now:
    https://docs.unity3d.com/Manual/PluginInspector.html

    I've tried to add Pimax classes from this repo
    https://github.com/wearvr/pimax-vr-unity-sdk-instructions
    And update them with this repo for Magic Leap updates
    https://github.com/leapmotion/UnityModules

    Thanks for any suggestions
     

    Attached Files:

    Arkaen_AtC likes this.
  2. Pawciu

    Pawciu

    Joined:
    Jun 21, 2015
    Posts:
    16
    Ok, so I got it to work. There were two problems:

    1. Assets\Plugins\Managed-PVR.dll was not referenced on automatic build.

    To fix this, you will need to pass a parameter to compiler that is called when building
    Go to Player settings.
    File->Build Settings->Player Settings or Edit->Project Settings->Player

    In "Settings for PC, Mac & Linux Standalone", scroll down to "Other settings" section
    Find "Additional compiler arguments" and add "-reference" or "-r" with a path can be relative or full like "c:\...."
    I've put relative here so this should work on any build agent:
    -r:"Assets\Plugins\Managed-PVR.dll"
    Additional resources:
    - attached projectsettings.png
    - https://docs.unity3d.com/Manual/dotnetProfileAssemblies.html
    - https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
    - https://docs.unity3d.com/540/Documentation/Manual/PlatformDependentCompilation.html
    - https://letsmakeagame.net/c-sharp-compiler-options-unity-plugin-documentation/
    - https://docs.unity3d.com/2021.1/Doc...pilerOptions.AdditionalCompilerArguments.html
    - https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/inputs
    - https://docs.unity3d.com/Manual/CommandLineArguments.html
    - https://strontic.github.io/xcyclopedia/library/csc.exe-F65B029562077B648A6A5F6A1AA76A66.html
    - https://stackoverflow.com/questions...ences-for-compiling-with-developement-console

    Above fixed the "error CS0246: The type or namespace name '{0}' could not be found (are you missing a using directive or an assembly reference?)

    2. After fixing that different multiple errors occured

    Start importing Assets/Packages/Pimax/LeapMotion/Core/Models/LowPolySphere.fbx using Guid(d3c658b9d2d991e49944fe238fc8b166) Importer(-1,00000000000000000000000000000000) ImportFBX Errors:
    2021-03-19T14:47:59.6064916Z Couldn't read file C:/BuildAgent/Unity3d Build Agent/_work/4/s/CyclopsVR/Assets/Packages/Pimax/LeapMotion/Core/Models/LowPolySphere.fbx.
    2021-03-19T14:47:59.6065423Z Unexpected file type
    ...


    I've checked agents folder when repository was pulled. The file was there but it's size was smaller then original file. So I figured it is only the git lfs pointer.
    So the agent was downloading the project repo for build but for binary files tracked with git lfs it only had a pointer not the complete file. (1KB vs 12KB)

    So I've added another step to the pipeline to git pull with lfs:

    (in azure-pipelines.yml)
    steps:
    - checkout: self # self represents the repo where the initial Pipelines YAML file was found
    lfs: true

    This indeed run the additional step in the job but file in agent work folder remained pointer (1KB). So I've manualy deleted the agent's work folder. Probably it doesn't clean the work folder on default checkout checkout with git pull lfs. So probably it's good idea to also add some command to clean the work folder before git pull.
    Anyway, after agent's work folder was clean I've run new job and it pulled the repository with full file content (not only the pointers for lfs tracked files).

    Additional resources:
    - attached 202103191549cyclopsvr build failed.txt, fullfile.png, lfspointer.png
    - https://stackoverflow.com/questions/56788144/how-to-use-git-lfs-with-azure-repos-and-pipelines
    - https://docs.microsoft.com/en-us/az...-devops&tabs=schema,parameter-schema#checkout
    - https://docs.microsoft.com/en-us/az...zure-devops&tabs=yaml#checkout-files-from-lfs
    - https://unitydevops.com/docs/unity-build-task/
    - https://github.com/microsoft/azure-pipelines-agent/blob/master/README.md



    Source for azure pipeline and project (current commit is 7e9fee9):
    https://github.com/paweltruong/Cyclops-VR
     

    Attached Files:

  3. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,689
    Quick Question @Pawciu , The Additional Compiler Arguments seem only to be available in the editor from 2021.
    Any ideas how to feed this in to earlier Unity versions in your research?

    *Edit, nws, figured it out. You need to add a "csc.rsp" test file in the Unity project and add the -r command for each dll

    Thanks for this post, it was a lifesaver
     
    Last edited: Aug 18, 2021
    Pawciu and Kurt-Dekker like this.
  4. wujinjindx

    wujinjindx

    Joined:
    Feb 9, 2020
    Posts:
    3
    • added .dll to ...\Editor\Data\Managed\
    actually works, and presumably make the dll available for all the project!
    a very useful way to add some common dll.

    I assume it is not recommended to put dll into this directory, but where should we put it?