GlitchEnzo / NuGetForUnity

A NuGet Package Manager for Unity
MIT License
3.25k stars 319 forks source link

NuGetForUnity CLI Package Generates Incorrect/missing .meta files #637

Open Reag opened 7 months ago

Reag commented 7 months ago

Description

The purpose of the NuGetForUnity CLI tool is to act as a pre build step for automated pipelines. However, when it downloads a DLL that includes a Roslyn Analyzer (Especially if said DLL is for code gen), said DLL will not receive a .meta file that includes the correct label. This means that the DLL will never perform its code gen in the automated pipeline.

In the normal editor, this isn't a problem, as part of the startup process includes a NuGet Restore that will build these meta files and tag them. However, in an automated pipeline, this step never seems to actually occur. If you perform

nugetforunity restore <PROJECTPATH> //Nuget Restore
unity-editor -quit        -batchmode -ignoreCompilerErrors ... //Run the project once, ignoring compilation errors. Should CodeGen
unity-editor -runTests -batchmode .... //Run tests!

It will fail to perform the required code gen and the .meta files will not have the correct label. Performing the same set of operations works fine if the editor is not in batch mode.

JoC0de commented 7 months ago

Hi @Reag Thanks for creating the issue and sorry for the delay. I created the CLI exactly for the reason that the batch mode didn't perform the restore operation at the correct point in time. But I never tested the .meta manipulation we als do in the restore/import. I think the main causes of the problem is that unity imports the dlls downloaded by the CLI before the NuGeForUnity plugin is imported by the package manager. One possible workaround would be to start unity twice, at least I think it helped to do the restore without the CLI. At least for the issue with Roslyn Analyzers it should be possible to duplicate the feature so the CLI also sets the correct .meta attributes.