Error building project with visual studio in Unity 2018 : Unity Package Source file not found error

When I tried to build and attach my visual studio debugger to Unity I got lots of
“CSC : error CS2001: Source file could not be found.” related to the new Package Manager.

It must be related to the new package manager, and when visual studio tries to locate some “embedded c# script” they could not be found.

Anybody encountered this issue and has found a fix or workaround for it?

1 Like

I have the same exact thing happening with all of my projects I create in Unity 2018.2.0f2. A bunch of CS2001 errors for each file within each of the packages that are by default loaded in with the new package manager.

It does not seem to prevent me from writing scripts and running them in the Unity Editor but I can’t use Visual Studio to compile without getting 45 errors having to do with package files that Visual Studio can’t find/read.

I have tried removing the packages and re-adding them and also recreating projects. Seems to be a continuous issue for me. I guess I can live with it for the time being but it is hard to ignore 45 unrelated red X’s every time I try to build my scripts.

I had the same issue, but installing the latest version of Visual Studio Community 2017 fixed the problem for me ! :slight_smile:

I actually deleted all the .csproj and the .sln. Then after having installed the latest visual studio update, I reopened a script from the editor, and Unity properly recreated the .csprojs and the .sln with ONLY my project scripts.

(so 4 .csprojs and 1 .sln, but not the ton of unwanted packages .csproj it was generating before the visual studio update)

2 Likes

Confirm the issue. I download Text mesh Pro with Package Manager and I can use asset in editor, but VS 2017 can’t find any references to Text Mesh Pro scripts
Unity please fix this issue, or remove Packeg Manager from 2018 verision, thx.

OK, for now I fixed this issue (don’t think this is the best way but still):
I discovered that VS can’t see some files

That was because there no any files like that in my project, so then:

  1. Some googling (visual studio - Error: "Assembly with name 'UnityEditor.StandardEvents' already exists (Packages/com.unity.standardevents/Editor/Editor.asmdef)" - Stack Overflow).
  2. So I discover the path to the cache (C:\Users(name of your account)\AppData\Local\Unity). Folks says to remove everything from there, but i just copy folders “Scripts” and “Test” from
    C:\Users\ (name of your account) \AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.textmeshpro@1.2.4;
  3. and paste it to the corresponding project folder (\ProjectPath\Packages\com.unity.textmeshpro).

And it seems to work fine.

Since that i think that something goes wrong when Unity tried to check cache and accidentally concluded that files are already exists in project.

4 Likes

Same problem here. Anything official?

Having the same issue after updating from 2017.x to 2018.2.3f1.

Same issue here, cannot debug in Visual Studio since 2018.2.x! At least not when using the package manager:(

Same issue, and above work-around didn’t work for me

Deleting the cache worked for me, thanks!

Deleting the cache didn’t work for me. I tried uninstalling Unity and installed 2018.2.5f1. That did not help. I upgraded from VS 2017 15.5.x to 15.8.1. That worked!

1 Like

Had same problem.

Try VisualStudio Update. It worked for me.

2 Likes

Updated to 15.8.2 still broken for me

I use VS 2015, as 2017 is pretty unusable for me. Is there an update/fix I could get for 2015?

Fixed the same issue by removing and reinstalling the TextMesh Pro package from Package manager worked for me.

On Unity 2018.2.6f1, just upgraded to VS2017 community 15.8.2, deleted the solution and project files, reopened the c# project, but still the source files of the pacakge manger still are not found and cause CS2001 errors.

edit: deleting the library folder and every I could find, helped and it is now compiling :smile:

I was encountering this issue (Unity 2018.2, VS 15.5.4) and resolved it by creating an empty Assembly Definition at the top level of my scripts folder.

As an absolute beginner on this platform, I was disheartened because I couldn’t get going the very basic application.
Even with latest Unity Pro and VS2017 I got 46 errors and don’t understand where the problem is.
Please Microsoft do something about this!

That worked for me!!! Thanks!

This worked for me, Unity 2018.2.16f1, VS 15.9.2

1 Like