diff --git a/ILRepack/Application.cs b/ILRepack/Application.cs index 856c5546..0274b3e8 100644 --- a/ILRepack/Application.cs +++ b/ILRepack/Application.cs @@ -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 diff --git a/ILRepack/ILRepack.cs b/ILRepack/ILRepack.cs index 088415c8..12ad4283 100644 --- a/ILRepack/ILRepack.cs +++ b/ILRepack/ILRepack.cs @@ -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); diff --git a/ILRepack/RepackOptions.cs b/ILRepack/RepackOptions.cs index 4f3f9b8f..e5eeb388 100644 --- a/ILRepack/RepackOptions.cs +++ b/ILRepack/RepackOptions.cs @@ -75,6 +75,7 @@ public string ExcludeFile public IEnumerable SearchDirectories { get; set; } = Array.Empty(); 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; } @@ -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");