Dar*_*nso 62 c# asp.net-core-mvc .net-core asp.net-core
尝试使用带有Update 3的Visual Studio 15 Enterprise在ASP.NET Core项目中添加Controller时,出现以下错误:
"The was an error running the selected code generator: No executables found matching command 'dotnet-aspnet-codegenerator'"
joh*_*rdy 151
如果您使用的是csproj(Visual Studio 2017)而不是project.json,那么您需要将以下内容添加到csproj文件中:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
对于最新版本,在project.json中添加以下依赖项:
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.1.0-preview4-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"type": "build",
"version": "1.1.0-preview4-final"
}
Run Code Online (Sandbox Code Playgroud)
和以下工具:
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.1.0-preview4-final",
"imports": [
"portable-net45+win8"
]
}
Run Code Online (Sandbox Code Playgroud)
比将版本号复制到配置文件中更为可靠的答案是使用NuGet来确保将包添加到项目中.
工具 - > NuGet包管理器 - >管理解决方案的NuGet包.
首先,让一切都是最新的.选择"更新"选项卡.选中"全部更新"复选框,然后运行几次.如果某些东西在升级前几次降级,请不要感到惊讶.某些依赖项似乎必须按顺序处理.我花了大约5次升级来获取最新信息.
然后,在浏览选项卡中搜索CodeGeneration.Tools.安装它.做同样的事情CodeGenerators.Mvc.当您发现其他错误消息时,您应该能够在NuGet中找到任何缺少的包.
如果您使用的是 Mac (OS X) 或任何受支持的 Linux 发行版,则必须运行:
dotnet tool install --global dotnet-aspnet-codegenerator --version 2.2.3
Run Code Online (Sandbox Code Playgroud)
此外,在 Mac 上我添加到我的.zshrc(或 bash 等价物)
export PATH=$HOME/.dotnet/tools:$PATH
Run Code Online (Sandbox Code Playgroud)
我必须确保重新启动终端。
将以下内容添加到您的project.json:
在依赖项下:
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
}
Run Code Online (Sandbox Code Playgroud)
在工具下:
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22340 次 |
| 最近记录: |