如何在MSBuild中的Exec命令中转义引号 [英] How to escape quote marks in Exec Command in MSBuild

查看:109
本文介绍了如何在MSBuild中的Exec命令中转义引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个MSBuild脚本,该脚本将网络驱动器映射到脚本中的驱动器号,但是不幸的是,目标文件夹的路径包含嵌入式空间.嵌入的空间会导致映射失败,并且我不知道是否有可能在路径周围转义引号.我尝试过使用双引号,但是MSBuild不喜欢它(要么Windows XP不喜欢它).有人知道如何编码这种野兽,以便地图起作用吗?

I'm trying to build an MSBuild script that maps a network drive to a drive letter in the script, but unfortunately the path to the target folder includes an embedded space. The embedded space causes the mapping to fail, and I don't know if it is possible to escape quotes around the path. I've tried double quote marks, but MSBuild doesn't like it (either that or Windows XP doesn't like it). Anyone know how to code this beast so the map works?

<Exec Command="net use x: \\ofmapoly703\c$\program files\ar\iap /user:$(UserID) $(Password)"
WorkingDirectory="c:\"
ContinueOnError="false"
/>

当然,嵌入式空间出现在程序文件"中.

The embedded space of course occurs in "program files".

推荐答案

使用 &quot; 编码您希望netCommand属性值内看到的双引号:

Use &quot; to encode the double quotes that you want net to see inside the Command attribute value :

<Exec Command="net use x: &quot;\\ofmapoly703\c$\program files\ar\iap&quot; /user:$(UserID) $(Password)" 
WorkingDirectory="c:\" 
ContinueOnError="false" 
/> 

这篇关于如何在MSBuild中的Exec命令中转义引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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