Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception calling "DownloadFile" with "2" argument(s): "The path is not of a legal form." #60

Closed
sreeraj-rajendran opened this issue Feb 28, 2020 · 8 comments
Assignees
Labels
Milestone

Comments

@sreeraj-rajendran
Copy link

Per the the task configuration, nuget.exe will be downloaded from : https://dist.nuget.org/win-x86-commandline/latest/nuget.exe if the :Nuget.exe location" is unspecified.

The task seems to be failing with the error: ##[error]Exception calling "DownloadFile" with "2" argument(s): "The path is not of a legal form." When leaving this to default.

The behavior is the same when we try from a dummy pipeline - just with the cake task with no arguments as well.
However, enabling the option – “Use the Build Agent Nuget” works

@dannmichelson
Copy link

dannmichelson commented Feb 28, 2020

Hello @gep13 - It looks like the change you made for 0.4.2 is causing this issue. The stack trace we saw is below. It seems like the build task, when we don't specify the location, is still interpreting $nugetExeDownloadLocation as an empty string rather than null, so when you replaced if($nugetExeDownloadLocation -eq "") with if($null -eq $nugetExeDownloadLocation), I'm guessing we get a $nugetExeDownloadLocation that is empty, so then it tries to DownloadFile from the url "" (blank), and then we get this exception

I'm also assuming you made this change because elsewhere you were getting $nugetExeDownloadLocation coming in as null and not "". Perhaps you could replace this and have a check for null or empty?
Edit: Something like one of these?
if($null -eq $nugetExeDownloadLocation -Or $nugetExeDownloadLocation -eq "")
if($null -eq $nugetExeDownloadLocation -Or $nugetExeDownloadLocation.trim() -eq "")

##[debug]System.Management.Automation.MethodInvocationException: Exception calling "DownloadFile" with "2" argument(s): "The path is not of a legal form." ---> System.ArgumentException: The path is not of a legal form.
##[debug]   at System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths)
##[debug]   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
##[debug]   at System.IO.Path.GetFullPathInternal(String path)
##[debug]   at System.Net.WebClient.GetUri(String path)
##[debug]   at System.Net.WebClient.DownloadFile(String address, String fileName)
##[debug]   at CallSite.Target(Closure , CallSite , Object , Object , Object )
##[debug]   --- End of inner exception stack trace ---
##[debug]   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
##[debug]   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
##[debug]   at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
##[debug]   at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
##[debug]   at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
##[debug]   at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
##[debug]   at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
##[debug]   at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord()
##[debug]   at System.Management.Automation.CommandProcessor.ProcessRecord()
##[error]Exception calling "DownloadFile" with "2" argument(s): "The path is not of a legal form."

MO2k4 added a commit to MO2k4/cake-vso that referenced this issue Feb 28, 2020
test if $nugetExeDownloadLocation is empty or null
@MO2k4
Copy link
Contributor

MO2k4 commented Feb 28, 2020

Hey

i have a change and proposed it as a PR.

i would do a check like this

if (-Not $nugetExeDownloadLocation)

@gep13 gep13 self-assigned this Feb 28, 2020
@gep13 gep13 added the Bug label Feb 28, 2020
@gep13 gep13 added this to the 0.4.3 milestone Feb 28, 2020
@gep13 gep13 changed the title The new update throws an exception while trying to download nuget.exe Exception calling "DownloadFile" with "2" argument(s): "The path is not of a legal form." Feb 28, 2020
@gep13 gep13 closed this as completed Feb 28, 2020
gep13 pushed a commit that referenced this issue Feb 28, 2020
test if $nugetExeDownloadLocation is empty or null
gep13 added a commit that referenced this issue Feb 28, 2020
* hotfix/0.4.3:
  (GH-59) Remove mention of Chocolatey
  #60 Update Task/Cake.ps1
gep13 added a commit that referenced this issue Feb 28, 2020
* hotfix/0.4.3:
  (GH-59) Remove mention of Chocolatey
  #60 Update Task/Cake.ps1
@cake-build-bot
Copy link

🎉 This issue has been resolved in version 0.4.3 🎉

The release is available on:

Your GitReleaseManager bot 📦🚀

@gep13
Copy link
Member

gep13 commented Feb 28, 2020

@sreeraj-rajendran @dannmichelson @MO2k4 @scott-the-programmer @danieljgmaclean @bkowalczyk88 This issue should now be resolved, with version 0.4.3 of the extension. Can you please let me know if you are still seeing problems.

Thanks

@MO2k4
Copy link
Contributor

MO2k4 commented Feb 28, 2020

Looks beautiful again, thanks for your fast response 👍

@JoaoDiogoF
Copy link

JoaoDiogoF commented Jun 16, 2020

We have been experiencing this bug again since this morning:

##[debug]Exception:
##[debug]System.Management.Automation.MethodInvocationException: Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: Could not create SSL/TLS secure channel." ---> System.Net.WebException: The request was aborted: Could not create SSL/TLS secure channel.
##[debug]   at System.Net.WebClient.DownloadFile(Uri address, String fileName)
##[debug]   at CallSite.Target(Closure , CallSite , Object , Object , Object )
##[debug]   --- End of inner exception stack trace ---
##[debug]   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
##[debug]   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
##[debug]   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
##[debug]   at System.Management.Automation.ScriptBlock.InvokeWithPipeImpl(ScriptBlockClauseToInvoke clauseToInvoke, Boolean createLocalScope, Dictionary`2 functionsToDefine, List`1 variablesToDefine, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Object[] args)
##[debug]   at System.Management.Automation.ScriptBlock.<>c__DisplayClass57_0.<InvokeWithPipe>b__0()
##[debug]   at System.Management.Automation.Runspaces.RunspaceBase.RunActionIfNoRunningPipelinesWithThreadCheck(Action action)
##[debug]   at System.Management.Automation.ScriptBlock.InvokeWithPipe(Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Pipe outputPipe, InvocationInfo invocationInfo, Boolean propagateAllExceptionsToTop, List`1 variablesToDefine, Dictionary`2 functionsToDefine, Object[] args)
##[debug]   at System.Management.Automation.ScriptBlock.InvokeUsingCmdlet(Cmdlet contextCmdlet, Boolean useLocalScope, ErrorHandlingBehavior errorHandlingBehavior, Object dollarUnder, Object input, Object scriptThis, Object[] args)
##[debug]   at Microsoft.PowerShell.Commands.ForEachObjectCommand.ProcessRecord()
##[debug]   at System.Management.Automation.CommandProcessor.ProcessRecord()
##[error]Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: Could not create SSL/TLS secure channel."
##[debug]Processed: ##vso[task.logissue type=error]Exception calling "DownloadFile" with "2" argument(s): "The request was aborted: Could not create SSL/TLS secure channel."

We are having this issue again with Cake.AzureDevOps v0.4.4, is it possible that the same bug as in v0.4.2 snug it's way back in?
EDIT:
Error was discovered, as of June 15th nuget does not support TLS 1.0 and 1.1.

@kapsiR
Copy link

kapsiR commented Jun 16, 2020

@JoaoDiogoF For reference, there is a new issue because of the removal of TLS1.X.

I've also added a workaround, when you are in full control of the machine.

@umesawan
Copy link

TLS 1.2 should be enabled to get it working. In PowerShell you can find out which protocols your system supports by running this code:

[Enum]::GetNames([Net.SecurityProtocolType]) -contains 'Tls12'
If the result is True then your system supports TLS 1.2. You can find out which protocols are being used by running:

If the result is True then TLS 1.2 is being used . However, you can add TLS 1.2 explicitly by using:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
This should solve these problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants