How to check if an assembly has changed

Is it possible to determine if the assembly has changed?

I have a standard project that generates an assembly called MyAssembly.dll.

In a separate project, I read the assembly and generate a hash.

When I generate a hash for the assembly, I recompile every time. I set the build version to be static, are there any other attributes that I need to change?

class Program
{
    static void Main(string[] args)
    {
        var array = File.ReadAllBytes(@"MyAssembly.dll");
        SHA256Managed algo = new SHA256Managed();
        var hash = algo.ComputeHash(array);

        Console.WriteLine(Convert.ToBase64String(hash));
    }
}

thanks

Rohan

+3
source share
4 answers

, . , , - . , , , , .pdb. , .

.pdb( .pdb , , pdb )

+4

, .

+2

Well, if this is the assembly you are managing, I would suggest adding a version number and automatically increasing the version number every time you build this assembly.

Then you can check the version number instead.

+1
source

This project seems to do the trick by parsing each file and discarding the GUID MVIDalong with several other bits before generating the MD5hash. It has a dependency on ildasm.exe .

0
source

Source: https://habr.com/ru/post/1711568/


All Articles