Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback [Please Help] Bug in Unity .csproj Generation

Discussion in 'Entity Component System' started by Lieene-Guo, Apr 15, 2020.

  1. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    I am currently using a Trick to access internal Field of DOTS。
    First, add A Assembly Reference file in a target folder.
    upload_2020-4-15_11-21-22.png
    Then, add a c# source file in the folder for example InternalsVisibleTo.cs
    And add these lines
    Code (CSharp):
    1. using System.Runtime.CompilerServices;
    2. [assembly: InternalsVisibleTo("NameOfAssembly")]
    where NameOfAssembly can be any assembly name you want.
    By doing so, the target assembly will have internal access to Unity.Collections.
    And version control can syn this update as it is in Asset Folder, No package to Asset copy needed, No Reflection to access Internal needs. All good.
    Until---
    The problem is. after doing so. If a new source file is added to the target Assembly folder or maybe anywhere in the asset. Unity will update relevant .csproj file. along with Unity.Collection.csproj.
    And the new Unity.Collection.csproj will be with only InternalsVisibleTo.cs. All the collection sources are missing.
    Unity Editor itself will compile fine, as it knows about which source to include.
    But IDE that depends on .csproj file will be corrupted.
    I tried with VS2017/2019 or VSCode as External Script Tool, all failed.Rider not testes but it will probably fail too.

    The only fix now is to switch external tool, it seems that Unity will mark all .csproj and .sln "Dirty" when external tool is changed. And .csproj will be regenerated from the ground up after that. And these new files are okay, packages are good. Until-- Incremental source file change happen again.

    Unity 2019.3.2f1 Reproduc-able Tested on multiple PC.

    This is really annoying...

    Can this be solved? by some walk around, like force regenerate project file from ground up?

    PS. generate all .csproj files is checked.

    Also, when using VSCode as external IDE. generate all .csproj files could not generate .csproj
    for packages on my PC. But okay on my friend's PC.
    Could this because I have been installing Unity from like Unity 5 on this PC. And some registry settings are out of date?
     
    Last edited: Apr 15, 2020
  2. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    I found a way to fix corrupted project files.
    https://forum.unity.com/threads/sol...orce-unity-to-regenerate-csproj-files.868147/
    Built I still can not prevent them from being corrupted again.
    I found this source file: SyncSolutionUtilities.cs from Unity forum.
    I found this call to
    UnityEditor.SyncVS.Synchronizer.Sync
    is exactly what corrupted my project file.
    look like this internal function can not deal with .asmref in Asset folder referencing .asmdef in package cache case.
    Hope it can be fixed in later builds.
     

    Attached Files:

    Last edited: Apr 15, 2020
  3. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    upload_2020-4-15_17-18-49.png
    Clicking this source link (the blue lines) also corrupt vs project files.
     
  4. Lieene-Guo

    Lieene-Guo

    Joined:
    Aug 20, 2013
    Posts:
    547
    Hope Unity dev see this:)
     
  5. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    You can do a Bug Report with a repro project, it helps the staff to track down those issues.