有没有办法在 NAnt 构建期间提示用户输入?我想执行需要密码的命令,但我不想将密码放入构建脚本中。
我现在正在使用脚本,但我很想听听是否有可用的预构建方法。非常感谢 sundar 的 ForegroundColor 技巧。
我不确定你使用 Project.Log 还是直接使用 Console.WriteLine() 是否重要,有 NAnt 忍者想教育我吗?
这是脚本和使用它的示例目标:
<target name="input">
<script language="C#" prefix="password" >
<code><![CDATA[
[Function("ask")]
public string AskPassword(string prompt) {
Project.Log(Level.Info, prompt);
ConsoleColor oldColor = Console.ForegroundColor;
Console.ForegroundColor = Console.BackgroundColor;
try
{
return Console.ReadLine();
}
finally
{
Console.ForegroundColor = oldColor;
}
}
]]></code>
</script>
<echo message="Password is ${password::ask('What is the password?')}"/>
</target>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)