正在查找生成器 'identity'...给定的程序集名称或代码库无效

Finding the generator 'identity'... The given assembly name or codebase was invalid

我的 App 构建和 运行 都很好。但是当我尝试 运行 dotnet aspnet-codegenerator identity --useDefaultUI 时,它会出错:

Building project ...

Finding the generator 'identity'...

The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean raiseResolveEvent) at System.Reflection.AssemblyName..ctor(String assemblyName) at Microsoft.VisualStudio.Web.CodeGeneration.DefaultCodeGeneratorAssemblyProvider.b__6_0(DependencyDescription lib) at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext() at Microsoft.VisualStudio.Web.CodeGeneration.CodeGeneratorsLocator.get_CodeGenerators() at Microsoft.VisualStudio.Web.CodeGeneration.CodeGeneratorsLocator.GetCodeGenerator(String codeGeneratorName) at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args) RunTime 00:00:05.76

这解决了我的问题:https://github.com/aspnet/Scaffolding/issues/586

简而言之:我不得不从我的 .csproj 文件中删除

<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="1.1.1" />