Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Microsoft.DotNet.SignTool.Tests/FakeSignTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override SigningStatus VerifySignedPEFile(Stream stream)

public override SigningStatus VerifyStrongNameSign(string fileFullPath) => SigningStatus.Signed;

public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath)
public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath, bool suppressErrors = false)
=> buildEngine.BuildProjectFile(projectFilePath, null, null, null);

internal static void SignFile(string path)
Expand Down
15 changes: 11 additions & 4 deletions src/Microsoft.DotNet.SignTool/src/RealSignTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal RealSignTool(SignToolArgs args, TaskLoggingHelper log) : base(args, log
_dotnetTimeout = args.DotNetTimeout;
}

public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath)
public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath, bool suppressErrors = false)
{
if (_dotnetPath == null)
{
Expand Down Expand Up @@ -80,16 +80,23 @@ public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath
bool success = true;
if (!process.WaitForExit(_dotnetTimeout))
{
_log.LogError($"MSBuild process did not exit within '{_dotnetTimeout}' ms.");
if (suppressErrors)
_log.LogMessage(MessageImportance.High, $"MSBuild process did not exit within '{_dotnetTimeout}' ms.");
else
_log.LogError($"MSBuild process did not exit within '{_dotnetTimeout}' ms.");
process.Kill();
process.WaitForExit();
success = false;
}

if (process.ExitCode != 0)
{
_log.LogError($"Failed to execute MSBuild on the project file '{projectFilePath}'" +
$" with exit code '{process.ExitCode}'.");
if (suppressErrors)
_log.LogMessage(MessageImportance.High, $"Failed to execute MSBuild on the project file '{projectFilePath}'" +
$" with exit code '{process.ExitCode}'.");
else
_log.LogError($"Failed to execute MSBuild on the project file '{projectFilePath}'" +
$" with exit code '{process.ExitCode}'.");
success = false;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Microsoft.DotNet.SignTool/src/SignTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal SignTool(SignToolArgs args, TaskLoggingHelper log)

public abstract SigningStatus VerifyStrongNameSign(string fileFullPath);

public abstract bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath);
public abstract bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath, bool suppressErrors = false);

public bool Sign(IBuildEngine buildEngine, int round, IEnumerable<FileSignInfo> files)
{
Expand Down Expand Up @@ -191,7 +191,7 @@ private bool AuthenticodeSignAndNotarize(IBuildEngine buildEngine, int round, IE
{
var notarizeProjectPath = Path.Combine(dir, $"Round{round}-Notarize.proj");
File.WriteAllText(notarizeProjectPath, GenerateBuildFileContent(filesToNotarize, null, true));

// Notarization can be flaky, so retry up to 5 times with no wait between retries
const int maxRetries = 5;
int attempt = 0;
Expand All @@ -208,7 +208,8 @@ private bool AuthenticodeSignAndNotarize(IBuildEngine buildEngine, int round, IE
notarizationSucceeded = RunMSBuild(buildEngine, notarizeProjectPath,
Path.Combine(_args.LogDir, $"{notarizeLogName}.binlog"),
Path.Combine(_args.LogDir, $"{notarizeLogName}.log"),
Path.Combine(_args.LogDir, $"{notarizeLogName}.error.log"));
Path.Combine(_args.LogDir, $"{notarizeLogName}.error.log"),
suppressErrors: attempt < maxRetries);

if (!notarizationSucceeded && attempt < maxRetries)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override SigningStatus VerifySignedPEFile(Stream assemblyStream)
public override SigningStatus VerifyStrongNameSign(string fileFullPath)
=> SigningStatus.Signed;

public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath)
public override bool RunMSBuild(IBuildEngine buildEngine, string projectFilePath, string binLogPath, string logPath, string errorLogPath, bool suppressErrors = false)
{
if (TestSign)
{
Expand Down
Loading