MSbuild Task FileUpdate to replace content in text files

I wanted to replace some strings in files using my deployment MSbuild script.

I've noticed that MSBuild Community Tasks Project has RegexReplace task.

But when I've looked in documentation 

(By the way, it will be good if Reference help will be available online, not only from download)

I've realized that the task is applicable for strings(e.g file names) not to content within a file.

Almost accidently in one of the posts i've found a reference to FileUpdate
task, that support Regex and does content replacements within a file.

The following examle (from downloaded help) search for a version number and update the revision.

 
            <FileUpdate Files="version.txt"
                Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
                ReplacementText="$1.$2.$3.123" />

Note: don't forget to insert in to your project

<

MSBuildCommunityTasksPath >.</MSBuildCommunityTasksPath>
<
Import Project="MSBuild.Community.Tasks.Targets" />
You may require to change MSBuildCommunityTasksPath if it is not in current directory.

posted @ Friday, July 03, 2009 8:45 PM

Print

Comments on this entry:

No comments posted yet.

Your comment:



 (will not be displayed)


 
 
 
 
 

Live Comment Preview:

 
«February»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
28123456
78910111213