How to Prevent Visual Studio from Deleting "Config" files when Performing "Clean Solution"

Farkler 211 Reputation points
2021-03-24T17:52:51.123+00:00

We recently converted from Visual Studio 2013 to 2019. Our application has an external application that creates the settings to write to a config file on the startup project. I won't go into the details to save space. Anyway, in Visual Studio 2013 we could perform 'clean solution' and the *.config file would not be deleted. In VS 2019 performing a "clean" on the solution deletes the config file, including the config file that has settings contained from the external application. Running the external application to repopulate the config file after every clean is not productive for our development environment.

Does anyone know what can be done in VS 2019 to prevent the config files from being deleted on 'clean solution'? Thanks

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,568 questions
0 comments No comments
{count} votes

Accepted answer
  1. Farkler 211 Reputation points
    2021-03-26T12:56:20.987+00:00

    Work around to prevent this issue. In the app.config file added below line of code.

    <appSettings file="[unique file name].exe.Config"></appSettings>

    The key is a file name that does not match any project name in the solution.

    Performing a clean on the solution no longer deletes the file i want to retain between solution clean process.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Karen Payne MVP 35,036 Reputation points
    2021-03-24T23:01:33.997+00:00

    Currently there are no properties or setting to prevent this behavior. You can report this as a problem or provide feed back. Do this via clicking the feedback button, top right corner of Visual Studio.

    81287-f1.png