Ant替换任务不起作用

时间:2016-06-17 15:47:42

标签: powershell ant

我有Powershell脚本。它有第一行:

$installation_folder = @aaa@

并拥有一个带有此任务的Ant构建文件:

<target name="prepare-install-script" description="Preparation of installation script">
    <replace file="install.ps1" propertyfile="${template-properties}">
        <replacefilter token="@aaa@" value="installation.dir"/>
    </replace>
</target>

初始化所有文件。日志说:

[replace] Replacing in c:\Users\install.ps1: @aaa@ --> sdfsdf

但是在文件中没有任何改变。

它有什么用?

2 个答案:

答案 0 :(得分:0)

您必须更改编码。这将有效:

<target name="prepare-install-script" description="Preparation of installation script">
<replace file="install.ps1" token="@aaa@" value="installation.dir" encoding="UTF-16"/>

答案 1 :(得分:0)

问题在于,当您在PowerShell默认的Windows IDE中编写脚本时,它变成了像#34; binary&#34;带有一些系统信息的文件。这就是Ant不能替换的原因。 通过复制脚本修复文本编辑器并保存为ps1。

相关问题