App config contains setting for physical path that I need to change....

Answered

Hi,

Within the solution that contains all our unit tests we have some text files. These text files are checked based on some results generated by our unit tests.

In order to load the files we have an app.config with:

Snippet

 <appSettings>
    <add key="BaseTestDataPath" value="D:\MyPath\MySolution\" />
 </appSettings>

So on each build run I want to:

  • Change the BaseTestsDataPath to the specific work path of the agent eg. C:\TeamCity\buildAgent\work\1ca1a73fe3dadf57\MySolution\

I know the physical layout within the agent work folder so what I need to know is:

  • How to change the app.config file prior to the Nunit run against the solution in my build steps using the current work folder for that agent

 

 

3 comments

Hi Donovan,

Have you tried the File Content Replacer build feature? It processes text files by performing regular expression replacements before a build. After the build, it restores the file content to the original state.

0

Hi Alina,

Thanks for that. Added to that option the following other solutions also exist http://stackoverflow.com/a/37204969/223742 

0

I have used the File Content Replacer but I am finding it somewhat brittle if, say, a subtle change is made to the source xml fragment automagically e.g. changing this <add key="someKey" value="someValue"/> to this: <add key="someKey" value="someValue" />.

e.g. 

Replace: <add key="someKey" value="Existing value with no trailing space"/>
With this: <add key="someKey" value="[Always fails]>

Is there an alternative to the File Content Replacer? Something like update value where key name matches?

Currently running TeamCity Professional v10.0.5 (build 42677)

 

0

Please sign in to leave a comment.