0

I'm trying to update/add some RC information in DLL directly from the Powershell.

I have found how I can get it but I didn't found how set some field like SpecialBuild or PrivateBuild.

PS C:\> (gi .\mydll.dll).VersionInfo | fl

OriginalFilename  : mydll.dll
FileDescription   : mydll.dll
...............................
PrivateBuild      : 32572
SpecialBuild      : NOT_HOTFIX
FileVersionRaw    : 17.3.0.12013
ProductVersionRaw : 17.3.0.12013

PS C:\> (gi .\mydll.dll).VersionInfo | gm


   TypeName : System.Diagnostics.FileVersionInfo

Name               MemberType     Definition
----               ----------     ----------
Equals             Method         bool Equals(System.Object obj)
GetHashCode        Method         int GetHashCode()
GetType            Method         type GetType()
ToString           Method         string ToString()
Comments           Property       string Comments {get;}
.................................................
PrivateBuild       Property       string PrivateBuild {get;}
ProductBuildPart   Property       int ProductBuildPart {get;}
ProductMajorPart   Property       int ProductMajorPart {get;}
ProductMinorPart   Property       int ProductMinorPart {get;}
ProductName        Property       string ProductName {get;}
ProductPrivatePart Property       int ProductPrivatePart {get;}
ProductVersion     Property       string ProductVersion {get;}
SpecialBuild       Property       string SpecialBuild {get;}
FileVersionRaw     ScriptProperty System.Object FileVersionRaw {get=New-Object System.Version -ArgumentList @(...
ProductVersionRaw  ScriptProperty System.Object ProductVersionRaw {get=New-Object System.Version -ArgumentList @(...

As you can see, properties are get only here.

So do you know how I can update theses fields ?

Thanks in advance for your help ;)

David
  • 1,177
  • 3
  • 11
  • 26

1 Answers1

1

Update fields possible with a tool like Resource Hacker, or verpatch, but it's not recommended. If the dll is yours, it's much easier to update it before compilation.

One of the downsides of patching compiled dll is that if it's signed, the signature will no longer be valid. Also, sometimes patching may result in a corrupted dll.

Is there any particular reason why you want to change it after compilation?

Andrey Marchuk
  • 13,301
  • 2
  • 36
  • 52
  • I already use verpatch to update DLL during my build pipeline ;). But here, it's just for my knowledge . I just want to known if this is possible without other tools or some code, directly from PS. – David Oct 28 '16 at 12:29
  • 1
    No, it's not possible and highly discouraged to do in general, unless you have a very good reason. – Andrey Marchuk Oct 28 '16 at 12:29
  • OK, so what is the good way to update the build number in an automatic build process ? Update the rc file before build with some regex ? – David Oct 28 '16 at 13:53
  • Yes. It depends on what platform you are using (.Net or Java or C++), as well as your build server. Each of the platforms and pretty much each of the build servers have the possibility to set this information. – Andrey Marchuk Oct 28 '16 at 15:31