Local package outside of project folder

Hi.
Upfront, I am using the (currently) newest Unity 2018.2.0f2 with Package Manager 1.9.11.
I have created a local package inside the Packages Folder and referenced it in the manifest.json and everything works fine.
But when I move the Package outside of the Project folder(and change the path in the manifest) something strange happens.
Unity does recognize the package and the code compiles normally. But when I want to open the C# Project via the Assets menu, it gives me an error and does not open the Visual Studio:

NotSupportedException: Visual Studio Tools: Project file has no matching compilation unit for Packagename
SyntaxTree.VisualStudio.Unity.Bridge.ProjectFilePostprocessor.OnGeneratedCSProject (System.String path, System.String content)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[ ] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.AssetPostprocessingInternal.CallOnGeneratedCSProject (System.String path, System.String content) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:178)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.SyncProjectFileIfNotChanged (System.String path, System.String newContents) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:320)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.SyncProject (MonoIsland island, System.Collections.Generic.Dictionary2 allAssetsProjectParts, UnityEditor.Scripting.Compilers.ResponseFileData responseFileData, System.Collections.Generic.List1 allProjectIslands) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:313)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.GenerateAndWriteSolutionAndProjects (ScriptEditor scriptEditor) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:245)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.Sync () (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:217)
UnityEditor.SyncVS.SyncSolution () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:190)
UnityEditor.SyncVS.SyncAndOpenSolution () (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:181)

I had this working already in a previous Unity Version I think. I do not remember if it was 2018.1 or 2018.2.beta.

Use the VS 2017 installer to update your VS installation to the latest version.

1 Like

If your VS 2017 is already at 15.7.5 (or greater) you can also try updating the two packages below individually. This fixed the error more reliability for me:
https://xamarin.azureedge.net/vstu/dev15/3.8.0.3/vstu2017.msi
https://xamarin.azureedge.net/vstu/dev15/3.8.0.3/SyntaxTree.VisualStudio.Unity.vsix

3 Likes

Hi, I have the same problem on osx.

VS for mac version: 7.5.4 (Build 3)
vs4m tools for unity version: 1.5.0.1
Unity 2018.2.0f2

edit:
solved by switching VS to the beta channel and updating to
VS 7.6 Preview (7.6 build 2086)
tools 1.6.0.2

the same Mac problem