Cake.Wget is a cross-platform add-in for Cake which encapsulates downloading files via Wget tool. Cake.Wget targets the .NET Standard 2.0 which means that will run on Windows, Linux and macOS.
| Build server | Platform | Build status |
|---|---|---|
| AppVeyor | Windows | |
| Azure Pipelines | Windows | |
| Azure Pipelines | Ubuntu | |
| Azure Pipelines | macOS |
You will need to have a copy of the Wget executable for your OS. Put location of Wget executable in your PATH environment variable and Cake will find it.
Cake.Wget is wrapper for command line Wget tool. To use Cake.Wget, you must import addin in your cake script:
#addin nuget:?package=Cake.WgetYou can also specify version which should be used:
#addin nuget:?package=Cake.Wget&version=1.1.0Command line switches are passed to the tool by WgetSettings object properties. Most WgetSettings properties names can be derived from Wget command line switches (long version) and vice versa. For example command line switch --input-file is translated to WgetSettings property name InputFile.
If command line switch does not have corresponding property, it can be passed to Wget tool by ArgumentCustomization:
var settings = new WgetSettings {
ArgumentCustomization = args=>args.Append("--debug")
.Append("--dns-timeout=10")
};Detailed documentation of all Wget command line switches can be found in official Wget manual pages.
var settings = new WgetSettings {
Url = new Uri("https://wordpress.org/latest.zip")
};
Wget(settings);var settings = new WgetSettings {
Url = new Uri("https://wordpress.org/latest.zip"),
OutputDocument = "wordpress.zip"
};
Wget(settings);var settings = new WgetSettings {
Url = new Uri("https://wordpress.org/latest.zip"),
DirectoryPrefix = "/opt/wordpress"
};
Wget(settings);var settings = new WgetSettings {
Url = new Uri("https://wordpress.org/latest.zip"),
LimitRate = new WgetLimitRateArgument(
300,
LimitRateUnitEnum.Kilobytes)
};
Wget(settings);Note: If you do not specify limit rate units (it is optional parameter), then the number means bytes per second.
var settings = new WgetSettings {
Url = new Uri("https://wordpress.org/latest.zip"),
Continue = true
};
Wget(settings);If you want to download multiple files with one command, create a text file (for example download.txt) and write the URLs each on separate line.
var settings = new WgetSettings {
InputFile = "download.txt"
};
Wget(settings);MIT License © deqenq
There is another interesting Cake add-in Cake.Curl. Curl is command line tool and library for transferring data with URLs.
General comparison between curl and Wget is described here.