Skip to content

Commit

Permalink
Added configuration for wait timeout of VerPatch.exe
Browse files Browse the repository at this point in the history
  • Loading branch information
yura-yaroshevich committed Jun 16, 2014
1 parent 8b2d185 commit d49bfa1
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion Fody/ModuleWeaver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using LibGit2Sharp;
using Mono.Cecil;

public class ModuleWeaver
{
private const string VerPatchWaitTimeoutConfigKey = "VerPatchWaitTimeoutInMilliseconds";

public XElement Config { get; set; }
public Action<string> LogInfo { get; set; }
public Action<string> LogWarning { get; set; }
public ModuleDefinition ModuleDefinition { get; set; }
Expand Down Expand Up @@ -136,6 +140,20 @@ TypeDefinition GetVersionAttribute()
return systemRuntime.MainModule.Types.First(x => x.Name == "AssemblyInformationalVersionAttribute");
}

Int32? GetVerPatchWaitTimeout()
{
var timeoutSetting = Config.Attributes().FirstOrDefault(attr => String.Equals(attr.Name.LocalName, VerPatchWaitTimeoutConfigKey));
if (timeoutSetting != null)
{
Int32 timeoutInMilliseconds;
if (Int32.TryParse(timeoutSetting.Value, out timeoutInMilliseconds) && timeoutInMilliseconds > 0)
{
return timeoutInMilliseconds;
}
}
return null;
}

public void AfterWeaving()
{
if (!dotGitDirExists)
Expand All @@ -157,7 +175,9 @@ public void AfterWeaving()
};
using (var process = Process.Start(startInfo))
{
if (!process.WaitForExit(1000))
var waitTimeoutInMilliseconds = GetVerPatchWaitTimeout().GetValueOrDefault(1000);
LogInfo(string.Format("Waiting {0} ms while verpatch.exe is processing assembly", waitTimeoutInMilliseconds));
if (!process.WaitForExit(waitTimeoutInMilliseconds))
{
var timeoutMessage = string.Format("Failed to apply product version to Win32 resources in 1 second.\r\nFailed command: {0} {1}", verPatchPath, arguments);
throw new WeavingException(timeoutMessage);
Expand Down

1 comment on commit d49bfa1

@vshteyn
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this is an old commit but how would you setup/increase timeout form default 100ms in say Web Application web config file? Thanks

Please sign in to comment.