Have a look at this answer (based on work of @theyetiman). It requires mainly a modification of the project, the app.config
file belongs to. The consuming projects are left unmodified.
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
<Link>$(TargetFileName).config</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Also note, that with Visual Studio 2017 this modification is not necessary any more. If you open a solution with a project containing the above workaround, a warning similar to the following is displayed in the errors window:
The file 'app.config' could not be added to the project.
Cannot add a link to the file ...\app.config.
This file is within the project directory tree.
Add a condition comparing $(VisualStudioVersion)
to avoid this warning and keep backward compatibility:
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup Condition="'$(VisualStudioVersion)' < '15.0'">
<None Include="app.config">
<Link>$(TargetFileName).config</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>