Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"(assembly) is already imported in engine" - but I don't think it is? #627

Open
tattyd opened this issue Mar 4, 2024 · 1 comment
Open

Comments

@tattyd
Copy link

tattyd commented Mar 4, 2024

Description

Hi there,

I'm trying to install the R3 package via NuGetforUnity.

It fails to install all transitive dependencies, specifically, System.Runtime.Compilerservices.Unsafe. On the console, I see the message:

Is package 'System.Runtime.CompilerServices.Unsafe' already imported? True
Package System.Runtime.CompilerServices.Unsafe.6.0.0 is already imported in engine, skipping install.

However, then Unity fails to compile saying that assembly is missing. From some quick experimentation:

public class Assemblies
{
    // menu item to print all assemblies
    [UnityEditor.MenuItem("Tools/Print Assemblies")]
    public static void PrintAssemblies()
    {
        var assemblies = CompilationPipeline.GetAssemblies(AssembliesType.Editor);
        foreach (var assembly in assemblies)
        {
            Debug.Log(assembly.name);
            Debug.Log(assembly.outputPath);
        }
    }
}

Is it possible that Nuget is mistaken? Is there any other way I can truly verify whether the dependency is already present, and if so where it is?

I don't see System.Runtime.CompilerServices.Unsafe anywhere in the output.

  • NuGet Package: System.Runtime.CompilerServices.Unsafe
  • NuGetForUnity Version: 3.0.5
  • Unity Version: 2023.2.11f1
  • Operating System: Win 10
@tattyd tattyd changed the title "(assemble) is already imported in engine" - but I don't think it is? "(assembly) is already imported in engine" - but I don't think it is? Mar 4, 2024
@JoC0de
Copy link
Collaborator

JoC0de commented Mar 6, 2024

Hi @tattyd
thanks for the issue.
Especially in Unity versions > 2023 Unity has different assemblies that are available in Editor / Player.
NuGet for unity uses the following to determine the assemblies:

const AssembliesType assemblyType = AssembliesType.Player;
#endif
var projectAssemblies = CompilationPipeline.GetAssemblies(assemblyType)

If you try to use the importer NuGet package in a Editor assembly you probably can fix it by changing the Editor Assembly Compatibility Level in the Unity settings so it matches the one used in runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants