38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
using System.IO.Compression;
|
|
using Microsoft.Build.Framework;
|
|
using Microsoft.Build.Utilities;
|
|
using Microsoft.DotNet.Cli.Build.Framework;
|
|
using static Microsoft.DotNet.Cli.Build.Framework.BuildHelpers;
|
|
|
|
namespace Microsoft.DotNet.Cli.Build
|
|
{
|
|
public class ExtractArchive : Task
|
|
{
|
|
[Required]
|
|
public string InputFile { get; set; }
|
|
|
|
[Required]
|
|
public string DestinationDirectory { get; set; }
|
|
|
|
public override bool Execute()
|
|
{
|
|
FS.Mkdirp(DestinationDirectory);
|
|
|
|
Log.LogMessage($"Extracting Archive '{InputFile}' to '{DestinationDirectory}'");
|
|
|
|
if (CurrentPlatform.IsWindows)
|
|
{
|
|
ZipFile.ExtractToDirectory(InputFile, DestinationDirectory);
|
|
}
|
|
else
|
|
{
|
|
Exec("tar", "xf", InputFile, "-C", DestinationDirectory);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|