Aspnetcore.docs: The located assembly's manifest definition does n ot match the assembly reference

Created on 30 May 2018  Â·  12Comments  Â·  Source: dotnet/AspNetCore.Docs

At the step dotnet aspnet-codegenerator razorpage -m Movie -dc MovieContext -udl -outDir Pages\Movies --referenceScriptLibraries, I get the following error:

D:\Users\John\Source\Repos\RazorPageMovie\RazorPageMovie>dotnet aspnet-codegenerator razorpage -m Movie -dc MovieContext -udl -outDir Pages\Movies --referenceScriptLibraries
Building project ...
Finding the generator 'razorpage'...
Running the generator 'razorpage'...
Could not load file or assembly 'System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:10.63
C:\>dotnet --version
2.1.4

I've closed VS and made sure I am in the correct directory.

The only other thing could be to do with Microsoft.VisualStudio.Web.CodeGeneration.Design version. I left off the version and let it install the latest which is:

PM> Get-Package Microsoft.VisualStudio.Web.CodeGeneration.Design

Id                                  Versions                                 ProjectName                                                                                                                                                                                
--                                  --------                                 -----------                                                                                                                                                                                
Microsoft.VisualStudio.Web.CodeG... {2.1.0}                                  RazorPageMovie

Any ideas as to what is wrong?

T, A


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Source - Docs.ms

Most helpful comment

For those following 2.1, the solution is actually created at 2.0 so my problem was the project target framework at 2.0, which was preventing Nuget from updating Microsoft.AspNetCore.All to 2.1

Change your target framework to 2.1 and then make sure you update Nuget package for Microsoft.AspNetCore.All , build the project and then run dotnet restore as the guide says

This is for VS Community 2017 15.7.3

All 12 comments

Try dotnet restore
that sometimes helps.
try the 2.1 version, it's much easier to follow.

I've run into the same issue, and dotnet restore did not resolve it.

@nospoon4u try the 2.1 version, it's much easier to follow.

@Rick-Anderson I also get this issue, following. Using the 2.1 version btw.

@jtshannon @HPringles you're getting Could not load file or assembly 'System.Collections.Immutable, Version=1.2.3.0 ?
Is that with the command line or VS? Try with VS. Is VS up to date? What does dotnet --version report?

I also met the same problem using vsCode. And dotnet -- version is 2.1.4.

@zackshine @HPringles @jtshannon you need to update the .NET Core SDK. It needs to be 2.1.300 or higher.

@Rick-Anderson So I managed to make it work. I had to manually edit the .csproj file to give ...CodeGeneration.Design version 2.0.0 instead of 2.1.0(or whatever it was before) that made it work - also updated the SDK.

My Full CSProj file is as follows :

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Pages\Movies\" />
  </ItemGroup>
</Project>

Can you use 2.1? Use M.A.App, not M.A.All
It's much simpler with 2.1

at ContosoUniversity.csproj file
change
PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.0"
PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.1.0"
to
PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0"
PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.0.0"

It worked for me.

For those following 2.1, the solution is actually created at 2.0 so my problem was the project target framework at 2.0, which was preventing Nuget from updating Microsoft.AspNetCore.All to 2.1

Change your target framework to 2.1 and then make sure you update Nuget package for Microsoft.AspNetCore.All , build the project and then run dotnet restore as the guide says

This is for VS Community 2017 15.7.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Rick-Anderson picture Rick-Anderson  Â·  3Comments

madelson picture madelson  Â·  3Comments

aaron-bozit picture aaron-bozit  Â·  3Comments

wgutierrezr picture wgutierrezr  Â·  3Comments

sonichanxiao picture sonichanxiao  Â·  3Comments