发射后在C#中重载环境变量环境变量

2023-09-03 21:14:24 作者:〆◆|▍痛丶不明不白

我们收到的使用环境变量所有的地方一个新的code基地。他们指出,像项目的根,资产,不同的工具,等等不是最理想的情况,但它的工作原理。然而,当谈到时间去尝试和运行我们的自动化构建成为一个巨大的痛苦。

We received a new code base that uses environment variables all over the place. They point to things like the project root, assets, different tools, etc. Not the most ideal situation but it works. However, when it comes time to try and run our automated build it becomes a giant pain.

的Windows似乎实例时创建一个过程,不会再次刷新这些值的环境变量。我们希望能有我们的自动化构建系统通过一个项目列表运行和建设的每一个顺序。这需要调用一个项目切换而改变这些值。当这样做但是变化不会反映在当前正在运行的生成过程。

Windows seems to instance the environment variables when a process is created and does not refresh those values again. We would like to be able to have our Automated Build System run through a list of projects and build each one sequentially. This requires calling a project switcher which changes those values. When this is done however the changes are not reflected in the currently running build process.

有谁知道任何C的#命令/功能/等,可用于强制环境变量调用项目切换后重新装入已取得?

Does anyone know of any C# commands/functions/etc that can be used to force the environment variables to reload after the call to project switcher has been made?

推荐答案

有的System.Environment.GetEnvironmentVariable和System.Environment.GetEnvironmentVariable该检索:

...一个环境变量从当前进​​程的价值或从Windows操作系统中的注册表项为当前用户或本地计算机的。

... the value of an environment variable from the current process or from the Windows operating system registry key for the current user or local machine.

如果您更改影响指定的注册表中的区域,这可能会为你工作。

If your changes affect the registry in the areas specified, this might work for you.

 
精彩推荐
图片推荐