Detokenising multiple files using msbuild – property not found error – Education Career Blog

I have the following piece of code to replace all tokens in a given set of files:
(I’m using the msbuild extensions detokenise task).

 <Project DefaultTargets="Build" xmlns="">
        <UsingTask TaskName="MSBuild.ExtensionPack.FileSystem.Detokenise" AssemblyFile="Extensions/MSBuild.ExtensionPack.dll"/>

            <someValueToReplace>New Value</someValueToReplace>

            <TextFiles Include="test1.txt"/>
            <TextFiles Include="test2.txt"/>

        <Target Name="Build">
            <Detokenise TaskAction="Detokenise" TextEncoding="ASCII" TargetFiles="@(TextFiles)"/>


Unfortunately I get the following error:
(I don’t get this error if only one item exist in the ItemGroup).
(Note that I don’t want to explicitly inject the tokens that I want replaced).

“C:\Users\v\Desktop\msbuildSample\detokenise.xml” (default target) (1) ->
(Build target) ->
C:\Users\v\Desktop\msbuildSample\detokenise.xml(10,3): error : Property not found: toReplace
C:\Users\v\Desktop\msbuildSample\detokenise.xml(10,3): error : ArgumentException: Review error log\r
C:\Users\v\Desktop\msbuildSample\detokenise.xml(10,3): error :


My mistake .. I thought it was a bug in msbuild .. actually the issue was exactly what the error message indicated — I was trying to replace a variable called toReplace — but it wasn’t defined.

Leave a Comment