Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Command Line -importPackage doesn't extract files in batch mode

Discussion in 'Editor & General Support' started by PDZ, Jul 25, 2016.

  1. PDZ

    PDZ

    Joined:
    Sep 12, 2013
    Posts:
    18
    I'm trying to automate the process of updating a unity project with a package. From a bash script, I run:

    which updates the package as expected. The variables above are just directory paths as you might imagine.

    However when I try to run the same command with the -batchmode flag, the package does not get imported. There isn't anything amiss in the editor logs, and I've tried with Unity 5.1 and 5.3.4. It is as if Unity quits before it actually gets to import the files but it's imported the package. Or is that the way it is designed?

    Anyone having any similar issues?
     
  2. NachoFernandez

    NachoFernandez

    Joined:
    Oct 3, 2017
    Posts:
    3
    I am seeing similar issues, I wonder if this has been resolved :) (I'm on 5.6.1f1 (2860b30f0b54) revision 2646195)
     
  3. dklompmaker_aofl

    dklompmaker_aofl

    Joined:
    Apr 13, 2017
    Posts:
    9
    Bumping this as we are seeing this too in 2017.2.1p2 Editor. Essentially, we call into AssetDatabase.ImportPackage during a command line method execution on Unity. The console reports that it is displaying a progress bar for importing the package however it is never imported.

    From another thread, we've learned that ImportPackage is non-blocking; therefore, we've tried a while loop that checks for the imported asset else Thread.sleeps. The problem here, is that it blocks the main thread which then must prevent the package from importing.

    Does anyone else have a work around for this?
     
  4. ZOS_DanBatson

    ZOS_DanBatson

    Joined:
    Oct 17, 2018
    Posts:
    2
    I'm still seeing this issue in 2018.1.9f2. Did Unity ever comment? This seems pretty egregious. If you're importing packages, you're obviously doing it because you reference those packages in your code. So why would it check for errors BEFORE importing?
     
    bszalapski likes this.
  5. Henningboat2

    Henningboat2

    Joined:
    Jan 7, 2016
    Posts:
    5
    I'm gonna bump this up because I am still seeing the same issue in 2019.3. Anyone knows a workaround for this?
    I am currently building a build pipeline that would greatly benefit from this
     
  6. djcam13

    djcam13

    Joined:
    Sep 15, 2017
    Posts:
    1
    Same here. Building a pipeline by trial and error. Encountering the same issue.
     
    bszalapski likes this.
  7. bszalapski

    bszalapski

    Joined:
    Feb 21, 2020
    Posts:
    4
    Hello Unity team -- any updates here? How can we use `-batchmode` to import a package with headless Unity?
     
  8. whd2020

    whd2020

    Joined:
    Sep 9, 2020
    Posts:
    1
    I am also having the same issue here (2019.4.13f1).

    I am creating a pipeline to test a package in Azure DevOps for that i need to create a project from the command line, which runs fine. But I also need to import the package before running the unit tests.

    Can we file a bug regarding the -importPackage switch.
    I should also add that documentation does not specify if we should provide the relative or absolute path of the directory containing the package, the package.json file or the tarball archive.
     
  9. callumroseFC

    callumroseFC

    Joined:
    May 10, 2019
    Posts:
    5
    Bump this also having this problem
     
  10. callumroseFC

    callumroseFC

    Joined:
    May 10, 2019
    Posts:
    5
    FYI for anyone still having this issue I used the
    -importPackage
    argument with the absolute path of the package e.g.

    "C:\Program Files\Unity\Hub\Editor\2021.3.1f1\Editor\Unity.exe" -batchmode -nographics -projectPath "%ProjectPath%" -importPackage "%ProjectPath%\Library\PackageCache\com.unity.textmeshpro@3.0.6\Package Resources\TMP Essential Resources.unitypackage" -quit


    Note in my case I was also using
    -executeMethod
    and the package was always imported after the call to the method. This didn't work for me because I was calling a custom build pipeline which was dependent on the package being imported. To get around this on our build server I ran the above import command as a separate build step before using
    -executeMethod
    .
     
    asofron_amber likes this.