Jetbrains Rider IDE =>托管环境
在这里输入图像描述我正在尝试使用My .Net从Visual Studio 2022转移到Jetbrains Rider全栈项目。
如果它给任何人都有线索,我正在将WebPack用于前端(我还像VS2002中的WebPack命令一样)。
发生的问题是hostingenvironment.isdevelopentenvironment
始终返回false。
我尝试使用aspnetcore_environment = development
命令从终端设置它,并且在我项目的调试模式的配置设置中,没有运气。我找不到解决这个问题的任何解决方案。
//开发或产品的不同脚本
string scriptFileName = HostingEnvironment.IsDevelopmentEnvironment ? "/dist/app.entry.js" : "/dist/app.entry.min.js";
enter image description hereI am trying to move from Visual Studio 2022 to JetBrains rider with my .NET full-stack project.
I am using Webpack for my front-end side if it gives anyone a clue (I also run the Webpack command like in my vs2002).
The problem which occurs is the HostingEnvironment.IsDevelopmentEnvironment
always returns false.
I tried to set it from the terminal with the ASPNETCORE_ENVIRONMENT=Development
command and in the configuration setting of debug mode of my project with no luck. I can't find any solution to this problem.
// different script for dev or prod
string scriptFileName = HostingEnvironment.IsDevelopmentEnvironment ? "/dist/app.entry.js" : "/dist/app.entry.min.js";
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在混合两件事:ASP.NET与ASP.NET核心。环境变量
ASPNETCORE_ENVIRONMENT
由ASP.NET Core使用,而方法hostingenvironment.isdevelovermentenvironment
只是旧ASP.NET的一部分。正如您已经发现的那样,您必须设置
dev_environment = 1
,我看到了两个选项:1. System wide in system wide
这意味着所有消费者(您的应用程序) ,集成测试等。)使用相同的值,即所有应用都处于开发模式。这取决于您的需求,无论是否可以接受。
假设您在Windows上工作,则可以通过GUI设置环境变量(请参见此处)或CLI(请参见
setx
命令)。请记住,环境变量在应用程序启动时被拾取。因此,更改变量后,您必须重新启动骑手。
2。骑手
打开运行配置并像这样配置:

您必须为所有运行配置执行此操作。
You're mixing up two things: ASP.NET vs. ASP.NET Core. The environment variable
ASPNETCORE_ENVIRONMENT
is used by ASP.NET Core, whereas the methodHostingEnvironment.IsDevelopmentEnvironment
is only part of old ASP.NET.As you already discovered, you have to set
DEV_ENVIRONMENT=1
and I see two options:1. System-wide
This implies that all consumers (your app, integration tests, etc.) use the same value, i. e. all apps are in development mode. It depends on your needs whether this is acceptable or not.
Assuming that you're working on Windows, you can either set the environment variable via GUI (see here) or CLI (see
setx
command).Keep in mind that environment variables are picked up on application startup. So you have to restart Rider after changing the variable.
2. Rider
Open the Run Configurations and configure it like this:

You have to do this for all your Run Configurations.
将
dev_environment = 1
添加到Jetbrains IDE中的项目运行配置。Add
DEV_ENVIRONMENT=1
to your project run configuration in your JetBrains IDE.