I have created a NuGet package that contains Native Libraries in two subfolders (amd64 and x86). The NativeLibraries are supposed to be copied into subfolders of the OutputPath, which works. I used the following stackoverflow entry as a guide for creating the package: https://stackoverflow.com/a/30316946/4496150
The NuGet package folder structure looks like this:
- build
- amd64
- DLL1.dll
- DLL2.dll
- x86
- DLL1.dll
- DLL2.dll
- packagename.targets
- amd64
My targets file looks like this:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<NativeLibs Include="$(MSBuildThisFileDirectory)**\*.dll" />
<None Include="@(NativeLibs)">
<Link>%(RecursiveDir)%(FileName)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
However, additionally the files are copied flat into the Outputpath during the build step (msbuild.exe, VS 2019). Since the files in the amd64 and x86 folders are named the same, they overwrite each other.
The crucial build output looks like this:
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\amd64\DLL1.dll" to "C:\Bin\amd64\DLL1.dll".
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\amd64\DLL2.dll" to "C:\Bin\amd64\DLL2.dll".
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\x86\DLL1.dll" to "C:\Bin\x86\DLL1.dll".
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\x86\DLL2.dll" to "C:\Bin\x86\DLL2.dll".
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\amd64\DLL1.dll" to "C:\Bin\DLL1.dll".
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\amd64\DLL2.dll" to "C:\Bin\DLL2.dll".
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\x86\DLL1.dll" to "C:\Bin\DLL1.dll".
Copying file from "C:\Users\USERNAME\.nuget\packages\PACKAGENAME\1.2.3\build\x86\DLL2.dll" to "C:\Bin\DLL2.dll".
How can I prevent the NativeLibraries from being additionally copied flat to the Output folder?