Вот что у меня есть на данный момент:
Код: Выделить всё
public class UpdateBinaryResource {
class VersionResourceUpdater
{
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr BeginUpdateResource(string pFileName, bool bDeleteExistingResources);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool UpdateResource(IntPtr hUpdate, IntPtr lpType, IntPtr lpName, ushort wLanguage, byte[] lpData, uint cbData);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool EndUpdateResource(IntPtr hUpdate, bool fDiscard);
[StructLayout(LayoutKind.Sequential)]
private struct VS_FIXEDFILEINFO
{
public uint dwSignature;
public uint dwStrucVersion;
public uint dwFileVersionMS;
public uint dwFileVersionLS;
public uint dwProductVersionMS;
public uint dwProductVersionLS;
public uint dwFileFlagsMask;
public uint dwFileFlags;
public uint dwFileOS;
public uint dwFileType;
public uint dwFileSubtype;
public uint dwFileDateMS;
public uint dwFileDateLS;
}
public static bool UpdateVersionInfo(string filePath, string productVersion, string fileVersion)
{
string[] fileVersionParts = fileVersion.Split('.');
string[] productVersionParts = productVersion.Split('.');
Console.WriteLine(fileVersionParts[0]);
// combine parts to 32-bit uInt
VS_FIXEDFILEINFO fileInfo = new VS_FIXEDFILEINFO
{
dwSignature = 0xFEEF04BD,
dwStrucVersion = 0x00010000,
dwFileVersionMS = (uint.Parse(fileVersionParts[0])
Подробнее здесь: [url]https://stackoverflow.com/questions/78560627/is-there-a-way-to-update-the-file-version-of-a-dll-file-without-rebuilding[/url]