tags:

views:

3058

answers:

4

Simple question... is there a way to change the Assembly Version of a compiled .NET assembly?

I'd actually be fine with a way to change the Assembly File Version.

+2  A: 

Why do you want to do this? If it's so that another application can use it, you might want to look into assembly binding redirection instead.

Jon Skeet
For deployment, we update the AssemblyInfo files and do a full rebuild, but that is getting too heavy, so we're moving to an incremental build. The problem is determining which AssemblyInfo's to update so right now we're not updating the version on the incrementals.
Mike
So, current possible solution I'm looking at is updating the Assembly File Version post-build so that everybody knows which build of the code you're looking at.
Mike
You want to use an incremental build for *deployment*? Yikes. How long does your build take, and how often do you deploy? I personally wouldn't be comfortable with that - I'd want a clean, full build (and test run) for deployment. Much easier to reproduce that way.
Jon Skeet
No, deployment will still be a full clean build. Please, give me some credit! Incremental is just for the continuous internal build. Problem becomes people don't know which build they're looking at/testing unless it's a full clean build with updated AssemblyInfo.
Mike
If it's only for internal purposes can you just include a version.txt file? Low tech but simple :)
Jon Skeet
You may want to edit some of this commentary into the original question, might be helpful.
GWLlosa
Our build is the same for both deployment and internal testing. That way we will never risk testing something that we aren't shipping out, or more importantly, shipping out something other than what we tested. That way we only have one place where the version numbers are updated.
Lasse V. Karlsen
A: 

It sounds like your process is heavy because you have to update multiple AssemblyInfo files. Have you considered sharing the same AssemblyInfo file between projects? Derik Whittaker gives a good example on how to do this.

Once you have a single file, you could then go the extra distance by having a build process update your single AssemblyInfo version using MSBuild or NAnt.

A: 

We'd (also) like to be able to do this so that a release of our mixed-mode (client-server main app, web-based reporting) application uses the same "file version number" for a full-on release. Given that the c/s app & web app build as needed, they do not necessarily end up at the same version number when we're ready to release.

It'd be nice if I could take already QA'd assemblies & use a "touch"-like command to update the assembly attributes. At the moment, I have to rebuild the web app to update them. This always makes our support folks nervous.

DaveE
+1  A: 

You can use ilmerge ILMerge.exe" Foo.dll /ver:1.2.3.4 /out:Foo2.dll

A valid reason to do this is to increment the assembly version in a build in you find breaking changes (using NDepend for example). That way if there are no breaking changes the assembly version stays the same, and you can patch released builds easily.

We always increment the file version, and that reflects the build number.

MarkGr