Forum Visual Studio

How to specify an additional location for asset files in a NuGet built using VS2017?

JohnHardmanJohnHardman GBUniversity admin

I have a VS2017 solution that when I do Build/Publish creates a NuGet that I use in Xamarin.Forms applications for Android, iOS and UWP. There is no explicit NuGet specification file - it seems that VS2017 knows how to create the basic NuGet without further instruction.

When installed, the NuGet creates the following folder structure:

content\UWP\Assets
+file1.svg
+file2.svg
+file3.svg
contentFiles\any\monoandroid81\UWP\Assets
+file1.svg
+file2.svg
+file3.svg
contentFiles\any\netstandard2.0\UWP\Assets
+file1.svg
+file2.svg
+file3.svg
contentFiles\any\uap10.0.17134\UWP\Assets
+file1.svg
+file2.svg
+file3.svg
contentFiles\any\xamarinios10\UWP\Assets
+file1.svg
+file2.svg
+file3.svg
lib\monoandroid81
+Plugin.dll
lib\netstandard2.0
+Plugin.dll
lib\uap10.0.17134
+Plugin.dll
+Plugin.pri
lib\xamarinios10
+Plugin.dll
.nupkg.metadata
xam.plugin.0.0.42.1.nupkg
xam.plugin.0.0.42.1.nupkg.sha512

However, to get the three .svg files where I need them to be for the library to use them, I additionally need the following created when the NuGet is installed:

lib\uap10.0.17134\Plugin\UWP\Assets
+file1.svg
+file2.svg
+file3.svg

Is the way to do this to create a Post-Build event in the csproj of the library, with that doing an additional mkdir and xcopy? I am not sure where the NuGet packaging stuff picks up the files. Do I need to put them somewhere under $(TargetDir) or under $(SolutionDir)? Any input on what the appropriate script would be would be much appreciated.

Answers

Sign In or Register to comment.