OctoPack error: Cannot add part for the specified URI because it is already in the package

Recently, I had an issue with a project team’s TFS build and the OctoPack. Within the TFS log, I found this error:

OctoPack error OCTONUGET: Cannot add part for the specified URI because it is already in the package.

After some google-fu, I found a helpful post on StackOverflow. Short answer: you have to remove any duplicate references or duplicate content includes. This fixed worked for us and I imagine it would work for most people.
It takes a few minutes to solve the problem but without finding that post on StackOverflow, I imagine that I’d still be trying to find the fix. The error details within the TFS log did not specify the duplicate referenced file in question, nor did the actual file exist within our project. The culprit was we had duplicate references in our <DocumentationFile> tag within the csproject (.csproj) file. Once removed, everything worked fine. Keep in mind, MSBuild was finished and this was at the very end of the OctoPack process of adding all the files to the package. Let’s look at the error within the TFS log below:

2>MSBUILD : OctoPack error OCTONUGET: Cannot add part for the specified URI because it is already in the package. [C:\Builds\11\…\src\Web\SampleWebProject.Web\SampleWebProject.Web.csproj]
2>MSBUILD : OctoPack error OCT-1805672349: There was an error calling NuGet. Please see the output above for more details. Command line:
‘C:\Builds\11\…\src\Web\packages\OctoPack.3.0.31\tools\NuGet.exe’ pack “C:\Builds\11\…\src\Web\SampleWebProject.Web\obj\octopacking\SampleWebProject.Web.nuspec” -NoPackageAnalysis -BasePath “C:\Builds\11\…\src\Web\SampleWebProject.Web” -OutputDirectory “C:\Builds\11\…\src\Web\SampleWebProject.Web\obj\octopacked” -Version 1.0.0.0 [C:\Builds\11\…\src\Web\SampleWebProject.Web\SampleWebProject.Web.csproj]
2>MSBUILD : OctoPack error OCT-1805672349: System.Exception: There was an error calling NuGet. Please see the output above for more details. Command line: ‘C:\Builds\11\…\src\Web\packages\OctoPack.3.0.31\tools\NuGet.exe’ pack “C:\Builds\11\…\src\Web\SampleWebProject.Web\obj\octopacking\SampleWebProject.Web.nuspec” -NoPackageAnalysis -BasePath “C:\Builds\11\…\src\Web\SampleWebProject.Web” -OutputDirectory “C:\Builds\11\…\src\Web\SampleWebProject.Web\obj\octopacked” -Version 1.0.0.0 [C:\Builds\11\…\src\Web\SampleWebProject.Web\SampleWebProject.Web.csproj]
MSBUILD : OctoPack error OCT-1805672349: at OctoPack.Tasks.CreateOctoPackPackage.RunNuGet(String specFilePath, String octopacking, String octopacked, String projectDirectory) in y:\work\46cfb6001f03d701\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 520 [C:\Builds\11\…\src\Web\SampleWebProject.Web\SampleWebProject.Web.csproj]
MSBUILD : OctoPack error OCT-1805672349: at OctoPack.Tasks.CreateOctoPackPackage.Execute() in y:\work\46cfb6001f03d701\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 189 [C:\Builds\11\…\src\Web\SampleWebProject.Web\SampleWebProject.Web.csproj]
2>Done Building Project “C:\Builds\11\…\src\Web\SampleWebProject.Web\SampleWebProject.Web.csproj” (default targets) — FAILED.
1>Done Building Project “C:\Builds\11\…\src\Web\SampleWebProject.Web.sln” (default targets) — FAILED.
Build FAILED.

Initially, I started hunting down the OCT-1805672349 code to no avail. Then the line 520 caught my eye. Since the OctoPack is open source, you can view the CreateOctoPackPackage.cs on GitHub. That path, while accurate was a dead end. Initially, I had not realized that this was really a NuGet issue and that this had nothing to do with the OctoPack. It was the “Cannot add part for the specified URI..” message that lead me to the StackOverflow post.
So I guess the theme of this fix for NuGet (in the OctoPack) is no duplicate references or content in your project file. Ok, NuGet. I understand. I wish your error messages were a little more precise rather than vague. I no longer wish to play with you like this, NuGet. Definitely not “forever and ever..”.
the-shining-grady-twins
 

ianpaullin

Share

1 Response

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment