Kinook Software Forum

Go Back   Kinook Software Forum > Visual Build Professional > [VBP] Third Party Tools
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 06-16-2004, 10:57 AM
shuttledude shuttledude is offline
Registered User
 
Join Date: 06-16-2004
Posts: 3
Question Assigning File Version of .NET Assembly

How do I use Visual Build Pro to (1) obtain the Assembly Version of a .NET assembly, and (2) assign that value to the same assembly's "File Version" property.

When we build our .NET programs the Assembly version is always automatically updated. But, the File Version is "stuck" at 1.0.0.3 . This is causing problems with our installation program, which is now set to update existing files by version. Unfortunately, it's an older installation product that cannot discern between Assembly version and File version.

I suppose I could change the install program to force an overwrite of every file regardless of version or date, but I'm wondering if there's a less forceful way.

An alternative approach is to somehow get the Visual Studio compiler to assign the File Version value, but I'm not sure how to do that either.

It would be best to know how to do this both ways (Visual BuildPro and Visual Studio .NET).

Thanks in advance for any suggestions.
Reply With Quote
  #2  
Old 06-16-2004, 02:39 PM
kinook kinook is online now
Administrator
 
Join Date: 03-06-2001
Location: Colorado
Posts: 6,034
Use the VS.NET Get Version action to retrieve the assembly version from a VS.NET project or AssemblyInfo file. Or see this post if you need to retrieve the version from a compiled assembly: http://www.kinook.com/Forum/showthread.php?threadid=403

Use the Make VS.NET action to update the File version of a VS.NET project, solution, or AssemblyInfo file. See this post for how to handle differing file/assembly/product versions: http://www.kinook.com/Forum/showthread.php?threadid=371

See the help topics on those actions for more details, and/or the samples that use them (GetProjVer.bld and VStudio.bld).
Reply With Quote
  #3  
Old 06-16-2004, 03:19 PM
shuttledude shuttledude is offline
Registered User
 
Join Date: 06-16-2004
Posts: 3
Found part of the answer...

To partially answer my own question, I have since discovered this:

Visual Build Pro approach:

In the .NET build step on the "Versions" tab, select the radio button "Set the project version to a specific value before building", and in the edit box put something like 1.0.0.%BUILDNUM% . Also, select these two check boxes: "Update the File version" and "Update the Assembly version". Thus, the .NET assembly's "Assembly version" and "File version" will now be the same, and set to a value that you have determined at build time, controlled by a Visual Build Pro macro.

.NET compiler approach:

I have started to write a utility program that (a) loads a user-specified assembly, (b) examines the assembly version and file version info., and (c) sets the file version to be the value of the assembly version. Here is the Visual C# code for parts (a) and (b) -- can anyone help me with the code for part (c)?

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Diagnostics; // for FileVersionInfo
.
.
.
// Get the assembly information and display to the console.
string thefile = "C:/MyAssembly.dll";

// Get the file's "Assembly Version" information
AssemblyName myAssemblyName = AssemblyName.GetAssemblyName(thefile);
string assemblyver = myAssemblyName.Version.ToString();
Console.WriteLine("\nThe assembly version is:");
Console.WriteLine(assemblyver);

// Note: if you want to see "all the info." instead of just the assembly version:
// Console.WriteLine("\nDisplaying the assembly information of 'core.dll'\n");
// Console.WriteLine(myAssemblyName.ToString());

// Get the file's "File Version" information
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(thefile);
string results = "\nThe file version is:\n" + myFileVersionInfo.FileVersion;
Console.WriteLine(results);

// Set the "File Version" to the same value as the "Assembly Version"
// ??? how to do this?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT -5. The time now is 05:27 PM.


Copyright © 1999-2023 Kinook Software, Inc.