Discussion:
Set file version from powershell
(too old to reply)
David
2009-03-27 09:42:01 UTC
Permalink
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)
Marco Shaw [MVP]
2009-03-27 15:28:15 UTC
Permalink
Post by David
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
2009-03-27 16:26:19 UTC
Permalink
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
Post by Marco Shaw [MVP]
Post by David
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
Josh Einstein
2009-03-29 17:26:22 UTC
Permalink
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
Post by Marco Shaw [MVP]
Post by David
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
p***@gmail.com
2019-03-16 07:48:30 UTC
Permalink
Post by Josh Einstein
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
Post by Marco Shaw [MVP]
Post by David
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
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?
Joel Bennett
2009-03-28 04:19:07 UTC
Permalink
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
Post by David
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)
David
2009-04-01 08:08:02 UTC
Permalink
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
Post by Joel Bennett
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
Post by David
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)
Continue reading on narkive:
Loading...