change to properties, artifact names
This commit is contained in:
parent
0d37da4d0d
commit
fa97921a4d
23 changed files with 698 additions and 87 deletions
49
build_projects/dotnet-cli-build/DownloadFile.cs
Normal file
49
build_projects/dotnet-cli-build/DownloadFile.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Net.Http;
|
||||
using Microsoft.Build.Utilities;
|
||||
using Microsoft.DotNet.Cli.Build.Framework;
|
||||
using Microsoft.DotNet.InternalAbstractions;
|
||||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Build
|
||||
{
|
||||
public class DownloadFile : Task
|
||||
{
|
||||
[Required]
|
||||
public string Uri { get; set; }
|
||||
|
||||
[Required]
|
||||
public string DestinationPath { get; set; }
|
||||
|
||||
public bool Overwrite { get; set; }
|
||||
|
||||
public override bool Execute()
|
||||
{
|
||||
FS.Mkdirp(Path.GetDirectoryName(DestinationPath));
|
||||
|
||||
if (File.Exists(DestinationPath) && !Overwrite)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
var getTask = httpClient.GetStreamAsync(Uri);
|
||||
|
||||
using (var outStream = File.Create(DestinationPath))
|
||||
{
|
||||
getTask.Result.CopyTo(outStream);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue