Scaffolding: Error 'Could not load file or assembly 'Microsoft.VisualStudio.Web.CodeGeneration.Utils, Version 1.1.0.0'
I am attempting to scaffold a controller in an ASP.NET Core app targeting 1.1 in Visual Studio 2017 Community. When I do, I get the error:
'Could not load file or assembly ‘Microsoft.VisualStudio.Web.CodeGeneration.Utils, Version 1.1.0.0’
I’ve read up on similar issues, and gotten this to work in the command line on a Mac with Visual Studio Code by adding the “PackageTargetFallback” shown below. However, am unable to get this working on VS2017 on Windows 2012.
If I fiddle with the Microsoft.VisualStudio.Web.CodeGeneration.Design and Microsoft.VisualStudio.Web.CodeGeneration.Tool references to get newer versions, and to add Microsoft.VisualStudio.Web.CodeGeneration.Utils DotNetCliToolsReference I get different errors such as:
Package Microsoft.Composition 1.0.27 is not compatible with netcoreapp1.1 .
This is referenced in issue #18452, but the “fix” is to remove Microsoft.VisualStudio.Web.CodeGeneration.Design, which breaks scaffolding.
Is scaffolding supported in netcorapp1.1 & visual studio 2017? If so, what is wrong with my environment and/or csproj here?
.csproj is below.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hangfire" Version="1.6.12" />
<PackageReference Include="Hangfire.Console" Version="1.3.1" />
<PackageReference Include="MailKit" Version="1.14.2" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0-msbuild3-final" PrivateAssets="All" />
</ItemGroup>
<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>
</Project>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 32 (6 by maintainers)
I found a solution. I deleted bin & obj folders then it gave me error it couldnt find project.deps.json in debug folder. I set project to debug, ran it and now I can add scaffolded items.
Downgrading “Microsoft.VisualStudio.Web.CodeGeneration.Design” from 3.0.0 to 2.2.4 resolved the issue for me. VS2019, AspNet Core 2.2
These are the corresponding CodeGeneration.Design packages to use for the following TFMs:
.NET CoreApp 2.1 -> https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Design/2.1.10
.NET CoreApp 2.2 -> https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Design/2.2.4
.NET CoreApp 3.0 -> https://www.nuget.org/packages/Microsoft.VisualStudio.Web.CodeGeneration.Design/3.0.0
Hope this helps. We are trying to improve the experience by failing to install the package that is not compatible.
The reason we need these mapping packages is because the content generated for each of these TFMs could be different.
I was getting similar issues then i realized my mistake. I had update to EF Core 3.1 and updated all my Nuget packages to 3.1 which was a mistake. My project was still targeting .Net Core 3.0 so I needed to keep the 3.0 version of Microsoft.VisualStudio.Web.CodeGeneration.Design to match the .Net Core version my project targets.
Note: the Nuget package manager UI in visual studio suggests I update to 3.1 so you can get caught out if you blindly update all packages.
For me, these suggestions didn’t solve. i’m using vs2019 - “Microsoft.VisualStudio.Web.CodeGeneration.Design” Version=“3.0.0”
Reinstall Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Utils
Thanks @Lukkian , that worked for me !!!
@Lukkian Your solution worked for me as well!! Thanks
I found that originally the reference
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.0" ExcludeAssets="all" />hasExcludeAssets="all". I added it manually because of How to stop the localized Microsoft.CodeAnalysis.*.resources.dll files from getting published by ASP.NET Core? problem. That should be my original problem. Remove this reference then add again solves.