You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
litecoin/build_msvc/msbuild/tasks/replaceinfile.targets

35 lines
1.0 KiB

<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask
TaskName="ReplaceInFile"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<FilePath Required="true" />
<Replace Required="true" />
<By Required="false" />
<ToFullPath Required="false" />
</ParameterGroup>
<Task>
<Using Namespace="System"/>
<Using Namespace="System.IO"/>
<Code Type="Fragment" Language="cs">
<![CDATA[
if(File.Exists(FilePath) == false) {
Log.LogError("replaceinfile task could not locate " + FilePath + ".");
}
else {
var data = File.ReadAllText(FilePath);
var by = By;
if (ToFullPath == "true")
{
by = Path.GetFullPath(by);
}
data = data.Replace(Replace, by);
Log.LogMessage("Replace '" + Replace + "' by '" + by + "' in " + FilePath);
File.WriteAllText(FilePath, data, new System.Text.UTF8Encoding(false));
}
]]>
</Code>
</Task>
</UsingTask>
</Project>