2

I have the following project setup:

  • Unity project in C:\XXX
  • Added an another project to solution, located in C:\XXX\Tests

Now, whenever adding a class to that Test project, I found that a .meta file is being added as well.

This doesn't seem correct as .meta files are supposedly only for files inside Assets.

Using Process Monitor I discovered that indeed it is devenv.exe that is creating these .meta files.

Quick-fix:

Using ignores Visual Studio and Unity ignores, these .meta files are not committed to the repository,

And adding this to the csproj will hide them:

  <ItemGroup>
    <None Update="**/*.meta" Visible="false" />
  </ItemGroup>

But in reality, this only hides the problem ...

And unfortunately, this approach won't work in Directory.Build.props, forcing one to manually add former code block to each of these 'external' projects.

Question:

Why are .meta files also created outside Assets and how to turn that off?

aybe
  • 15,516
  • 9
  • 57
  • 105
  • Had a similar issue shortly when having multiple projects (assemblies) in Unity. It created `.meta` files even for some of the `.sln` solutions which was really strange. I couldn't reproduce it though, but sometimes it still happens again – derHugo Jan 28 '20 at 06:50
  • Yes, apparently, it does not always happen! – aybe Jan 28 '20 at 06:53

1 Answers1

2

For now, putting this in Directory.Build.props at root effectively removes the need to manually update each project:

<Project>
    <PropertyGroup>
        <DefaultItemExcludes>$(DefaultItemExcludes);**\*.meta</DefaultItemExcludes>
    </PropertyGroup>
</Project>

But this only hides the problem instead of fixing it...

Update

The problem comes from Resharper and has been fixed:

Avoid creating meta files outside Assets and Packages (#1489)

aybe
  • 15,516
  • 9
  • 57
  • 105