I am just getting started with NuGet and trying to get my head around it. I may be trying to use NuGet for someting it isn't intended for, but I was hoping someone might give me some hints.
My issue: I am trying to create a package with different files. The files is of different type (images, text files, etc.). I want the package to work, so that the files get added to my application root, but isn't included in my visual studio project. I have tried it, but the files is always added to the project. Is there a way around this?
Thanks
There is no direct support for this today. Anything that you put in the content folder gets added to your project when the package is installed.
However, you should be able to achieve this result using an install.ps1 script, e.g.:
You can put your files in another folder (not content) in the nuget packet and add a .targets file to your nuget packet copy the files at build time.
MyProject.nuget file:
...
<files>
<file src="bin\$configuration$\$id$.pdb" target="lib\net45"/>
<file src="C:\MyResourceFolder\**" target="resources"/>
<file src="MyProject.targets" target="build"/>
</files>
</package>
MyProject.targets file:
<?xml version="1.0"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)\..\resources\**">
<Link>\Recources\%(RecursiveDir)\%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
When you build your final Application the files will be copy'ed to the build target folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With