Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are a few ways to prevent MSBuild from utilizing App.config in the .NET6 part of a multi-targeted project:

  1. Rename App.config file: Renaming App.config to something else, like App.config.disabled, will prevent MSBuild from using it.

  2. Ignore App.config: Add App.config to .gitignore or any other version control tool you use to ignore it. This will prevent MSBuild from using it during the build process.

  3. Exclude App.config from the build: In the .csproj file, exclude App.config from the build process by adding the following line:

<None Update="App.config">
  <ExcludeFromBuild>true</ExcludeFromBuild>
</None>

This will prevent MSBuild from using it during the build process.

  1. Use MSBuild properties: Finally, you can use MSBuild properties to disable the use of App.config in the build process. Add the following line to your .csproj file:
<PropertyGroup>
  <UseAppConfig>false</UseAppConfig>
</PropertyGroup>

This will set the UseAppConfig property to false, preventing MSBuild from using App.config during the build process.

Note that if you need to use the App.config file in the .NET6 part of your project, you should not use any of the above methods. Instead, ensure your App.config file is correctly configured for the .NET6 part of your project.