0

I have created a Nuget Package in which i install other referenced packages. I also have a folder of Images containing up to 100 image files. If I put these in the content folder they get copied over to the root of the project on which I install the nuget package.

Here is my problem. When having the content>Images>listoffiles it takes up to 30 minutes per project to copy the files to the root folder. Further more I need them in the bin/debug and bin/release folders, not the root of the project.

Is there a way to just add the images into the lib folder so that they are in the package>lib>Images folder and then copy them to the bin/debug bin/release folders of the project to which it was installed?

Kyle Hancock
  • 132
  • 8

1 Answers1

0

What you are articulating is the need for static content files that are only copied during a build action.

More information about that.

Unfortunately only PackageReference based projects support contentFiles folders, but you're using packages.config based projects by the sound of it.

Good news is you can still achieve this by using the build targets!

Start by putting your content into any random folder in your package

/mycontent/images/ListOfFiles

In the build folder, you can add a targets file that has the exact same name as the package. Ex:

build/MyPackage.targets

In that targets file you can use some MsBuild magic to make sure the files are copied.

Example:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <ItemGroup>
        <OutputFiles Include="$(MSBuildThisFileDirectory)\..\mycontent\**\*"></OutputFiles>
    </ItemGroup>
    <Target Name="MyCopyFilesToOutputDirectory" BeforeTargets="Build">
        <Copy SourceFiles="@(OutputFiles)" DestinationFolder="$(IntermediateOutputPath)" />
    </Target>
</Project>

Or something along those lines :) Please note that I haven't tested this, but it should point you to the right direction.

imps
  • 1,423
  • 16
  • 22