剛剛遇到類似的任務。我用這種方式解決了它,希望它有一點幫助。
<script language="C#"><code><![CDATA[
public static void ScriptMain(Project project)
{
project.Properties["command-line-targets"] = string.Empty;
StringBuilder sb = new StringBuilder();
string[] args = Environment.GetCommandLineArgs();
for (int i = 1; i < args.Length; ++i)
{ string arg = args[i];
if (! arg.StartsWith("-"))
{
project.Log(Level.Info, " Command line target: " + arg);
sb.Append(" ").Append(arg);
}
}
if (sb.Length >= 1)
{
project.Properties["command-line-targets"] = sb.ToString(1, sb.Length - 1);
}
}
]]></code></script>
<echo message="Command line targets: ${command-line-targets}" />
但是,此代碼不會顯示默認目標。
你需要什麼? – AlG 2012-03-20 14:42:32