0

I am trying to create a Nuget package using NuGet.exe 1.2.20311.3, and the following specification:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata>
    <id>SharedWebsitesMvc</id>
    <version>1.0.16</version>
<authors>Ted</authors>
<owners>Ted</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Shared Websites Mvc Library</description>
    <frameworkAssemblies>
        <frameworkAssembly assemblyName="mscorlib" targetFramework=".NETFramework4.6" />
        <frameworkAssembly assemblyName="System" targetFramework=".NETFramework4.6" />
        <frameworkAssembly assemblyName="System.Core" targetFramework=".NETFramework4.6" />
        <frameworkAssembly assemblyName="Microsoft.CSharp" targetFramework=".NETFramework4.6" />
    </frameworkAssemblies>
</metadata>
<files>
    <file src="D:\Projects\Websites\SharedWebsitesMvc.dll" target="lib\net46\SharedWebsitesMvc.dll" />
    <file src="D:\Projects\Websites\SharedWebsitesMvc.xml" target="lib\net46\SharedWebsitesMvc.xml" />
    <file src="D:\Projects\Websites\Scripts\backtalk.js" target="js\backtalk.js" />
    <file src="D:\Projects\Websites\Scripts\shared.js" target="js\shared.js" />
    <file src="D:\Projects\Websites\SharedWebsitesMvcInstall.ps1" target="tools\Install.ps1" />
</files>

Nuget generates a package, and package explorer shows the following:

js
    backtalk.js
    shared.js
lib
    net46
         SharedWebsitesMvc.dll
         SharedWebsitesMvc.xml
tools
     Install.ps1

The Install.ps1 looks like this:

param($installPath, $toolsPath, $package, $project)
Write-Host "hello from install.ps1"

When I install this package into an MVC project, the script files are not copied and no output is displayed from the script in the package console. I am using Visual Studio 2016.

What is wrong with my NuGet specification?

Sasha Palmer
  • 153
  • 1
  • 9

1 Answers1

0

The JavaScript files need to have a target that starts with Content:

<file src="D:\Projects\Websites\Scripts\backtalk.js" target="Content\js\backtalk.js" />
<file src="D:\Projects\Websites\Scripts\shared.js" target="Content\js\shared.js" />

The above does not support project's that use a project.json file. For those you need to use a ContentFiles section in your .nuspec file:

<contentFiles>
    <files include="D:\Projects\Websites\Scripts\backtalk.js"   buildAction="None" />
</contentFiles>

The .nuspec file looks OK for the install.ps1 PowerShell script for projects that use a packages.config file. Note that install.ps1 is not supported in projects that use project.json files.

Matt Ward
  • 47,057
  • 5
  • 93
  • 94
  • Thanks for the help. I made the changes but the content files were not copied. Just found out this is not working yet. https://github.com/aspnet/Home/issues/651 – Sasha Palmer May 03 '16 at 17:26