From 056c3db0774dace9f83fcc5633720d2a8226cf1b Mon Sep 17 00:00:00 2001 From: Jeremy Koritzinsky Date: Thu, 4 Feb 2021 14:46:38 -0800 Subject: [PATCH] Use the package_tool.sh script that dotnet-deb-tool wraps directly and is maintained in Arcade instead of the old dotnet-deb-tool CLI tool package. --- src/core-sdk-tasks/DotNetDebTool.cs | 74 +++++++++++++++++++++---- src/redist/redist.csproj | 4 ++ src/redist/targets/GenerateDebs.targets | 16 ++---- src/redist/targets/GenerateMSIs.targets | 6 +- 4 files changed, 72 insertions(+), 28 deletions(-) diff --git a/src/core-sdk-tasks/DotNetDebTool.cs b/src/core-sdk-tasks/DotNetDebTool.cs index 82036e60c..8d111f171 100644 --- a/src/core-sdk-tasks/DotNetDebTool.cs +++ b/src/core-sdk-tasks/DotNetDebTool.cs @@ -1,23 +1,14 @@ // 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.Diagnostics; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace Microsoft.DotNet.Cli.Build { - public class DotNetDebTool : DotNetTool + public class DotNetDebTool : ToolTask { - protected override string Command - { - get { return "deb-tool"; } - } - - protected override string Args - { - get { return $"{GetInputDir()} {GetOutputFile()} {GetPackageName()} {GetPackageVersion()}"; } - } - [Required] public string InputDirectory { get; set; } @@ -30,6 +21,10 @@ namespace Microsoft.DotNet.Cli.Build [Required] public string PackageVersion { get; set; } + public string WorkingDirectory { get; set; } + + protected override string ToolName => "package_tool.sh"; + private string GetInputDir() { return $"-i {InputDirectory}"; @@ -49,5 +44,62 @@ namespace Microsoft.DotNet.Cli.Build { return $"-v {PackageVersion}"; } + + protected override MessageImportance StandardOutputLoggingImportance + { + get { return MessageImportance.High; } // or else the output doesn't get logged by default + } + + protected override string GenerateFullPathToTool() + { + string path = ToolPath; + + // if ToolPath was not provided by the MSBuild script + if (string.IsNullOrEmpty(path)) + { + Log.LogError($"Could not find the Path to {ToolName}"); + + return string.Empty; + } + + return path; + } + + protected override string GetWorkingDirectory() + { + return WorkingDirectory ?? base.GetWorkingDirectory(); + } + + protected override string GenerateCommandLineCommands() + { + var commandLineCommands = $"{GetInputDir()} {GetOutputFile()} {GetPackageName()} {GetPackageVersion()}"; + + LogToolCommand($"package_tool.sh {commandLineCommands}"); + + return commandLineCommands; + } + + protected override void LogToolCommand(string message) + { + base.LogToolCommand($"{GetWorkingDirectory()}> {message}"); + } + + protected override ProcessStartInfo GetProcessStartInfo( + string pathToTool, + string commandLineCommands, + string responseFileSwitch) + { + var psi = base.GetProcessStartInfo( + pathToTool, + commandLineCommands, + responseFileSwitch); + + foreach (var environmentVariableName in new EnvironmentFilter().GetEnvironmentVariableNamesToRemove()) + { + psi.Environment.Remove(environmentVariableName); + } + + return psi; + } } } diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index 852ba97c1..b9c93ddf5 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -16,6 +16,10 @@ + + + + diff --git a/src/redist/targets/GenerateDebs.targets b/src/redist/targets/GenerateDebs.targets index 72305b0a7..2db99a2b6 100644 --- a/src/redist/targets/GenerateDebs.targets +++ b/src/redist/targets/GenerateDebs.targets @@ -1,10 +1,9 @@ - - - - + + $(PkgMicrosoft_DotNet_Build_Tasks_Installers)/build/deb-package-tool/package_tool.sh + @@ -286,7 +284,7 @@ ReplacementItems="@(DebianConfigTokenValues)" /> - - - - - - diff --git a/src/redist/targets/GenerateMSIs.targets b/src/redist/targets/GenerateMSIs.targets index 2ef350c4f..6c5d16204 100644 --- a/src/redist/targets/GenerateMSIs.targets +++ b/src/redist/targets/GenerateMSIs.targets @@ -1,9 +1,5 @@ - - - - - + $(NuGetPackageRoot)microsoft.dotnet.build.tasks.installers\$(MicrosoftDotNetBuildTasksInstallersPackageVersion)\tools\netcoreapp2.1\Microsoft.DotNet.Build.Tasks.Installers.dll $(NuGetPackageRoot)microsoft.dotnet.build.tasks.installers\$(MicrosoftDotNetBuildTasksInstallersPackageVersion)\tools\net472\Microsoft.DotNet.Build.Tasks.Installers.dll