12

I am using NUGET Pack in teamcity to build a package. But it is creating the following error. I am using nuget teamcity version 2.2.1.

Step 2/2: Build Package (NuGet Pack) (14s)

[12:10:40][Step 2/2] Cleaning Z:\hgbuilds\IT\Build\packages

[12:10:40][Step 2/2] pack: Create NuGet package from UI\UI.Tour\UI.Tour.Web\UI.Tour.Web.csproj (14s)

[12:10:40][pack] NuGet command: C:\BuildAgent\tools\NuGet.CommandLine.2.2.1.nupkg\tools\NuGet.exe pack Z:\hgbuilds\IT\UI\UI.Tour\UI.Tour.Web\Calrom.UI.InclusiveTour.Web.csproj -OutputDirectory Z:\hgbuilds\IT\Build\packages -BasePath Z:\hgbuilds\IT -Verbose -Version 1.0.0.7 -Symbols -Properties Configuration=Deploy-Test

[12:10:40][pack] Starting: C:\BuildAgent\temp\agentTmp\custom_script2086270793558421822.cmd

[12:10:40][pack] in directory: Z:\hgbuilds\IT

[12:10:45][pack] WARNING: Option 'Verbose' has been deprecated. Use 'Verbosity' instead.

[12:10:45][pack] Attempting to build package from 'UI.Tour.Web.csproj'.

[12:10:45][pack] Packing files from 'Z:\hgbuilds\IT\UI\UI.Tour\UI.Tour.Web\bin'.

[12:10:46][pack] WARNING: Description was not specified. Using 'Description'.

[12:10:48][pack] content

[12:10:54][pack] Cannot add part for the specified URI because it is already in the package.

[12:10:54][pack] Process exited with code 1

[12:10:54][Step 2/2] Step Build Package (NuGet Pack) failed

Please guide what I am missing here.

sam
  • 4,594
  • 12
  • 61
  • 111
  • +1, but if my answer doesn't help please could you post your nuspec file/more details? – infojolt Apr 04 '13 at 12:54
  • 1
    I am using octopack. Cant see any nuspec file. It has added a package file with following contents and in NUGET Pack sending the package parameters specifying project file – sam Apr 04 '13 at 14:14
  • Did you get this fixed? – Dan H May 09 '13 at 14:09

6 Answers6

8

I had the same error but there were no issues in the csproj file. I was using typescript and was accidentally checking in the .js files. So at run-time another js file was being generated, thus there were two of each js files being added.

I found it by going through the team city build log and looking for duplicates. As they were "do not copy" there was no issue with a simple msbuild but as we just switched to using Octopack, cannot add multiple when nugeting a solution.....

You can find the culprit (typescript or otherwise) as it will be the first to appear after the "attempting to create line" (there could be many but finding them on at a time could be easier than doing it manually) enter image description here

GarethReid
  • 406
  • 4
  • 12
5

Edit the project file and make sure you do not have duplicate Reference Incudes or duplicate Content Includes. My issue was I had...

    <Reference Include="SCS.PickList, Version=1.7.0.0, Culture=neutral, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>Bin\SCS.PickList.dll</HintPath>
</Reference>

AND

<Content Include="Bin\SCS.PickList.dll" />

Once I removed the Content include it worked.

Dan H
  • 1,828
  • 2
  • 21
  • 38
  • Thanks this solved the problem for me too! I also got this issue because of an assembly reference in the project that occurred both as Reference and Content include in the *.csproj file. – gurkan Jan 02 '14 at 11:17
2

One possible problem could be that Octopack is actually case sensitive. In my case VS Project had reference to the file with name in lower case letters such as this

Adam B
  • 3,775
  • 3
  • 32
  • 42
abjinugu
  • 21
  • 3
  • my problem was case sensitivity also. Typescript file with capitals was compiling to a js file with a filename that was the same but all lower case. Changing the case of the .js filename to match the .ts file fixed the issue – soupy1976 Jun 30 '16 at 11:21
  • 1
    In my case, it as as obscure as having an old `/// ` line at the top of another file caused Language-Service.ts to compile to language-service.ts – Jeremy Noble Jan 20 '17 at 09:06
1

In my .nuspec file I had the lines equivalent to:

<file src="Source\MyCompany.ProjectA\**\*.cs" target="src" />
<file src="Source\MyCompany.ProjectB\**\*.cs" target="src" />

I got the error due to the AssemblyInfo.cs file being in both projects.

(This was to enable the creation of a NuGet Symbol Package.)

David White
  • 3,014
  • 1
  • 32
  • 35
  • I had the same problem. To fix it, specify different target directories: target="src\ProjectA", target="src\ProjectB". – Daniel Nov 29 '14 at 22:28
1

For me, it was because my files didn't have extensions.

<file src=".\LICENSE" target="" />
<file src=".\NOTICE" target="" />

My solution was to add a wildcard to the end of the file:

<file src=".\LICENSE*" target="" />
<file src=".\NOTICE*" target="" />
Aaron Jensen
  • 25,861
  • 15
  • 82
  • 91
  • Thank you so much, I have no idea how long it would have taken me to find this if not for your answer here. – bikeman868 Jan 10 '18 at 00:22
0

In your nuspec file do you have a file node specified?

<files>
    <file src="the_dll_for_your_csproj"/>
</files>

If so, is it possible that you have included (either explicitly or by wildcard) the dll for the csproj you are trying to build?

infojolt
  • 5,244
  • 3
  • 40
  • 82