get real product version in c# -


this may seem straight forward, however, typical methods version grab version info needs manually set, , not build versions publish.

this results in (if never go properties , change value deep inside project settings), version returning 1.0.0.0. in fact, version shows when right click compiled .net exe inside of publish folders. example :

/publish/1.0.0.2/foo.exe

the properties show 1.0.0.0, though build 1.0.0.2.

i willing accept solution either of following :

  1. automatically set actual file version current version on publish.
  2. obtain actual version (not 1.0.0.0) using c#.

not looking hack add own versioning system. use mechanisms built in (and working in predecessors .net).

for added clarification, seems auto-versioning garbage in .net, , instead of using publish version, using versions inside

properties > application > [assembly information] enter image description here

thanks in advance :)

i think solution:

using system.reflection;  ....  string path = assembly.getexecutingassembly().location; fileversioninfo versioninfo = fileversioninfo.getversioninfo(path);  return fvi.fileversion; // type: string 

this piece of code returns version of assembly set inside manifest-file. works retrieving assembly version of nativ application/library


edit: adv12 wrote previously, updated solution:

using system.deployment;  ...  if (applicationdeployment.isnetworkdeployed)     return applicationdeployment.currentdeployment.currentversion.tostring(4)); 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -