Skip to content
↔️ A cross-platform add-in for Cake that allows to transfer files to and from remote URLs using curl.
Branch: master
Clone or download
ecampidoglio Bumps the version to 4.1.0
This release adds new features while still being backwards compatible,
so we increment the minor version.
Latest commit c3bffdb May 21, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build Generates a code coverage report using Coverlet May 5, 2019
src Bumps the version to 4.1.0 May 21, 2019
.editorconfig
.gitattributes Adds the .gitignore and .gitattributes files Dec 18, 2016
.gitignore
.travis.yml Builds with the SDK version 2.1.502 on Travis CI May 3, 2019
LICENSE.txt
README.md Adds the code coverage badge to the README file May 5, 2019
appveyor.yml
build.cake Upgrades to xUnit.net 2.4.1 May 15, 2019
build.ps1 Inconsistent cake version (#23) Mar 12, 2019
build.sh
global.json Requires version 5.0.* of the 2.1 SDK May 3, 2019
logo.png Adds the logo Mar 13, 2017

README.md

Cake.Curl

Package Windows Linux Tests Coverage
NuGet AppVeyor Travis CI Tests Coverage

Cake.Curl is a cross-platform add-in for Cake that allows to transfer files to and from remote URLs using curl.

Cross-platform

Cake.Curl targets the .NET Standard 2.0 and the .NET Framework 4.6. As such, it will run on Linux, macOS and Windows.

Prerequisites

In order to use Cake.Curl, you will need to have a copy of the curl executable for your OS. It doesn't have to be in a specific location; as long as it's included in your PATH environment variable, Cake will find it.

Usage

The purpose of this add-in is to expose the functionality of curl to the Cake DSL by being a very thin wrapper around its command line interface; this means that you can use Cake.Curl in the same way as you would normally use curl, only with a different interface.

Here are a few examples of how some common usage scenarios would look like in a Cake script.

First of all, you need to import Cake.Curl in your build script by using the add-in directive:

#addin Cake.Curl

Downloading Files

Downloading a text file from a remote HTTP server onto the working directory:

Task("Download")
    .Does(() =>
{
    CurlDownloadFile(new Uri("http://host/file.txt"));
});

Downloading a sequence of text files numbered between 1 and 10 from a remote HTTP server onto the working directory:

Task("Download")
    .Does(() =>
{
    CurlDownloadFile(new Uri("http://host/file[1-10].txt"));
});

Downloading a text file from a remote HTTP server onto the working directory and giving it a different name:

Task("Download")
    .Does(() =>
{
    CurlDownloadFile(
        new Uri("http://host/file.txt"),
        new CurlDownloadSettings
        {
            OutputPaths = new FilePath[] { "renamed.txt" }
        });
});

Downloading multiple files concurrently from different servers onto the working directory:

Task("Download")
    .Does(() =>
{
    CurlDownloadFiles(new[]
    {
        new Uri("ftp://host/file.txt"),
        new Uri("ftp://anotherhost/anotherfile.txt"),
        new Uri("http://yetanotherhost/yetanotherfile.txt")
    }
});

Downloading multiple files into specific paths:

Task("Download")
    .Does(() =>
{
    CurlDownloadFiles(
        new[]
        {
            new Uri("ftp://host/file.txt"),
            new Uri("http://anotherhost/anotherfile.txt"),
        }
        new CurlDownloadSettings
        {
            OutputPaths = new FilePath[]
            {
                "some/path/file.txt",
                "some/other/path/anotherfile.txt"
            }
        });
});

Uploading Files

Uploading a local text file to a remote HTTP server:

Task("Upload")
    .Does(() =>
{
    CurlUploadFile("some/file.txt", new Uri("http://host/path"));
});

Uploading a local text file to a remote FTPS server using credentials:

Task("Upload")
    .Does(() =>
{
    CurlUploadFile(
        "some/file.txt",
        new Uri("ftps://host/path"),
        new CurlSettings
        {
            Username = "username",
            Password = "password"
        });
});

Custom HTTP Headers

Transferring a file using a custom HTTP header in the request:

Task("Upload")
    .Does(() =>
{
    CurlUploadFile(
        "some/file.txt",
        new Uri("http://host/path"),
        new CurlSettings
        {
            Headers = new Dictionary<string, string>
            {
                ["X-SomeHeader"] = "SomeValue"
            }
        });
});

Additional Resources

You can find more information about how to use Cake.Curl in the official documentation for these projects:

You can also see Cake.Curl in action in the following videos:

You can’t perform that action at this time.