What do I need to do so that the log4net.config: 1 - is not treated as a linked file
This is by design. contentFiles
are supposed to be added as a link. Copying files into the project's source directory is not supported and has been a discouraged practice for classic projects.
Check Martin`s answer here:
This is by design. NuGet packages are no longer supposed to modify the project's source but only add to its built output or build process (in addition to .NET libraries). The content folder for adding sources to the project is only continued to be supported for packages.config based projects since it would be a breaking change for existing projects, but projects using project.json or PackageReference (VS 2017) get the new behaviour.
Now, The contentFiles
section controls the msbuild items that are generated for these files into the obj\projectname.csproj.nuget.g.props
file.
2 - is copied to outbut directory by default.
You can set copyToOutput="true"
for the log4net.config
in the .nuspec file:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>xxxx</id>
<version>1.0.0</version>
<authors>Tester</authors>
<owners>Tester</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package Description</description>
<contentFiles>
<files include="any/any/Views/log4net.config" buildAction="content" flatten="true" copyToOutput="true"/>
</metadata>
<files>
<file src="contentFiles/any/any/log4net.config" target="contentFiles/any/any/log4net.config" />
</files>
You can check the document NuGet ContentFiles Demystified and this thread for more details.