I'm working in a legacy project (Windows Forms Application), with target framework .NET 2.0. The goal is to build a single .exe
file that does not depend in any configuration file (in particular that does not depend on the .exe.config
because the application doesn't need anything from this configuration file).
The characteristics of the project:
Application:
Targe framework: .NET Framework 2.0
Output type: Windows Application
Auto-generate binding redirecs: Not enabled
Build:
Platform target: Any CPU
Visual Studio Community 2019, version 16.1.3
The solution has a app.config
file that I've tried to remove but for some reason It seems that remains in the project. When I say seems to remains in the project is because I follow this steps:
- In the Solution Explorer, right-click on the
App.config
, and then click on Exclude From Project. - Rebuild the project, and still the
.exe.config
in generated. - Again in the Solution Explorer > Add > New Item, and when I try to add an Application Configuration File with the name
App.config
VS show this message: A file with the name 'App.config' already exists. Do you want to replace it?.
(I've also tried with the right-click on the App.config
, and then click Delete option)
This seems to indicate that the configuration file is not effectively removed from the project, and therefore the .exe.config
is still generated.
Also, I've checked this post, and tried changing the files properties (Build Action, Copy to Output Directory, etc) but the .exe.config
file remains in the build.
Finally, I've tried (probably more as a desperate attempt) with uncheck the Auto-generate binding redirects which prevents the generation of the .exe.config
but the .exe
is not running properly.
Just as an additional information, the content of the .exe.config
is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Company.Afis.ImageContainer" publicKeyToken="97cac07b8409e999" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.5.0.1827" newVersion="2.5.0.1827" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Other post that I've checked:
- How to make work 'do not copy' app.config to output directory?
- appname.exe.config not created on windows application
- Release build without config file
- How to not copy app.config file to output directory
If any other information is needed, please let me know to update it.