Skip to content

Commit 55fcfd9

Browse files
authored
[SignTool] Add msbuild verbosity option (#15582)
1 parent 5b1e2d1 commit 55fcfd9

File tree

6 files changed

+18
-5
lines changed

6 files changed

+18
-5
lines changed

src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@
9393
PkgToolPath="$(PkgToolPath)"
9494
RepackParallelism="$(SignToolRepackParallelism)"
9595
MaximumParallelFileSize="$(SignToolRepackMaximumParallelFileSize)"
96-
DotNetTimeout="$(SignToolDotNetTimeout)" />
96+
DotNetTimeout="$(SignToolDotNetTimeout)"
97+
MSBuildVerbosity="$(SignToolMSBuildVerbosity)" />
9798
</Target>
9899

99100
</Project>

src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@
116116
<!-- Timeout in milliseconds for DotNet MicroBuild build command. '-1' is infinite. -->
117117
<SignToolDotNetTimeout Condition="'$(SignToolDotNetTimeout)' == ''">-1</SignToolDotNetTimeout>
118118

119+
<!-- Verbosity for DotNet MicroBuild build command. -->
120+
<SignToolMSBuildVerbosity Condition="'$(SignToolMSBuildVerbosity)' == ''">quiet</SignToolMSBuildVerbosity>
121+
119122
<NETCORE_ENGINEERING_TELEMETRY>Signing</NETCORE_ENGINEERING_TELEMETRY>
120123
</PropertyGroup>
121124

src/Microsoft.DotNet.SignTool.Tests/SignToolTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ private void ValidateGeneratedProject(
342342
// The path to DotNet will always be null in these tests, this will force
343343
// the signing logic to call our FakeBuildEngine.BuildProjectFile with a path
344344
// to the XML that store the content of the would be Microbuild sign request.
345-
var signToolArgs = new SignToolArgs(_tmpDir, microBuildCorePath: "MicroBuildCorePath", testSign: true, dotnetPath: null, _tmpDir, enclosingDir: "", "", wixToolsPath: wixToolsPath, tarToolPath: s_tarToolPath, pkgToolPath: s_pkgToolPath, dotnetTimeout: -1);
345+
var signToolArgs = new SignToolArgs(_tmpDir, microBuildCorePath: "MicroBuildCorePath", testSign: true, dotnetPath: null, msbuildVerbosity: "quiet", _tmpDir, enclosingDir: "", "", wixToolsPath: wixToolsPath, tarToolPath: s_tarToolPath, pkgToolPath: s_pkgToolPath, dotnetTimeout: -1);
346346

347347
var signTool = new FakeSignTool(signToolArgs, task.Log);
348348
var configuration = new Configuration(signToolArgs.TempDir, itemsToSign, strongNameSignInfo, fileSignInfo, extensionsSignInfo, additionalCertificateInfo, tarToolPath: s_tarToolPath, pkgToolPath: s_pkgToolPath, snPath: s_snPath, task.Log);

src/Microsoft.DotNet.SignTool/src/RealSignTool.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ internal sealed class RealSignTool : SignTool
2020
{
2121
private readonly string _dotnetPath;
2222
private readonly string _logDir;
23+
private readonly string _msbuildVerbosity;
2324
private readonly string _snPath;
2425
private readonly int _dotnetTimeout;
2526

@@ -38,6 +39,7 @@ internal RealSignTool(SignToolArgs args, TaskLoggingHelper log) : base(args, log
3839
{
3940
TestSign = args.TestSign;
4041
_dotnetPath = args.DotNetPath;
42+
_msbuildVerbosity = args.MSBuildVerbosity;
4143
_snPath = args.SNBinaryPath;
4244
_logDir = args.LogDir;
4345
_dotnetTimeout = args.DotNetTimeout;
@@ -57,7 +59,7 @@ public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath
5759
process.StartInfo = new ProcessStartInfo()
5860
{
5961
FileName = _dotnetPath,
60-
Arguments = $@"build ""{projectFilePath}"" -bl:""{binLogPath}""",
62+
Arguments = $@"build ""{projectFilePath}"" -v:""{_msbuildVerbosity}"" -bl:""{binLogPath}""",
6163
UseShellExecute = false,
6264
WorkingDirectory = TempDir,
6365
RedirectStandardOutput = true,

src/Microsoft.DotNet.SignTool/src/SignToolArgs.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ internal readonly struct SignToolArgs
99
internal string MicroBuildCorePath { get; }
1010
internal bool TestSign { get; }
1111
internal string DotNetPath { get; }
12+
internal string MSBuildVerbosity { get; }
1213
internal string SNBinaryPath { get; }
1314
internal string LogDir { get; }
1415
internal string EnclosingDir { get; }
@@ -17,12 +18,13 @@ internal readonly struct SignToolArgs
1718
internal string PkgToolPath { get; }
1819
internal int DotNetTimeout { get; }
1920

20-
internal SignToolArgs(string tempPath, string microBuildCorePath, bool testSign, string dotnetPath, string logDir, string enclosingDir, string snBinaryPath, string wixToolsPath, string tarToolPath, string pkgToolPath, int dotnetTimeout)
21+
internal SignToolArgs(string tempPath, string microBuildCorePath, bool testSign, string dotnetPath, string msbuildVerbosity, string logDir, string enclosingDir, string snBinaryPath, string wixToolsPath, string tarToolPath, string pkgToolPath, int dotnetTimeout)
2122
{
2223
TempDir = tempPath;
2324
MicroBuildCorePath = microBuildCorePath;
2425
TestSign = testSign;
2526
DotNetPath = dotnetPath;
27+
MSBuildVerbosity = msbuildVerbosity;
2628
LogDir = logDir;
2729
EnclosingDir = enclosingDir;
2830
SNBinaryPath = snBinaryPath;

src/Microsoft.DotNet.SignTool/src/SignToolTask.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ public class SignToolTask : BuildTask
123123
/// </summary>
124124
public string DotNetPath { get; set; }
125125

126+
/// <summary>
127+
/// Verbosity level for MSBuild.
128+
/// </summary>
129+
public string MSBuildVerbosity { get; set; } = "quiet";
130+
126131
/// <summary>
127132
/// Path to sn.exe. Required if strong name signing files locally is needed.
128133
/// </summary>
@@ -232,7 +237,7 @@ public void ExecuteImpl()
232237

233238
if (Log.HasLoggedErrors) return;
234239

235-
var signToolArgs = new SignToolArgs(TempDir, MicroBuildCorePath, TestSign, DotNetPath, LogDir, enclosingDir, SNBinaryPath, WixToolsPath, TarToolPath, PkgToolPath, DotNetTimeout);
240+
var signToolArgs = new SignToolArgs(TempDir, MicroBuildCorePath, TestSign, DotNetPath, MSBuildVerbosity, LogDir, enclosingDir, SNBinaryPath, WixToolsPath, TarToolPath, PkgToolPath, DotNetTimeout);
236241
var signTool = DryRun ? new ValidationOnlySignTool(signToolArgs, Log) : (SignTool)new RealSignTool(signToolArgs, Log);
237242

238243
var itemsToSign = ItemsToSign.Select(i => new ItemToSign(i.ItemSpec, i.GetMetadata(SignToolConstants.CollisionPriorityId))).OrderBy(i => i.CollisionPriorityId).ToList();

0 commit comments

Comments
 (0)