nuget usage for C++. How do I copy source path directory structure?

28 Views Asked by At

I am building nuget package for c++. The build itself is performed on the server using jenkins. The output files laid out as follows:

D:/jenkins/workspace/myworkspace/build/Debug/package/lib/mylib.lib
D:/jenkins/workspace/myworkspace/build/Release/package/lib/mylib.lib
D:/jenkins/workspace/myworkspace/build/Release/package/include/subdir1/include1.h
D:/jenkins/workspace/myworkspace/build/Release/package/include/subdir2/include2.h

.nuspec looks like this:

<files>
 <file src="mylib.props" target="build\native\"/>
 <file src="build/Release/package/include/**/*" target="build\native"/>
 <file src="build/Release/package/lib/mylib.lib" target="build\native\lib\x64\Release"/>
 <file src="build/Debug/package/lib/mylib.lib" target="build\native\lib\x64\Debug"/>
</files>

After the packaging, inside package, the include folder is packaged but the layout is build/native/include/build/Release/package/include. Since I use ** to copy directory structure, nuget will copy upper part too. Is there a way to change base directory so the path will become build/native/include

1

There are 1 best solutions below

0
SparcU On

There is a bug in nuget. Forward slash (/) is not treated correctly. So the below works as expected

<files>
 <file src="mylib.props" target="build\native\"/>
 <file src="build\Release\package\include\**\*" target="build\native"/>
 <file src="build\Release\package\lib\mylib.lib" target="build\native\lib\x64\Release"/>      
 <file src="build\Debug\package\lib\mylib.lib" target="build\native\lib\x64\Debug"/>     
</files>