7

In a Visual Studio Extension (VSIX) solution, I'm using Roslyn to load a specific project from my current solution:

Project myProject = 
    this.CurrentComponentModel.GetService<VisualStudioWorkspace>()
        .CurrentSolution.Projects
             .FirstOrDefault(p => p.Name == "MyProject")

The projct myProject is definitely loaded, but on inspection I see that:

myProject.HasDocuments == false
myProject.Documents is Empty

And yet, in Visual Studio I can see loads of documents.

If I close the solution and open the same solution but from another TFS branch, then the same code returns:

myProject.HasDocuments == true 
myProject.Documents is not Empty

Any ideas?

farlee2121
  • 2,959
  • 4
  • 29
  • 41
DrGriff
  • 4,394
  • 9
  • 43
  • 92
  • Could you share a project that does this with us (in other words, a [mcve])? Otherwise, I doubt anyone will be able to help you. – svick Jun 09 '16 at 18:49

1 Answers1

0

I got this to work by:

  1. Deleting the obj/debug folder
  2. Cleaning
  3. Transforming all T4 templates (this is ASP.NET MVC)
  4. Restarting Visual Studio
  5. Re-compiling

Simply re-compiling had no effect. Can't explain why, but the above formula worked for me.

DrGriff
  • 4,394
  • 9
  • 43
  • 92
  • In my case, it was a matter of updating nuget packages for Microsoft.Build and Microsoft.Build.Tasks.Core in my analyzer – farlee2121 May 07 '18 at 18:41