22

When I install my custom NuGet package it works, but the output window in VS shows messages like it tried to add the files twice and they already existed. Output is further down in this post.

I have a NuGet private repository on a server here that is working to host our gallery. Installs and uninstalls are working, even though the output window shows the messages below. I am curious about the <files> tag in the spec file and if there's a different way I need to do this. I have tried multiple ways based on the documentation. My version is up to date installed from the NuGet site.

From the site: The latest version of the nuget.exe command-line tool is always available from http://nuget.org/nuget.exe

Specifying files to include in the package

The output window shows things like this on Install-Package CustomNuGet:

The item /Plugins/CustomNuGet/CSS/custom.css already exists.

The item /Plugins/CustomNuGet/Scripts/custom.js already exists.

The item /Plugins/CustomNuGet/Views/custom.cshtml already exists.

The output window shows things like this on Uninstall-Package CustomNuGet:

The item /Plugins/CustomNuGet/CSS/custom.css could not be found in your workspace.

The item /Plugins/CustomNuGet/Scripts/custom.js could not be found in your workspace.

The item /Plugins/CustomNuGet/Views/custom.cshtml could not be found in your workspace.

I have created a custom Nuget package using the command line tools. The folder looks like this:

/CustomNuGet
    CustomNuGet.nuspec
    CustomNuGet.0.1.1.nupkg
    /content
        /lib
            CustomNuGet.dll
        /Plugins
            /Views
                custom.cshtml
            /Scripts
                custom.js
            /CSS
                custom.css

The spec file was created using: nuget spec and the package nuget pack in the root CustomeNuGet folder per the documentation. Here is the spec file:

    <?xml version="1.0"?>
    <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>CustomNuGet</id>
        <version>0.1.1</version>
        <authors>CustomNuGet</authors>
        <owners>CustomNuGet</owners>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <description>CustomNuGet</description>
        <tags>CustomNuGet</tags>
        <references>
            <reference file="CustomNuGet.dll" />
        </references>
        <dependencies>
            <dependency id="WebActivatorEx" version="2.0.0" />
        </dependencies>
    </metadata>
    <files>
        <file src="content\lib\CustomNuGet.dll" target="lib"/>
        <file src="content\Plugins\**" target="content\Plugins" />
    </files>
    </package>

I didn't see any posts about this exact issue so hopefully others have had this happen and it's only a setting I missed.

Community
  • 1
  • 1
area28
  • 1,425
  • 1
  • 9
  • 11
  • Your solution is linked to TFS source control yes? – Rhumborl Jan 15 '15 at 16:36
  • Yes. Our repos are on TFS. – area28 Jan 15 '15 at 16:45
  • Have you tried opening the .nupkg file you generate on pack? It's just a zip file, so a program like 7-zip will open it (you can also use a tool like [NuGet Package Explorer](http://npe.codeplex.com/)). Either way, you can browse the package and see how everything is laid out, whether files are included twice or anything else looks amiss. – NextInLine Jan 16 '15 at 22:42
  • Yes. The structure of the package is showing correctly.Thank you. – area28 Jan 17 '15 at 15:45
  • Are those the exact errors? The messages seem to indicate that there is an additional 'CustomNuGet' folder under your Plugins folder, which doesn't match how you say the folder structure is laid out. – Tim B Apr 16 '15 at 15:39
  • Those are the exact errors. The NuSpec file has a `` tag that has a target of where to put the files. The paths are correct. Plugins in the error refers to a folder at the root of the project that it creates if not exists. It might be TFS including things in the project and not liking it when you want to remove them from source control this way. – area28 Apr 16 '15 at 16:32
  • 2
    Try to install this package into a clean new project that is not under TFS - so you cam eliminate or confirm the TFS factor here. – qbik Apr 21 '15 at 04:31
  • This does not happen on a non-TFS source controlled project. – area28 Jun 18 '15 at 16:53

1 Answers1

1

This can happen if you deleted .dll reference manually instead of using uninstall-package to remove it through console. Check packages.config file, package you're trying to install is probably still listed there. You will have to delete it from that config file and save changes. After you did that, try installing package again and it should work.

msmolcic
  • 6,407
  • 8
  • 32
  • 56