Getting file version of GAC entries
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2010
09:13 AM
08-20-2010
09:13 AM
Getting file version of GAC entries
Hi,
When we work on service packs or patches of our software, we are required to verify whether the file version of certain dll's have been updated as expected. To go through the whole list of files manually is very time consuming and error prone, so we decided to automate it.
I am able to use the GetFileVersion method of FileSystemObject without any issues for files that are present under the C:\Program Files\Application\Bin directory however; I would like to know of a similar approach to get the versions of the assemblies that get registered in the GAC when our application is installed.
As a workaround, I open the 'assembly' window and from the 'Run' window and read the contents of the 'Version' column to get the job done but it would be good to know a non-GUI based alternative like the one above.
Thanks and Regards,
GJ
When we work on service packs or patches of our software, we are required to verify whether the file version of certain dll's have been updated as expected. To go through the whole list of files manually is very time consuming and error prone, so we decided to automate it.
I am able to use the GetFileVersion method of FileSystemObject without any issues for files that are present under the C:\Program Files\Application\Bin directory however; I would like to know of a similar approach to get the versions of the assemblies that get registered in the GAC when our application is installed.
As a workaround, I open the 'assembly' window and from the 'Run' window and read the contents of the 'Version' column to get the job done but it would be good to know a non-GUI based alternative like the one above.
Thanks and Regards,
GJ
3 REPLIES 3
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2010
07:38 PM
08-20-2010
07:38 PM
dotNET.System_Reflection.Assembly.LoadFrom(FILE_NAME).GetName().Version.ToString()
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2010
10:33 PM
08-22-2010
10:33 PM
Hi GJ,
There is no built-in way to do this in TestComplete as well as in the .NET Framework. However, it is possible to get this information using the 'Gacutil' tool which is shipped along with the .NET Framework SDK. This SDK is installed along with Visual Studio or with the SDK of the operating system. The below script demonstrates how this tool can be used in TestComplete.
function test()
{
// var items = getInstalledAssembliesList(); // Get all assemblies
var items = getInstalledAssembliesList("MyCompany.MyNamespace.MyAssembly");
Log.Message("Total " + items.length + " assemblies");
for (var i = 0; i < items.length; i++) {
Log.Message(items.Name, items.Version + "\r\n" + items.Culture + "\r\n" + items.PublicKeyToken);
}
}
function getInstalledAssembliesList(assemblyName)
{
if (null == assemblyName) {
assemblyName = "";
}
var gacutilPath = "\"c:\\Program Files\\Microsoft SDKs\\Windows\\v7.0\\Bin\\gacutil.exe\"";
var header = "The Global Assembly Cache contains the following assemblies:";
var footer = "Number of items =";
var WshShellObj = new ActiveXObject("WScript.Shell");
var WshShellExecObj = WshShellObj.Exec(gacutilPath + " /l " + assemblyName);
var out = "";
while (!WshShellExecObj.StdOut.AtEndOfStream) {
out += WshShellExecObj.StdOut.Read(1);
}
var strList = aqString.Trim(out.match(new RegExp("^.*" + header + "((\\s|\\S)*)" + footer + ".*$", "im"))[1]);
var strArr = strList.split("\r\n");
var assembliesList = new Array();
for (var i = 0; i < strArr.length; i++) {
var line = strArr.split(",");
var item = new Object();
item.Name = aqString.Trim(line[0]);
item.Version = aqString.Trim(line[1].split("=")[1]);
item.Culture = aqString.Trim(line[2].split("=")[1]);
item.PublicKeyToken = aqString.Trim(line[3].split("=")[1]);
assembliesList.push(item);
}
return assembliesList;
}
--
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Dmitry Nikolaev
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2010
12:21 PM
08-24-2010
12:21 PM
Hi,
Thanks to both of you for posting a suggestion ... I'll try them out and let you know my observations.
Regardx,
GJ
Thanks to both of you for posting a suggestion ... I'll try them out and let you know my observations.
Regardx,
GJ
