Share Static Content with NuGet Packages

One option for sharing static content such as scripts across projects until Universal Packages are more mature is to use NuGet packages.

To create the NuGet package, we specify the folders which we wish to include within the package as content files within a .nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="">
  <metadata minClientVersion="3.3.0">
    <description>My package.</description>
      <files include="scripts/**/*.ps*1" buildAction="None" />
    <file src="**/*.ps*1" target="content" />
    <file src="**/*.ps*1" target="contentFiles/any/any" />

Here, we are creating a package of any PowerShell scripts under the local scripts folder.

Once the package is built and published, we can reference the package as normal within a Visual Studio project.

For projects that don’t use Visual Studio project files, you can also manually create a packages.config file to reference your NuGet package:

<?xml version="1.0" encoding="utf-8"?>
  <package id="MyPackage" version="0.1.0" />  

You can use the NuGet cli to do a restore outside the context of Visual Studio:

nuget restore packages.config -PackagesDirectory ./packages

For packages.config based restores, the contents of the NuGet package will be available in: