当我开发一个我没有VS2015的应用程序时,我无法做到
> Hookup launchSettings.json到我的应用程序
>更改启动设置,例如托管环境,launchUrl或默认端口5000等.
解决方法
据我所知,launchSettings.json是特定于Visual Studio的.从documentation:
This file holds settings specific to each profile Visual Studio is configured to use to launch the application,including any environment variables that should be used.
您需要一种不同的方式来设置所需的选项:
绑定地址和端口
在Program.cs中引导应用程序时可以配置此项:
public static void Main(string[] args) { var host = new WebHostBuilder() .UseKestrel() .UseUrls("http://localhost:8080") // name and port to listen on .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup<Startup>() .Build(); host.Run(); }
托管环境
ASP.NET Core references a particular environment variable,
ASPNETCORE_ENVIRONMENT
to describe the environment the application is currently running in. This variable can be set to any value you like,but three values are used by convention:Development
,Staging
,andProduction
.
只需为您的平台设置适当的环境变量为“开发”,“暂存”,“生产”等.ASP.NET Core将读取值,所有IHostingEnvironment逻辑都将起作用.
在Windows中,您可以在GUI或命令行中设置环境变量:
setx ASPNETCORE_ENVIRONMENT "Development"
启动网址
在运行应用程序时,Visual Studio会自动打开浏览器,从而尝试提供帮助.如果您使用的是dotnet,则必须手动执行此操作.
我没有尝试过,但Visual Studio Code的这个插件可能会给你这个功能:Visual Studio Chrome Debugger
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。