0

I have config files: confing.yml and scenarios.yml that are in the /config/ folder in my source. I use this code to find the configurations at the expected location using relative path:

string currentAssblLoc = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
string confFileLoc = currentAssblLoc + @"\config\config.yaml";

When I compile the app, the executable is moved to the debug folder, but the config files are not.

Question: taking into account the release version of the compiled assembly and the debug mode in which developers are writing code where should I place the config files. Is there a way for these files to be moved into the appropriate folders that can be defined in the project properties and what are some recommended practices around that.

Update: I see that the contents of the config folder are included in the .csproj file

  <ItemGroup>
    <None Include="App.config" />
    <None Include="config\config.yml" />
    <None Include="config\scenarios.yml" />
    <None Include="packages.config" />
  </ItemGroup>
Mindaugas Bernatavičius
  • 3,757
  • 4
  • 31
  • 58
  • Did you try [copy to output dir](https://stackoverflow.com/questions/4596508/vs2010-how-to-include-files-in-project-to-copy-them-to-build-output-directory-a) ? though this will just copy them as is, you would need transforms to have specific files per configuration – MarkovskI Aug 02 '17 at 00:58

1 Answers1

0

I have been using SlowCheetah for many years. It can transform different config files depending on the Configuration settings. You can transform config files for development, staging and releases without having to manually change anything.

You can replace certain tags or complete sections. Config files are put into the appropriate configuration output directory defines in the properties for the configuration.

You can also use the Post Build options to copy files around after the build.

JAZ
  • 1,050
  • 6
  • 15