从Mac上的命令行运行ASP.NET 5应用程序时是否使用launchSettings.json?

编程入门 行业动态 更新时间:2024-10-28 12:27:56
本文介绍了从Mac上的命令行运行ASP.NET 5应用程序时是否使用launchSettings.json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Mac上的Visual Studio代码开发ASP.NET 5 Web API应用程序.我手动修改了Properties/launchSettings.json文件,以使用ASPNET_ENV环境变量将所有配置文件的环境设置为Staging:

但是,当我在Mac终端中运行dnx web以启动应用程序时,我仍然得到Production环境:

如果在Mac上使用Visual Studio Code,可以使用launchSettings.json指定环境变量(以及环境类型)吗?还是特定于完整的Visual Studio?

ASP.NET 5文档launchSettings.json可以建议用于注入环境变量.但是,此SO讨论建议通过命令传递它们./p>

解决方案

LaunchSettings.json严格来说是VS概念.在其他情况下,您必须将环境变量配置为以下命令:

要运行标准命令行,请使用:

set ASPNET_ENV=Development dnx web

对于Powershell,请使用:

$env:ASPNET_ENV='Development' dnx web

更短版本: dnx web ASPNET_ENV=Development

I am developing an ASP.NET 5 Web API app using Visual Studio code on Mac. I manually modified my Properties/launchSettings.json file to set environment to Staging for all profiles using ASPNET_ENV environment variable:

However, when I run dnx web in Mac terminal to start the app, I still get Production environment:

Can I use launchSettings.json to specify environment variables (and, thus, environment types) if I use Visual Studio Code on Mac? Or is it specific to full Visual Studio?

ASP.NET 5 docs suggest that launchSettings.json can be used to inject environment variables. However, this SO discussion suggests passing them through commands.

解决方案

LaunchSettings.json is strictly a VS concept. In other cases, you will have to configure environment variables as commands below:

For standard command line run, use:

set ASPNET_ENV=Development dnx web

For powershell, use:

$env:ASPNET_ENV='Development' dnx web

Shorter version: dnx web ASPNET_ENV=Development

更多推荐

从Mac上的命令行运行ASP.NET 5应用程序时是否使用launchSettings.json?

本文发布于:2023-11-09 09:06:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1571981.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令行   应用程序   ASP   Mac   json

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!