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

Exception: Must set an output directory through SetCompileScriptsOutputDirectory before compiling #581

Closed
CDTR-MattConroy opened this issue Oct 11, 2023 · 2 comments · Fixed by #691

Comments

@CDTR-MattConroy
Copy link

CDTR-MattConroy commented Oct 11, 2023

Description

When opening a Unity Project that already contains NuGetForUnity and has restored packages, Unity prompts to enter Safe Mode as there are compilation issues. If I Ignore and open Unity, I am presented with the following logs, once for each installed package:

Warning:

Import Error Code:(4)
Message: Build asset version error: assets/packages/<package-name>.<package-version>/lib/<net-version>/<package-name>.dll.meta in SourceAssetDB has modification time of '2023-10-11T10:00:24.4550484Z' while content on disk has modification time of '2023-10-11T10:00:28.709174Z'

Error:

Exception: Must set an output directory through SetCompileScriptsOutputDirectory before compiling
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.GetCompileScriptsOutputDirectory () (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CreateScriptAssemblySettings (UnityEditor.BuildTargetGroup buildTargetGroup, UnityEditor.BuildTarget buildTarget, UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, System.String[] extraScriptingDefines) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CreateScriptAssemblySettings (UnityEditor.BuildTargetGroup buildTargetGroup, UnityEditor.BuildTarget buildTarget, UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CreateEditorScriptAssemblySettings (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Scripting.ScriptCompilation.EditorCompilation.GetAllScriptAssemblies (UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, UnityEditor.Scripting.ScriptCompilation.PrecompiledAssembly[] unityAssembliesArg, System.Collections.Generic.Dictionary`2[TKey,TValue] precompiledAssembliesArg, System.String[] defines) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Compilation.CompilationPipeline.GetScriptAssemblies (UnityEditor.Scripting.ScriptCompilation.IEditorCompilation editorCompilation, UnityEditor.Scripting.ScriptCompilation.EditorScriptCompilationOptions options, System.String[] extraScriptingDefines) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Compilation.CompilationPipeline.GetScriptAssemblies (UnityEditor.Scripting.ScriptCompilation.IEditorCompilation editorCompilation, UnityEditor.Compilation.AssembliesType assembliesType, System.String[] extraScriptingDefines) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Compilation.CompilationPipeline.GetAssemblies (UnityEditor.Scripting.ScriptCompilation.EditorCompilation editorCompilation, UnityEditor.Compilation.AssembliesType assembliesType, System.String[] extraScriptingDefines) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.Compilation.CompilationPipeline.GetAssemblies (UnityEditor.Compilation.AssembliesType assembliesType) (at <88872b21b1e746a7ad699974a2be8304>:0)
NugetForUnity.UnityPreImportedLibraryResolver.GetAlreadyImportedLibs () (at ./Library/PackageCache/[email protected]/Editor/UnityPreImportedLibraryResolver.cs:46)
NugetForUnity.UnityPreImportedLibraryResolver.GetAlreadyImportedEditorOnlyLibraries () (at ./Library/PackageCache/[email protected]/Editor/UnityPreImportedLibraryResolver.cs:90)
NugetForUnity.NugetPackageAssetPostprocessor+<HandleAsset>d__6.MoveNext () (at ./Library/PackageCache/[email protected]/Editor/NugetPackageAssetPostprocessor.cs:128)
System.Linq.Lookup`2[TKey,TElement].Create (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] keySelector, System.Collections.Generic.IEqualityComparer`1[T] comparer) (at <fa6dfabea46b4d38a92695d5d0cf891d>:0)
System.Linq.GroupedEnumerable`2[TSource,TKey].GetEnumerator () (at <fa6dfabea46b4d38a92695d5d0cf891d>:0)
NugetForUnity.NugetPackageAssetPostprocessor.LogResults (System.Collections.Generic.IEnumerable`1[T] results) (at ./Library/PackageCache/[email protected]/Editor/NugetPackageAssetPostprocessor.cs:256)
NugetForUnity.NugetPackageAssetPostprocessor.OnPreprocessAsset () (at ./Library/PackageCache/[email protected]/Editor/NugetPackageAssetPostprocessor.cs:67)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <cbc72d4a9767498db39486e941a498e3>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <cbc72d4a9767498db39486e941a498e3>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <cbc72d4a9767498db39486e941a498e3>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethodIfAvailable (System.Object target, System.String methodName, System.Object[] args) (at <88872b21b1e746a7ad699974a2be8304>:0)
UnityEditor.AssetPostprocessingInternal.PreprocessAsset () (at <88872b21b1e746a7ad699974a2be8304>:0)
  • NuGetForUnity Version: 3.1.3
  • Unity Version: 2022.2.17
  • Operating System: Windows 11
@JoC0de
Copy link
Collaborator

JoC0de commented Oct 11, 2023

A SourceAssetDB has modification error is just a caching think. Unity stores information all imported files inside a database in the Library folder. If the file in the database and the file on the disk is out of sync you can get this error. This can happen if the file gets modified while unity is importing it. In the NugetPackageAssetPostprocessor we change some settings of the .dll so they are stored inside the .dll.meta. But I don't see a reason why this can produces the out of sync error.
I see that GetAlreadyImportedEditorOnlyLibraries is inside the call stack so eventually it is because we try to query for installed Assemblies while Unity is still starting.
Can you reproduce this? Because I never saw this error by my self. Eventually we need to skip the GetAlreadyImportedEditorOnlyLibraries part when doing a first time "open project".
Normally the AssetPostprocessor marks every file he torched / configured once with a NuGetForUnity lable. Does the file that produces the error has the lable?

@Artemiy42
Copy link

Artemiy42 commented Sep 1, 2024

Hi, I have the error playing every time.
Steps to reproduce it:

  1. Create a project (I am using Unity 2022.3.37f)
  2. Install NuGetForUnity via OpenUPM
  3. Install dependencies (for example R3)
  4. Close Unity and delete the ./Assets/Packages folder so that they will be restored when you open Unity.
  5. Open the project and catch an error

I've tried deleting the Library folder, but the error persists.

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

Successfully merging a pull request may close this issue.

3 participants