Sometimes you need to download additional files (installers, libraries, resources, etc.) required by your build process.
There are a number of ways you can download a file in AppVeyor environment:
$source = "http://yoursite.com/file.xml" $destination = "c:\application\data\newdata.xml" Invoke-WebRequest $source -OutFile $destination
$source = "ftp://yoursite.com/file.xml" $destination = "c:\application\data\newdata.xml" Invoke-WebRequest $source -OutFile $destination -Credential ftpUser
You can use the following PowerShell code to download a file using
System.Net.WebClient class which is part of .NET Framework:
(New-Object Net.WebClient).DownloadFile('<file_url>', '<local_file_name>')
<file_url>- URL of remote file
<local_file_name>- full local path to downloaded file
AppVeyor build session has built-in
Start-FileDownload cmdlet for downloading files. There are some advantages of using this cmdlet instead of WebClient class:
Start-FileDownload <url> [-FileName <string>] [-Timeout <int>]
Timeout value is milliseconds. Default timeout is 300000 (5 minutes).
For example, the following command downloads a remote file to the current folder with
Example usage in
install: - ps: Start-FileDownload 'http://www.myserver.com/packages/installer.msi'
If you are getting the following error while downloading
Start-FileDownloadInternal : Error downloading remote file: One or more errors occurred. Inner Exception: The request was aborted: Could not create SSL/TLS secure channel.
this most probably means that build worker and server could not agree on SSL protocol, because server does not support modern protocol with highest security. If you understand this security risk and trust that server, you can relax SSL client settings in build PowerShell session by the following statement called before
[Net.ServicePointManager]::SecurityProtocol = 'Ssl3, Tls, Tls11, Tls12'
AppVeyor command-line utility (
appveyor.exe) which is a part of Build Agent API provides
DownloadFile command which behaves similar to Start-FileDownload cmdlet.
appveyor DownloadFile <url> [-FileName <string>] [-Timeout <int>]
appveyor DownloadFile http://www.myserver.com/packages/installer.msi
curl.exe) has already been added to
PATH on build workers. Users on Unix-like operating systems may be more familiar with this command.
curl [-fsSL...] [-o <output-filename>] [-m <timeout-in-seconds>] <url>
For scripting, using
-fsSL) is recommended. For more info on what the flags do, see the curl manual. Be aware that if neither
-O are given, curl will dump the data to standard output.
curl -fsS -o installer.msi http://www.myserver.com/packages/installer.msi