Re: Set file version from powershell

1478 views
Skip to first unread message

Marco Shaw [MVP]

unread,
Mar 27, 2009, 11:28:15 AM3/27/09
to
David wrote:
> Is it possible to set a files "File Version" attribute from powershell. I
> want to loop through a directory and set the "File Version" attribute of all
> files within the directory to (lets say 1.0.0.1)

That seems to be a read-only property in .NET. I'll keep looking and
maybe someone else might have an idea...

Marco

--
*Microsoft MVP - Windows PowerShell
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com

Vadims Podans

unread,
Mar 27, 2009, 12:26:19 PM3/27/09
to
Yes, this property may be changed using these programs, such ResHacker or
Restorator. However I don't sure that this is good solution.
--
WBR, Vadims Podans
PowerShell blog - www.sysadmins.lv

"Marco Shaw [MVP]" <marco.shaw@NO_SPAMgmail.com> rakstīja ziņojumā
"news:ul026Cvr...@TK2MSFTNGP05.phx.gbl"...

Joel Bennett

unread,
Mar 28, 2009, 12:19:07 AM3/28/09
to
Uhm... I think this would be a good time to ask for a little bit more
clarification on what you're trying to accomplish.

Are you trying to *change* the file version on dlls or executables, or
set it on files that don't have a version already in hopes of tracking
something that way?
--
Joel "Jaykul" Bennett

Josh Einstein

unread,
Mar 29, 2009, 1:26:22 PM3/29/09
to
There's a .NET version (which is a part of the strong name, which is a part
of the IL metadata) and there's a Win32 version. A versioned .NET assembly
must be strong-named which means you can't change anything about the
assembly after it's compiled otherwise the signature would be invalid and
the assembly would fail to load.

The Win32 information (which is also applicable to .NET assemblies and
independent of the .NET version) can be changed by editing the appropriate
resource but the same caveat applies. If the file is signed, changing the
resource will break the signature.

And finally one last bit of useless trivia... even though the version of a
.NET assembly is added using the AssemblyVersionAttribute and
FileVersionAttribute, many developers are surprised to learn that these
attributes don't actually exist in the compiled assemblies. They are special
and are converted to the appropriate metadata by the compiler.

Josh

"Marco Shaw [MVP]" <marco.shaw@NO_SPAMgmail.com> wrote in message
news:ul026Cvr...@TK2MSFTNGP05.phx.gbl...

David

unread,
Apr 1, 2009, 4:08:02 AM4/1/09
to
I currently have a build process hosted within cruise control. All my
assemblies are versioned, built, unit tested, analysed with fxcop, archived
and deployed to development environment every night. One of the projects is
a web application that contains css, js, images. I want to set the version
of these files to the build number from cruise control so that all content
deployed to an environment is versioned. This allows me to run regular scans
on 5 environments for files that are no longer needed and can be removed.

Regards,
David

priyabha...@gmail.com

unread,
Mar 16, 2019, 3:48:32 AM3/16/19
to
I am also facing problem of setting version info after compilation. Iam ready to resign the files after changing version. But how to change version of executables is the question?
Reply all
Reply to author
Forward
0 new messages