Skip to content

Commit

Permalink
Add /preservetimestamp command line option
Browse files Browse the repository at this point in the history
Preserve original file PE timestamp
  • Loading branch information
myhomeiot committed Dec 9, 2024
1 parent 0856f03 commit fbcafb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions ILRepack/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ allows dropping members denoted by this attribute name when merging
- /keepotherversionreferences
take reference assembly version into account when removing references
- /preservetimestamp preserve original file PE timestamp
- /skipconfig skips merging config files
- /illink merge IL Linker files
- /xmldocs merges XML documentation as well
Expand Down
8 changes: 6 additions & 2 deletions ILRepack/ILRepack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,14 @@ private void RepackCore(string tempOutputDirectory)
StrongNameKeyBlob = signingStep.KeyInfo?.KeyBlob,
WriteSymbols = Options.DebugInfo && symbolWriterProvider != null,
SymbolWriterProvider = symbolWriterProvider,
DeterministicMvid = true,
Timestamp = ComputeDeterministicTimestamp()
DeterministicMvid = true
};

if (!Options.PreserveTimestamp)
{
parameters.Timestamp = ComputeDeterministicTimestamp();
}

Logger.Verbose($"Writing temporary assembly: {tempOutputFilePath}");
TargetAssemblyDefinition.Write(tempOutputFilePath, parameters);

Expand Down
2 changes: 2 additions & 0 deletions ILRepack/RepackOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public string ExcludeFile
public IEnumerable<string> SearchDirectories { get; set; } = Array.Empty<string>();
public bool UnionMerge { get; set; }
public Version Version { get; set; }
public bool PreserveTimestamp { get; set; }
public bool SkipConfigMerge { get; set; }
public bool MergeIlLinkerFiles { get; set; }
public bool XmlDocumentation { get; set; }
Expand Down Expand Up @@ -260,6 +261,7 @@ void Parse()
var version = cmd.Option("ver");
if (!string.IsNullOrEmpty(version))
Version = new Version(version);
PreserveTimestamp = cmd.Modifier("preservetimestamp");
SkipConfigMerge = cmd.Modifier("skipconfig");
MergeIlLinkerFiles = cmd.Modifier("illink");
XmlDocumentation = cmd.Modifier("xmldocs");
Expand Down

0 comments on commit fbcafb5

Please sign in to comment.