I want to validate if there is source code difference occurred between two builds with help of .pdb files generated from Build1 and Build2.
Little Background :
I am using Visual Studio 2019 and My solution has a mix of .NET Framework, .NET Core projects summing up to 50 projects. I want a mechanism to validate if the source code has changed between two builds by comparing the .dll’s and/or .pdb’s from build1 and build2.
Note : The environment under which the source codes are built is the same.
What I want to achieve :
Whenever source code changes from versionX to versionY, Computer 1 builds the whole solution result of which is 50 dll’s and 50 pdb’s.
I want to skip the building process and copy only the changed dll’s and pdb’s and port it to Computer 2 after of checking out the source code to versionY to save time.
So, the tool I’m looking for should be capable of doing the following operations :
Compare two pdb’s output ‘true’ if the source code matches, ‘false’ is there seems to difference in source code. Plus: The tool can make use of the dll’s also.
2
Answers
You can use the Debug Interface Access SDK to achieve what you require.
Specifcally MS provide an example using IDiaDataSource::loadAndValidateDataFromPdb
Quote from MS site: "A .pdb file contains both signature and age values. These values are replicated in the .exe or .dll file that matches the .pdb file. Before preparing the data source, this method verifies that the named .pdb file’s signature and age match the values provided."
As the official document says:
How symbol files work
The pdb file contains the below information:
So I think the pdb will not be able to compare whether the source file of them are same. Because the content of it doesn’t have enough information.
But you can still get an approximate result (based on line number and offset).
Below is a console app sample for you to achieve your requirement(I am based on System.Reflection.Metadata):
The above code should be able to run directly.