I want to replace a string such "how r u" in file test.xml with a string "i am fine" in another file xy.xml.using regular expression in ms build.
ie i have to read string from one file(xy.xml) and replace it in another file test.xml. so please provide necessary steps to solve this issue with example
EDIT: This answer is obsolete. Use solution below...
Use ReadLinesFromFile task to get replacement string from the xy.xml file. Check this
Then use value from xy.xml as a replacement string for FileUpdate task. Check this
And put it all together ;)
This is no longer required... you can now inject C# into the project/build file...
Define a custom task and parameters as follows:
Then simply call it like any other MSBuild task
The above example replaces "$version$" with "1.0.0.2" in the "File.exe.config" located in the output directory.
I ran the both replacements against same file that sits on a Unix drive and used the unc path to it \server\path...:
and the cs custom action above does not add the bom; however the FileUpdate did:
Thanks csharptest.net - I was doing doing exec's with perl subtitute commands for unix builds.
You can use the task FileUpdate from MSBuild Community Tasks as explained in the article http://geekswithblogs.net/mnf/archive/2009/07/03/msbuild-task-to-replace-content-in-text-files.aspx