在南特构建脚本的密码处理 [英] Dealing with passwords in NAnt build script
本文介绍了在南特构建脚本的密码处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在一个NAnt构建以提示用户输入?我想执行的命令,需要一个密码,但是我不想把密码进入构建脚本。
Is there a way to prompt the user for input during a NAnt build? I want to execute a command that takes a password, but I don't want to put the password into the build script.
推荐答案
我使用的脚本,但我很想听听是否有已有一个prebuilt方法。非常感谢孙大信为ForegroundColor把戏。
I'm using a script for now, but I'd love to hear if there's a prebuilt method already available. Many thanks to sundar for the ForegroundColor trick.
我不知道,如果它的事项是否使用Project.Log,或者直接Console.WriteLine(),任楠忍者想要教育我?
I'm not sure if it matters whether you use Project.Log or go direct to Console.WriteLine(), any NAnt ninjas want to educate me?
下面是使用它的脚本和一个示例目标:
Here's the script and a sample target that uses it:
<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>
这篇关于在南特构建脚本的密码处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文