Jetbrains Rider IDE =>托管环境

发布于 2025-01-28 17:12:51 字数 584 浏览 2 评论 0原文

在这里输入图像描述我正在尝试使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

祁梦 2025-02-04 17:12:51

您正在混合两件事:ASP.NET与ASP.NET核心。环境变量ASPNETCORE_ENVIRONMENT由ASP.NET Core使用,而方法hostingenvironment.isdevelovermentenvironment只是旧ASP.NET的一部分。

正如您已经发现的那样,您必须设置dev_environment = 1,我看到了两个选项:

  1. 设置环境变量范围内的系统
  2. 范围内设置环境变量

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 method HostingEnvironment.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. Set environment variable system-wide
  2. Set environment variable within Rider configuration

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:
enter image description here
You have to do this for all your Run Configurations.

一个人练习一个人 2025-02-04 17:12:51

dev_environment = 1添加到Jetbrains IDE中的项目运行配置。

Add DEV_ENVIRONMENT=1 to your project run configuration in your JetBrains IDE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文