Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MSBuild download task
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="DownloadFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll">
<ParameterGroup>
<Url ParameterType="System.String" Required="true" />
<File ParameterType="System.String" Required="false" />
<OutputFolder ParameterType="System.String" Required="false" />
</ParameterGroup>
<Task>
<Using Namespace="System.Web"/>
<Code Type="Fragment" Language="cs"><![CDATA[
using (var client = new System.Net.WebClient())
{ client.DownloadFile(Url, (OutputFolder != null ? OutputFolder + "/" : "") + (File ?? System.IO.Path.GetFileName(new Uri(Url).LocalPath))); }
]]></Code>
</Task>
</UsingTask>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.