I've created a nuget package targeting a .NET Core project. The idea here is to add xxx.dll as a reference with copy local as false and copy all DLLs in a subfolder in the output path and all resources files in subfolder\resources
The nuspec targeting NET Core 3 is working fine.
Now I want to do the same to target NET Framework 4.6.1.
But the content files are not added to the project. This is my nuspec file :
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>xxx.Win.x64.ForIPS11</id>
<version>15.5.3.4</version>
<title>xxx toolkit</title>
<authors>xxx Team</authors>
<owners>xxx</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>xxx 15.5.3.4 x64 Windows to .NETFramework 4.6.1 for IPS 11</description>
<releaseNotes></releaseNotes>
<copyright>2020</copyright>
<tags></tags>
<dependencies>
<group targetFramework=".NETFramework4.6.1" />
</dependencies>
<contentFiles>
<files include="**\subfolder\resources\*.*" buildAction="Content" copyToOutput="true" />
<files include="**\subfolder\*.dll" buildAction="Content" copyToOutput="true" />
</contentFiles>
</metadata>
<files>
<file src="bin\xxx.dll" target="lib\net461" />
<file src="resources\*.*" target="contentFiles\any\any\subfolder\resources" />
<file src="bin\*.dll" target="contentFiles\any\any\subfolder" />
</files>
</package>
Did I use an incompatible tag for .NET Framework target? Any idea how to get this done?
EDIT : I use packages.config file in VS2017 in the target project
contentFiles is not compatible with packages.config way
This is an alternative :
Nuspec file :
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>xxx.Win.x64.ForIPS11</id>
<version>0.0.0</version>
<title>xxx toolkit</title>
<authors>xxx Team</authors>
<owners>xxx</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>xxx 0.0.0 x64 Windows to .NETFramework 4.6.1</description>
<releaseNotes></releaseNotes>
<copyright>2020</copyright>
<dependencies>
<group targetFramework=".NETFramework4.6.1" />
</dependencies>
<tags></tags>
</metadata>
<files>
<file src="bin\xxx.dll" target="lib\net461" />
<file src="resources\*.*" target="build\subfolder\resources" />
<file src="bin\*.dll" target="build\subfolder" />
<file src="xxx.Win.x64.targets" target="build" />
<file src="install.ps1" target="tools" />
</files>
</package>
xxx.Win.x64.targets to copy subfolder to output
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)**\*.*" />
<None Include="@(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
and install.ps1 to mark copy local false to the reference
param($installPath, $toolsPath, $package, $project)
$asms = $package.AssemblyReferences | %{$_.Name}
foreach ($reference in $project.Object.References)
{
if ($asms -contains $reference.Name + ".dll")
{
$reference.CopyLocal = $false;
}
}