Reputation: 6973
I have a config file which has an old stylee format (no xml)
dbpath=C:\Program Files\Mongodb\Data\Db
journal=true
smallfiles=true
Depending on the system I am releasing too I want to update and change the values after the =
Is this possible with MSbuild? Can you show me how?
I know how to do this using xml poke for xml config files.
Upvotes: 2
Views: 244
Reputation: 6681
You could set up a template system and use the detokenise from the msbuild extension pack. See the Documentation here:http://www.msbuildextensionpack.com/help/4.0.6.0/Index.html
That would mean you wouldn't have to write custom targets like above all the time
So youd have:
<ItemGroup>
<Transforms Include="$(ReleasePath)\Yourtemplates\**"/>
</ItemGroup>
<MSBuild.ExtensionPack.FileSystem.Detokenise
TaskAction="Detokenise"
TargetFiles="%(Transforms.FullPath)"/>
Upvotes: 1
Reputation: 63299
Write your own MSBuild task,
http://msdn.microsoft.com/en-us/library/t9883dzc(v=VS.90).aspx
And then reference it in your MSBuild scripts.
Upvotes: 1
Reputation: 6973
Nothing like asking a question to help you answer it!
I am going to do this
<Target Name="UpdateConfig">
<CreateProperty Value="..\config.cfg">
<Output TaskParameter="Value" PropertyName="path" />
</CreateProperty>
<Message Text="LogFilePath=$(LogFilePath)"/>
<FileUpdate Files="$(path)"
Regex="logpath=.*"
ReplacementText="logpath=$(LogFilePath)" />
</Target>
It is not what I would call elegant but I don't find much about msbuild that is!
Got a better suggestion?
Upvotes: 1