0
votes

I'm currently facing an ugly Problem while trying to scaffold from Control class. I get the following error:

Scaffolding error

The error text is:

There was an error running the selected Code Generator: 'Unhandled Exception: System.TypeLoadException: Could not load typa 'Microsoft.VisualStudio.Web.CodeGeneration.ConsoleLogger' from assembly Microsoft.VisualStudio.Web.CodeGeneration.Core, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. at Microsoft.VisualStudio.Web.CodeGeneration.Tools.Program.Main(String [] args)'

My project.json file is:

"Microsoft.EntityFrameworkCore.Design": "1.1.2",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.2",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
  "version": "1.1.1",
  "type": "build"
},
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.2",
"Microsoft.Extensions.Configuration.Json": "1.1.2",
"Microsoft.Extensions.Configuration.UserSecrets": "1.1.1",
"Microsoft.Extensions.Logging": "1.1.2",
"Microsoft.Extensions.Logging.Console": "1.1.2",
"Microsoft.Extensions.Logging.Debug": "1.1.1",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.2",
"Microsoft.NETCore.App": {
  "version": "1.1.1",
  "type": "platform"
},
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
  "version": "1.1.0-preview4-final",
  "type": "build"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Core": "1.1.1",
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
  "version": "1.1.1",
  "type": "build"
},
"Microsoft.VisualStudio.Web.CodeGeneration.Design": "1.0.1"

"tools": {
"BundlerMinifier.Core": "2.4.337",
"Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final",
"Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
  "version": "1.1.0-preview4-final",
  "imports": [
    "portable-net45+win8"
  ]
}
  },

Any idea where I'm doing wrong?

I've already read some other Posts on SO, but I've found no help.

1
IIRC the last versions which supports VS2015 (I assume you still use that since you're on project.json - VS2017 uses csproj) is -preview2-final. Try these or switch to VS2017, migrate to csproj and use the RTM toolsTseng
Hi Tseg, which versions should I Change exactly? I don't really understand what you are referring toCode4Fun
The packages in the tools section, like "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",. The last version of these tools (all of it with 1.1.0-preview4-final as version) are for VS2017. Newer versions of these tools won't run anymore on VS2015 (only 1.1.0-preview2-final or older). There won't be any further updates for VS2015 so you should switch to VS2017 sooner than laterTseng
I've tried with all versions. It does not work. I get the same error. There should be a way to let it run in VS2015Code4Fun
Did you change the versions in both dependencies and tools? Any nuget restore errors? I.e. Microsoft.EntityFrameworkCore.Tools.DotNet isn't there in preview2-final iirc, it was split out in preview 3 iirc. so instead you need to use Microsoft.EntityFrameworkCore.Tools and 1.0.0-preview2-finalTseng

1 Answers

0
votes

I decided to move to Visual Studio 2017. After some troubles I got it running again, but be aware:

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0-msbuild3-final" PrivateAssets="All" />

<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0-msbuild3-final" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0-msbuild3-final" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
</ItemGroup>

I hope this will help