设置过程环境变量不适用于带有MSBuild 4.0的子MSBuild任务 [英] Setting process environment variable does not work for child MSBuild tasks with MSBuild 4.0

查看:204
本文介绍了设置过程环境变量不适用于带有MSBuild 4.0的子MSBuild任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于通过VCBuild任务(除其他事项外)构建C ++项目的MSBuild(3.5)项目.该项目需要在开发人员桌面以及Continuous Integration服务器上启动.

I have a MSBuild (3.5) project that I use to (amongst other things) build C++ projects, using the VCBuild task. This project needs to be launched on developers desktops as well as on a Continuous Integration server.

为了能够为VCBuild任务选择正确的环境(例如,分支可以使用与主干不同的Windows SDK),我开发了一个自定义任务,可以在新过程中调用正确的SetEnv.cmd,检索环境变量 受此调用影响的内容,然后将其影响到当前流程(指定 调用时的过程 SetEnvironmentVariable ).

To be able to pickup the right environment for the VCBuild tasks (branches could use a different Windows SDK than the trunk, for instance), I have developed a custom task that can call the right SetEnv.cmd in a new process, retrieve the environment variables that have been impacted by this call, and then affect them to the current process (specifying Process when calling SetEnvironmentVariable ).

这听起来可能有些棘手,但它的作用就像是一种魅力.然后,我希望能够使用MSBuild 4.0启动项目(首先使用ToolsVersion ="3.5"),但它不起作用:任务启动了,似乎按预期工作,但没有环境变量 曾经受到影响.我已经使用ToolsVersion ="4.0"(无论是否带有多处理器)进行了尝试,都无济于事.

It may sound a bit tricky, but it works like a charm. Then I wanted to be able to use MSBuild 4.0 to launch the project (at first using ToolsVersion="3.5"), and it does not work : the task gets launched, seems to work as expected but no environment variable is ever impacted. I have tried it using ToolsVersion="4.0", with or without multiprocessor, to no avail.

我认为这与MSBuild现在工作方式的核心方面所做的一些更改有关:

I assume this has to do with some changes made in the core of how MSBuild now works :

  • 您能帮我找到有关此行为的解释吗?
  • 使用MSBuild 4.0实现我的目标的正确方法是什么?

推荐答案

我不知道这方面的任何变化都会导致您的失败.您可以尝试在 MSBuild扩展包,如果您收到相同的错误行为,请告诉我.

I don't know of any changes in this area that would cause your failures. Can you try the Environment variable task in the MSBuild Extension Pack and let me know if you get the same incorrect behaviour.

其用法示例为 这里

Samples for its usage are here

 

迈克


这篇关于设置过程环境变量不适用于带有MSBuild 4.0的子MSBuild任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆