在Visual Studio Code中设置.NET Core MVC Web应用

谜语

我一直在尝试使用Visual Studio Code,并按照入门指南努力使用.NET Core MVC Web应用程序启动和运行。

我安装了Visual Studio Code,.NET Core SDK和C#代码扩展,并使用dotnet new mvc命令创建了项目。我确保按照提示添加构建和调试所需的缺少资产。

至此,我阅读的教程说您可以使用F5运行该应用程序,并且它们会在浏览器中显示一个模板页面。但是,当我尝试运行它时,它将带我到“环境”下拉列表。如果选择.NET Core,它将带我到launch.json文件。

我是Visual Studio代码的新手,所以不确定如何最好地解决此问题,或者不确定是否遗漏或误解了某些内容。

rbonestell

为了使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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在.NET Core和Visual Studio Code中调试xUnit测试

Visual Studio 2015 Web应用程序.NET Core与.NET Framework

如何在Visual Studio Community 2013中创建ASP.NET MVC 5 Web应用程序?

我们如何在Visual Studio Code中调试ASP.NET MVC Web应用程序?

(.NET Core 1.0 && net46)Visual Studio中的Views类中的MVC错误

在没有Visual Studio 2015的情况下配置.NET Core Web应用程序启动设置

Visual Studio 15上不存在ASP.NET Core Web应用程序模板

在Visual Studio 2017 RC中调试ASP.Net Core 1.1 MVC源代码

在Visual Studio 2017中设置.NET Core MVC应用程序以使用完整的IIS(不是IIS Express)

Visual Studio 15.2上的ASP.NET Core Web应用HTTP错误502.5进程失败

如何以与Visual Studio使用SSL相同的方式在VS Code中本地运行.Net Core 2.0应用

是否可以在Mac的Visual Studio中开发ASP.NET MVC应用程序?

无法在Visual Studio 2017中建立「Asp.Net Core Web应用程式」

如何在Visual Studio 2012中更改ASP.NET MVC Web应用程序的SSL端口号

Visual Studio 2015中的ASP.NET Core MVC 2.0

创建F#ASP.NET Core Web应用程序需要哪种Visual Studio 2017选项?

Visual Studio 2017中的空白ASP .NET Core Web应用程序项目

Visual Studio Code调试默认的ASP.NET Core MVC WebApp:不起作用

新的ASP.Net Core Web应用程序屏幕中没有ASP.Net Core模板Visual Studio 2017

将-ASP.NET MVC 5 Web应用程序(Visual Studio 2017)转换为.exe设置文件

Microsoft.EntityFrameworkCore未安装并挂在Web API .NET Core应用中-Visual Studio 2019

无法在Visual Studio(Mac)上使用.NET Core 3.1创建Web应用程序

是否可以在Visual Studio中连接现有的本地数据库并使用ASP.NET mvc Core在Web上生成数据?

在Visual Studio中创建.NET Core模板

更改“applicationUrl”后,ASP .Net Core MVC 路由在 Visual Studio 2017 中不起作用

如何在不使用 Visual Studio Code 中的 git 的情况下将我的 ASP.Net Core Angular Web 应用程序发布到 Azure

在 ASP.NET Core 3 MVC Web 应用程序中设置路由

在 Visual Studio Code 中的 asp.net core mvc 中实现 jquery 插件数据表

Visual Studio 2017“ASP.NET Core Web 应用程序(.NET Core)”模板丢失