Error OCTONUGET: Target path contains invalid characters

Hi Team,

We are getting error while teamcity creates octopack in the teamcity.
Please find below log

[CreateOctoPackPackage] error OCTONUGET: Target path 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Graph\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Graph.dll' contains invalid characters.
[09:57:01][CreateOctoPackPackage] error OCTONUGET: Target path 'C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.PowerPoint\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.PowerPoint.dll' contains invalid characters.
[09:57:01][CreateOctoPackPackage] error OCTONUGET: Target path 'C:\Windows\assembly\GAC_MSIL\Microsoft.Vbe.Interop\15.0.0.0__71e9bce111e9429c\Microsoft.Vbe.Interop.dll' contains invalid characters.
[09:57:01][CreateOctoPackPackage] error OCT-1805672349: There was an error calling NuGet. Please see the output above for more details. Command line: 'E:\ProjectBuildDirectory\91b27f9720f85ff2\packages\OctoPack.3.0.33\tools\NuGet.exe' pack "E:\ProjectBuildDirectory\91b27f9720f85ff2\PackageName\obj\octopacking\PackageName.nuspec"  -NoPackageAnalysis -BasePath "E:\ProjectBuildDirectory\91b27f9720f85ff2\PackageName" -OutputDirectory "E:\ProjectBuildDirectory\91b27f9720f85ff2\PackageName" -Version 5.0.2302
[09:57:01]
[CreateOctoPackPackage] error OCT-1805672349: System.Exception: There was an error calling NuGet. Please see the output above for more details. Command line: 'E:\ProjectBuildDirectory\91b27f9720f85ff2\packages\OctoPack.3.0.33\tools\NuGet.exe' pack "E:\ProjectBuildDirectory\91b27f9720f85ff2\PackageName\obj\octopacking\PackageName.nuspec"  -NoPackageAnalysis -BasePath "E:\ProjectBuildDirectory\91b27f9720f85ff2\PackageName" -OutputDirectory "E:\ProjectBuildDirectory\91b27f9720f85ff2\PackageName" -Version 5.0.2302
   at OctoPack.Tasks.CreateOctoPackPackage.RunNuGet(String specFilePath, String octopacking, String octopacked, String projectDirectory) in y:\work\46cfb6001f03d701\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 538
   at OctoPack.Tasks.CreateOctoPackPackage.Execute() in y:\work\46cfb6001f03d701\source\OctoPack.Tasks\CreateOctoPackPackage.cs:line 195

Can you please check this why this error happening?
Regards,
Shyam

Hi Shyam,

Thanks for getting in touch.

We had a look in the discussion forums and there was a similar case reported several years ago here that may help.

From what we can understand, Nuget.exe pack does not like referencing files in the GAC. I think you’ll find if you just use the Nuget.exe pack command (which OctoPack just calls through to), the same error will occur, so the problem is with Nuget.exe.

This other customer’s solution was to copy the locally referenced Office GAC assemblies into a “lib” directory and referenced them in their project.

Could you give their solution a try and let me know how you go.

Hope this helps.

Cheers
Mark

Hi Mark,

Thank you for reply.
I have already read that article but, I am not able to solve the problem. The problem is that in different machine Project builds get succeeded. Once I select second machine we got build error in teamcity.

Can you please check that why it is not working in different machine?

Regards,
Shyam

Hi Shyam,

Could you please clarify what you mean by you selecting a different machine? Do you mean another TeamCity build agent?

That error you previously showed is when OctoPack is using nuget.exe to pack. If it’s failing on that step for some build agents (but working on others), then it is a problem with that build agent and not something we can help with. You will have to investigate what is different about that build agent compared to the agent where it runs successfully.

Did you try moving those libraries from the GAC and referencing them in your project as described in the other support issue? That may help it to work on any build agent.

Cheers
Mark