Scaffolding: Scaffolding failed. Could not load information for project
Expand on this issue
- You won’t have this error if your project doesn’t have the “ProjectReference”
- When you add “ProjectReference” and try adding Scaffolded now you will get this error
Video:
Include stack traces
"[Trace]: Command Line: --project D:\WebProjects\ScaffoldingTest\ScaffoldingTest\ScaffoldingTest.csproj --no-build --port-number 49754 area Afa --dispatcher-version 2.0.0 --no-dispatch --simulation-mode
Scaffolding failed.
Could not load information for project D:\WebProjects\ScaffoldingTest\ScaffoldingTest.Model\ScaffoldingTest.Model.csproj
[Trace]: at Microsoft.VisualStudio.Web.CodeGeneration.Utils.RoslynWorkspaceHelper.GetProjectReferenceInformation(IEnumerable`1 projectReferenceStrings)
at Microsoft.VisualStudio.Web.CodeGeneration.Utils.RoslynWorkspace..ctor(IProjectContext projectInformation, String configuration)
at Microsoft.VisualStudio.Web.CodeGeneration.Design.CodeGenCommandExecutor.AddFrameworkServices(ServiceProvider serviceProvider, IProjectContext projectInformation)
at Microsoft.VisualStudio.Web.CodeGeneration.Design.CodeGenCommandExecutor.Execute(Action`1 simModeAction)
at Microsoft.VisualStudio.Web.CodeGeneration.Design.Program.<>c__DisplayClass4_0.<<Execute>b__0>d.MoveNext()"
Edit After I tried debugging https://github.com/dotnet/Scaffolding/blob/f9d5980105a2f1604e98a330b51a8959fe870097/src/Scaffolding/VS.Web.CG.Utils/Workspaces/RoslynWorkspaceHelper.cs#L12 I found the problem was that the project could not be obtained https://github.com/dotnet/Scaffolding/blob/f9d5980105a2f1604e98a330b51a8959fe870097/src/Scaffolding/VS.Web.CG.Utils/Workspaces/RoslynWorkspaceHelper.cs#L20
innerException:
InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk' specified could not be found.
Include provider and version information
Microsoft.VisualStudio.Web.CodeGeneration.Design version: 6.0.9 Target framework: .Net 6 Operating system: Windows 10 (21H2) IDE: Visual Studio Version 17.3.4
Edit: Found a solution (pending fix)
- Unload another project https://github.com/dotnet/Scaffolding/issues/2019#issuecomment-1250187016 or
- Make a new project, add scaffolding then copy to the main project https://github.com/dotnet/Scaffolding/issues/2019#issuecomment-1251531466
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 10
- Comments: 59 (2 by maintainers)
Commits related to this issue
- Reduced projects and implemented scaffolding due to issue reference in https://github.com/dotnet/Scaffolding/issues/2019 — committed to mudouasenha/2fa-practice by mudouasenha 2 years ago
I’m experiencing the same bug scaffolding identity on a multi project solution. I’m using 6.0.9 version of net core libraries.
Make new project with same solution and project name and add DB context and other necessary thing than scaffold then the new added files add in the main project you are making, now you are good to go.
On Tue, Sep 20, 2022, 01:39 Deep Choudhery @.***> wrote:
@42degrees @richardaubin I solved the issue of “package version returns back from 6.0.10 to 6.0.9 automatically”, by the following:
Add this package to the API’s project: Microsoft.VisualStudio.Web.CodeGeneration.Core With version 6.0.10 And change the version of Microsoft.VisualStudio.Web.CodeGeneration.Design to 6.0.10 and then save the project and run.
I am now getting several errors similar to this in the library/referenced project - Warning CS8032 An instance of analyzer Microsoft.CodeAnalysis.CSharp.Analyzers.FixAnalyzers.CSharpFixerWithFixAllAnalyzer cannot be created from C:\Users\MyUser.nuget\packages\microsoft.codeanalysis.analyzers\1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll: Could not load type ‘Microsoft.CodeAnalysis.Analyzers.FixAnalyzers.FixerWithFixAllAnalyzer
1' from assembly 'Microsoft.CodeAnalysis.Analyzers, Version=3.3.5.2003, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.. Project.Entities 1 Active System.TypeLoadException: Could not load type 'Microsoft.CodeAnalysis.Analyzers.FixAnalyzers.FixerWithFixAllAnalyzer1’ from assembly ‘Microsoft.CodeAnalysis.Analyzers, Version=3.3.5.2003, Culture=neutral, PublicKeyToken=31bf3856ad364e35’. at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.Extensions1.GetAnalyzersForTypeNames(Assembly analyzerAssembly, IEnumerable1 analyzerTypeNames, Boolean& reportedError)I can list all of them if necessary. Also, the MVC project kept rollbacking to 6.0.9.
I also have this problem. These workarounds work, but there is a lot of work to do. May this problem be resolved quickly 🤔
Description of my problem: https://stackoverflow.com/questions/73833413/asp-net-core-mvc-web-app-controller-wizard-issue Link to a sample project: https://github.com/everstudybee/DatabaseTest
Thank you so much, Deepak. Very kind of you to take the time to send this to me. I will be working on it later today and let you know how it goes.
Thank you again!
Michelle
On Thu, Sep 22, 2022 at 10:50 PM Deepak Joy Jose @.***> wrote:
Please can you tell me how to go back to version 6.0.8? I uninstalled version 6.0.9 of code generator (from cmd) and installed 6.0.8, but the problem sill present, and when I do scaffolding, the version of CodeGeneration.Design returns back to 6.0.9 automatically, even if I change it manually to 6.0.8.
Currently experiencing the issue for ASP.Net core web api scaffolding of controllers. VS 2019 .Net 6.0.9
I’m not able to scaffold my MVC Controller, with views, when my Library is unloaded. I’ve kept the reference, but it cannot find the ApplicationDbContext.
You do not need to remove the project references. Just unload the projects from your solution then retry adding scaffolded items. This way you can still use the referenced projects within your application. At least the best way workaround as of the moment until this bug gets fixed.
Bug occurs when scaffolding on classes that are (dependent on) references to user created projects. Removing project reference and add reference to the compiled library does not solve issue. It occurs both when generating Controllers and Views. Moving classes to the web project, performing generation and removing them works. But is impractical as that is an error-prone way of working. (Explaining this to students and expecting them to understand is unfeasible.)