0

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.

Code4Fun
  • 413
  • 5
  • 17
  • 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 tools – Tseng Jul 07 '17 at 16:36
  • Hi Tseg, which versions should I Change exactly? I don't really understand what you are referring to – Code4Fun Jul 07 '17 at 16:49
  • 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 later – Tseng Jul 07 '17 at 16:52
  • 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 VS2015 – Code4Fun Jul 07 '17 at 18:10
  • 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-final` – Tseng Jul 07 '17 at 18:23
  • Hi Tseng, I changed all references and also put back Microsoft.EntityFrameworkCore.Tools.DotNet to Microsoft.EntityFrameworkCore.Tools, but no way to get it running. – Code4Fun Jul 07 '17 at 19:06
  • Check this package "Microsoft.VisualStudio.Web.CodeGeneration.Design": "1.0.1"` all other packages are 1.1 series except this one. Perhaps align that on 1.1 train and try. – Smit Jul 10 '17 at 17:42

1 Answers1

0

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

Code4Fun
  • 413
  • 5
  • 17