AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

dotnet aspnet-codegenerator crash

Open nelfer opened this issue 8 years ago • 4 comments

The command:

dotnet aspnet-codegenerator razorpage -m Movie -dc MovieContext -udl -outDir Pages/Movies --referenceScriptLibraries

Crashes with the following error message:

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:03.99

Was using .Net Core 2.1.200 and upgraded to 2.1.401 and still the same issue. Linux machine, Ubuntu 16.04


Document Details

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

nelfer avatar Aug 24 '18 00:08 nelfer

'System.Collections.Immutable, Version=1.2.3.0 can't be correct. What does your project file look like?

Rick-Anderson avatar Aug 24 '18 00:08 Rick-Anderson

Here are the instructions for the updated RP/EF tutorial. Adjust them for your project

dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design --version 2.1.0
dotnet aspnet-codegenerator razorpage -m Student -dc ContosoUniversity.Models.SchoolContext -udl -outDir Pages\Students --referenceScriptLibraries

Rick-Anderson avatar Aug 24 '18 00:08 Rick-Anderson

This is my project. It was target framework netcoreapp2.0 and I changed it to 2.1 and Microsoft.AspNetCore.All changed it to 2.1.3 (it was 2.0.8) and now it works. I think what happened is that I started the tutorial in 2.1.200 and so the template had old references.

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.3" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.3" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
  </ItemGroup>
</Project>

nelfer avatar Aug 24 '18 02:08 nelfer

@nelfer thanks for the update. This will probably help someone else out.

Rick-Anderson avatar Aug 24 '18 02:08 Rick-Anderson