DownloadFile task

Downloads the specified files using the Hyper-Text Transfer Protocol (HTTP).


The DownloadFile task is available in MSBuild 15.8 and above only.


The following table describes the parameters of the DownloadFile task.

Parameter Description
DestinationFileName Optional ITaskItem parameter

The name to use for the downloaded file. By default, the file name is derived from the SourceUrl or the remote server.
DestinationFolder Required ITaskItem parameter.

Specifies the destination folder to download the file to. If folder is created if it does not exist.
DownloadedFile Optional ITaskItem output parameter.

Specifies the file that was downloaded.
Retries Optional Int32 parameter.

Specifies how many times to attempt to download, if all previous attempts have failed. Defaults to zero.
RetryDelayMilliseconds Optional Int32 parameter.

Specifies the delay in milliseconds between any necessary retries. Defaults to 5000.
SkipUnchangedFiles Optional Boolean parameter.

If true, skips the downloading of files that are unchanged. Defaults to true. The DownloadFile task considers files to be unchanged if they have the same size and the same last modified time according to the remote server.

Note: Not all HTTP servers indicate the last modified date of files will cause the file to be downloaded again.
SourceUrl Required String parameter.

Specifies the URL to download.


In addition to the parameters listed above, this task inherits parameters from the TaskExtension class, which itself inherits from the Task class. For a list of these additional parameters and their descriptions, see TaskExtension base class.


The following example downloads a file and includes it in the Content items prior to building the project.

<Project xmlns="">


    <Target Name="DownloadContentFiles" BeforeTargets="Build">
        <Output TaskParameter="DownloadedFile" ItemName="Content" />


See also