WhiteleyJ
WhiteleyJ

Reputation: 1701

How to force app.config to become exe.config

This is probably a bug, but I have 2 F# projects in my solution. One is a console app, the other is a test app (expecto test so technically also console). There are also 3 other C# projects in the solution.

When ever I build my solution the app.config in the startup project is not copied to the foo.exe.config. Instead a default F# config file is created and placed there.

The file that is being generated looks like this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

None of the application configs in my solution look even remotely like that. I've checked that my app.configs are set to content mode. Also this is just a problem with the main application; the test app copies app.config into it's bin/debug just fine.

I've resorted to opening bin and dragging and dropping the correct exe.config into the directory every time before I want to run the program. I have no idea where to even begin to look to figure out what is probably not configured properly.

Upvotes: 4

Views: 3352

Answers (1)

scrwtp
scrwtp

Reputation: 13577

Why do you think it's a bug? Thousands of app.configs get copied every second - you'd assume that's rather well tested. There's probably something wrong with how your project is set up. You might want to look into the project file (hint: it's a regular xml file that you can read).

If you're building your project through VS, I'd suggest you bump up MSBuild verbosity first (Tools -> Options -> Projects and Solutions -> Build and Run tab).

Once you've done that, clean and rebuild your project. You should be able to find output from the task that copies the app.config file in the Build Output window when you search for CopyAppConfigFile. This should tell you what, if anything, really gets copied - and from where.

In a same way you can find if any other task that is part of your build process tries overwriting the file for whatever reason - as long as it produces proper log output.

Upvotes: 3

Related Questions