开发者

MSBuild not recognizing computer name in response file

开发者 https://www.devze.com 2022-12-08 04:41 出处:网络
We have a standard MSBuild project file that is used for our different开发者_JS百科 deployment stages (pre-stage, stage, live, etc). Since each deployment stage is performed on a different server we i

We have a standard MSBuild project file that is used for our different开发者_JS百科 deployment stages (pre-stage, stage, live, etc). Since each deployment stage is performed on a different server we introduced a server parameter called $SourceDatabaseServer and used this extensively in each of the targets inside the project file. Note: This database server name could be different from the server name on which the build is run.

To assist us with the customization of this parameter, we created a response file for each deployment stage and subsequently defined a value for this parameter in the response file, e.g. /p:SourceDatabaseServer=SRC_DB_NAME.

This worked fine, until we created a new deployment stage in which this value had to be the current computer name. So we thought by using the $(COMPUTERNAME) reserved property in the response file (/p:SourceDatabaseServer=$(COMPUTERNAME)), this would do the trick, but it seems like this value is interpreted literally by MSBuild, and we consequently get an error that server $(ComputerName) could not be found.

Interestingly, when the $(COMPUTERNAME) property is used directly in the proj file it works, but as stated above, we do not necessarily want to use the computer name in all the cases.

Is there a way to still use the $(COMPUTERNAME) property in the response file and get MSBuild to interpret this correctly?


What if you use %COMPUTERNAME%?

$(VAR) is the syntax for variable expansion when you're "inside" the MSBuild system, but coming from the outside, I believe you'd have to use the shell environment variable expansion syntax, %VAR%.

0

精彩评论

暂无评论...
验证码 换一张
取 消