Skip to content

Commit

Permalink
[SignTool] Add msbuild verbosity option (#15582)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellahathaway authored Feb 25, 2025
1 parent 5b1e2d1 commit 55fcfd9
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.proj
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
PkgToolPath="$(PkgToolPath)"
RepackParallelism="$(SignToolRepackParallelism)"
MaximumParallelFileSize="$(SignToolRepackMaximumParallelFileSize)"
DotNetTimeout="$(SignToolDotNetTimeout)" />
DotNetTimeout="$(SignToolDotNetTimeout)"
MSBuildVerbosity="$(SignToolMSBuildVerbosity)" />
</Target>

</Project>
3 changes: 3 additions & 0 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/Sign.props
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@
<!-- Timeout in milliseconds for DotNet MicroBuild build command. '-1' is infinite. -->
<SignToolDotNetTimeout Condition="'$(SignToolDotNetTimeout)' == ''">-1</SignToolDotNetTimeout>

<!-- Verbosity for DotNet MicroBuild build command. -->
<SignToolMSBuildVerbosity Condition="'$(SignToolMSBuildVerbosity)' == ''">quiet</SignToolMSBuildVerbosity>

<NETCORE_ENGINEERING_TELEMETRY>Signing</NETCORE_ENGINEERING_TELEMETRY>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.DotNet.SignTool.Tests/SignToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ private void ValidateGeneratedProject(
// The path to DotNet will always be null in these tests, this will force
// the signing logic to call our FakeBuildEngine.BuildProjectFile with a path
// to the XML that store the content of the would be Microbuild sign request.
var signToolArgs = new SignToolArgs(_tmpDir, microBuildCorePath: "MicroBuildCorePath", testSign: true, dotnetPath: null, _tmpDir, enclosingDir: "", "", wixToolsPath: wixToolsPath, tarToolPath: s_tarToolPath, pkgToolPath: s_pkgToolPath, dotnetTimeout: -1);
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);

var signTool = new FakeSignTool(signToolArgs, task.Log);
var configuration = new Configuration(signToolArgs.TempDir, itemsToSign, strongNameSignInfo, fileSignInfo, extensionsSignInfo, additionalCertificateInfo, tarToolPath: s_tarToolPath, pkgToolPath: s_pkgToolPath, snPath: s_snPath, task.Log);
Expand Down
4 changes: 3 additions & 1 deletion src/Microsoft.DotNet.SignTool/src/RealSignTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal sealed class RealSignTool : SignTool
{
private readonly string _dotnetPath;
private readonly string _logDir;
private readonly string _msbuildVerbosity;
private readonly string _snPath;
private readonly int _dotnetTimeout;

Expand All @@ -38,6 +39,7 @@ internal RealSignTool(SignToolArgs args, TaskLoggingHelper log) : base(args, log
{
TestSign = args.TestSign;
_dotnetPath = args.DotNetPath;
_msbuildVerbosity = args.MSBuildVerbosity;
_snPath = args.SNBinaryPath;
_logDir = args.LogDir;
_dotnetTimeout = args.DotNetTimeout;
Expand All @@ -57,7 +59,7 @@ public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath
process.StartInfo = new ProcessStartInfo()
{
FileName = _dotnetPath,
Arguments = $@"build ""{projectFilePath}"" -bl:""{binLogPath}""",
Arguments = $@"build ""{projectFilePath}"" -v:""{_msbuildVerbosity}"" -bl:""{binLogPath}""",
UseShellExecute = false,
WorkingDirectory = TempDir,
RedirectStandardOutput = true,
Expand Down
4 changes: 3 additions & 1 deletion src/Microsoft.DotNet.SignTool/src/SignToolArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal readonly struct SignToolArgs
internal string MicroBuildCorePath { get; }
internal bool TestSign { get; }
internal string DotNetPath { get; }
internal string MSBuildVerbosity { get; }
internal string SNBinaryPath { get; }
internal string LogDir { get; }
internal string EnclosingDir { get; }
Expand All @@ -17,12 +18,13 @@ internal readonly struct SignToolArgs
internal string PkgToolPath { get; }
internal int DotNetTimeout { get; }

internal SignToolArgs(string tempPath, string microBuildCorePath, bool testSign, string dotnetPath, string logDir, string enclosingDir, string snBinaryPath, string wixToolsPath, string tarToolPath, string pkgToolPath, int dotnetTimeout)
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)
{
TempDir = tempPath;
MicroBuildCorePath = microBuildCorePath;
TestSign = testSign;
DotNetPath = dotnetPath;
MSBuildVerbosity = msbuildVerbosity;
LogDir = logDir;
EnclosingDir = enclosingDir;
SNBinaryPath = snBinaryPath;
Expand Down
7 changes: 6 additions & 1 deletion src/Microsoft.DotNet.SignTool/src/SignToolTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public class SignToolTask : BuildTask
/// </summary>
public string DotNetPath { get; set; }

/// <summary>
/// Verbosity level for MSBuild.
/// </summary>
public string MSBuildVerbosity { get; set; } = "quiet";

/// <summary>
/// Path to sn.exe. Required if strong name signing files locally is needed.
/// </summary>
Expand Down Expand Up @@ -232,7 +237,7 @@ public void ExecuteImpl()

if (Log.HasLoggedErrors) return;

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

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

0 comments on commit 55fcfd9

Please sign in to comment.