Skip to content
Cake.Wget is a cross-platform add-in for Cake which encapsulates downloading files via Wget.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.editorconfig
.gitattributes
.gitignore
.travis.yml Added Travis CI yaml file Jun 22, 2019
LICENSE
README.md
appveyor.yml
azure-pipelines-macos.yml
azure-pipelines-ubuntu.yml Added azure pipelines for macOS and Ubuntu Jul 13, 2019
azure-pipelines-windows.yml
build.cake
build.ps1
build.sh
global.json

README.md

Cake.Wget

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.

Nuget

Continuous integration

Build server Platform Build status
Travis CI Ubuntu Build Status
AppVeyor Windows AppVeyor branch
Azure Pipelines Windows Build Status
Azure Pipelines Ubuntu Build Status
Azure Pipelines macOS Build Status
Test Coverage
Coverage Status

Prerequisites

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.

Usage

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.Wget

You can also specify version which should be used:

#addin nuget:?package=Cake.Wget&version=1.0.0

Command 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.

Download a single file

var settings = new WgetSettings {
    Url = new Uri("https://wordpress.org/latest.zip")
};

Wget(settings);

Download a file and save it under a different name

var settings = new WgetSettings {
    Url = new Uri("https://wordpress.org/latest.zip"),
    OutputDocument = "wordpress.zip"
};

Wget(settings);

Download a file and save it in a specific directory

var settings = new WgetSettings {
    Url = new Uri("https://wordpress.org/latest.zip"),
    DirectoryPrefix = "/opt/wordpress"
};

Wget(settings);

Set the download speed to 300KB/s

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.

Continue interrupted download

var settings = new WgetSettings {
    Url = new Uri("https://wordpress.org/latest.zip"),
    Continue = true
};

Wget(settings);

Download multiple files

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);

License

MIT License © deqenq

Addendum

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.

You can’t perform that action at this time.