System.ArgumentException: Illegal characters in path

I’m trying to upload a NuGet package from TeamCity (using NuGet 3.4.3) and I’m getting this error:

Unhandled error on request: http://localhost:89/nuget/packages/ by HLindestaf : Illegal characters in path.
System.ArgumentException: Illegal characters in path.
at System.IO.Path.CheckInvalidPathChars(String path, Boolean checkAdditional)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream…ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Octopus.Shared.Util.OctopusPhysicalFileSystem.OpenFile(String path, FileMode mode, FileAccess access, FileShare share) in Y:\work\refs\tags\3.3.9\source\Octopus.Shared\Util\OctopusPhysicalFileSystem.cs:line 184
at Octopus.Shared.Util.OctopusPhysicalFileSystem.CreateTemporaryFile(String filename, String& path) in Y:\work\refs\tags\3.3.9\source\Octopus.Shared\Util\OctopusPhysicalFileSystem.cs:line 210
at Octopus.Server.Web.Api.NuGet.PackagePushActionBase1.SaveToTemporaryLocation(HttpFile packageFile) in Y:\work\refs\tags\3.3.9\source\Octopus.Server\Web\Api\NuGet\PackagePushActionBase.cs:line 117 at Octopus.Server.Web.Api.NuGet.PackagePushActionBase1.Execute() in Y:\work\refs\tags\3.3.9\source\Octopus.Server\Web\Api\NuGet\PackagePushActionBase.cs:line 58
at Octopus.Server.Web.Infrastructure.Api.Responder`1.Respond(TDescriptor options, NancyContext context) in Y:\work\refs\tags\3.3.9\source\Octopus.Server\Web\Infrastructure\Api\Responder.cs:line 162
at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
at Octopus.Server.Web.Api.OctopusRestApiModule.<>c__DisplayClass0_0.<.ctor>b__0(Object o) in Y:\work\refs\tags\3.3.9\source\Octopus.Server\Web\Api\OctopusRestApiModule.cs:line 46
at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)

I noticed this only works when I’m using NuGet 3.4.3 in TeamCity, 3.3 works fine.

I noticed the same problem.

If i downgrade to Nuget 2.8.6 on the buid server it work fine but with nuget 3.4.3 it does not work.

My octopus server version is 3.3.8.

I can also confirm that NuGet 3.3.0 does not have this problem.

Hi Folks,

Thanks for reporting the error. We have an open issue you can track here: https://github.com/OctopusDeploy/Issues/issues/2464
It should be fixed in one of the next releases.

The only work around that we know is to roll back NuGet as has been suggested.

Vanessa