Ask Your Question
0

How to prevent MSBuild from utilizing App.config in the .NET6 part of a multi-targeted project?

asked 2023-03-15 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-09-20 06:00:00 +0000

bukephalos gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-03-15 11:00:00 +0000

Seen: 10 times

Last updated: Sep 20 '22