unity build_error ai_generated partial

IL2CPP error: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Build\Temp\StagingArea\Data\Managed\System.dll'

ID: unity/il2cpp-error-marshal-directorynotfound

Also available as: JSON · Markdown · 中文
75%Fix Rate
86%Confidence
1Evidence
2024-05-02First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Unity 2022.3.30f1 active
Unity 2023.2.5f1 active
Unity 6000.0.0a20 active

Root Cause

The IL2CPP build process cannot find a required managed assembly (e.g., System.dll) in the staging area, often due to incomplete build cache or missing .NET backend files.

generic

中文

IL2CPP 构建过程在暂存区找不到所需的托管程序集(例如 System.dll),通常是由于构建缓存不完整或缺少 .NET 后端文件。

Official Documentation

https://docs.unity3d.com/Manual/IL2CPP.html

Workarounds

  1. 80% success Delete the 'Library' and 'Temp' folders in the project directory, then rebuild from scratch. This clears the corrupted build cache.
    Delete the 'Library' and 'Temp' folders in the project directory, then rebuild from scratch. This clears the corrupted build cache.
  2. 70% success In Project Settings > Player > Configuration, set 'Scripting Backend' to 'IL2CPP' and 'Api Compatibility Level' to '.NET Standard 2.1' (or '.NET Framework' if available). Then perform a clean build via Build Settings > Clean Build.
    In Project Settings > Player > Configuration, set 'Scripting Backend' to 'IL2CPP' and 'Api Compatibility Level' to '.NET Standard 2.1' (or '.NET Framework' if available). Then perform a clean build via Build Settings > Clean Build.

中文步骤

  1. Delete the 'Library' and 'Temp' folders in the project directory, then rebuild from scratch. This clears the corrupted build cache.
  2. In Project Settings > Player > Configuration, set 'Scripting Backend' to 'IL2CPP' and 'Api Compatibility Level' to '.NET Standard 2.1' (or '.NET Framework' if available). Then perform a clean build via Build Settings > Clean Build.

Dead Ends

Common approaches that don't work:

  1. 80% fail

    The issue is a corrupted build cache, not missing Unity components.

  2. 95% fail

    The staging area is regenerated each build; manual copies are overwritten or cause version mismatches.

  3. 50% fail

    This avoids the error but changes the runtime behavior and may not be acceptable for platforms requiring IL2CPP (e.g., iOS, WebGL).