Skip to content

Latest commit

 

History

History
76 lines (61 loc) · 3.21 KB

downloadfile-task.md

File metadata and controls

76 lines (61 loc) · 3.21 KB
title ms.date ms.reviewer ms.suite ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager ms.workload
DownloadFile Task | Microsoft Docs
11/04/2016
reference
VB
CSharp
C++
jsharp
DownloadFile task [MSBuild]
MSBuild, DownloadFile task
916bb2e3-3017-4828-ae27-c0b5c99bbb48
16
ghogen
ghogen
jillfra
multiple

DownloadFile task

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

Note

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

Parameters

The following table describes the parameters of the DownloadFile task.

Parameter Description
DestinationFileName Optional xref:Microsoft.Build.Framework.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 xref:Microsoft.Build.Framework.ITaskItem parameter.

Specifies the destination folder to download the file to. If folder is created if it does not exist.
DownloadedFile Optional xref:Microsoft.Build.Framework.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.

Remarks

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

Example

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

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

    <PropertyGroup>
      <MyUrl>https://raw.githubusercontent.com/Microsoft/msbuild/master/LICENSE</MyUrl>
    </PropertyGroup>

    <Target Name="DownloadContentFiles" BeforeTargets="Build">
        <DownloadFile
            SourceUrl="$(MyUrl)"
            DestinationFolder="$(MSBuildProjectDirectory)">
        <Output TaskParameter="DownloadedFile" ItemName="Content" />
      </DownloadFile>
    </Target>

</Project>

See also