我一直在尝试使用Visual Studio Code,并按照入门指南努力使用.NET Core MVC Web应用程序启动和运行。
我安装了Visual Studio Code,.NET Core SDK和C#代码扩展,并使用dotnet new mvc命令创建了项目。我确保按照提示添加构建和调试所需的缺少资产。
至此,我阅读的教程说您可以使用F5运行该应用程序,并且它们会在浏览器中显示一个模板页面。但是,当我尝试运行它时,它将带我到“环境”下拉列表。如果选择.NET Core,它将带我到launch.json文件。
我是Visual Studio代码的新手,所以不确定如何最好地解决此问题,或者不确定是否遗漏或误解了某些内容。
为了使Visual Studio Code运行和调试项目,必须为每个项目创建启动配置。(请参阅:https : //code.visualstudio.com/docs/editor/debugging#_launch-configurations)
从“调试”菜单中选择“添加配置...”,然后为环境选择“ .NET Core”。
.NET Core MVC项目的启动配置(launch.json)如下所示:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (web)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/Your.Application.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}"
}]
}
然后,您可以从Visual Studio Code运行和调试.NET Core MVC Web应用程序!
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句