5

I want to be able to use the AssemblyIdentities.Version in my msbuild, how do I set/change it?

IAdapter
  • 62,595
  • 73
  • 179
  • 242

2 Answers2

6

Right-click Project->Properties->Assembly Information or (when have already created the properties) in project manager Properties->AssemblyInfo.cs.

Edit: For auto-modification from msbuild, you can use:

<FileUpdate Files="AssemblyInfo.cs"
   Regex="(\d+)\.(\d+)\.(\d+)\.(\d+)"
   ReplacementText="$1.$2.$3.$(Revision)" />
Jaroslav Jandek
  • 9,463
  • 1
  • 28
  • 30
  • I think IAdapter is looking to set the version in an msbuild invocation – David Heffernan Feb 12 '11 at 21:01
  • @David: Thanks, I have missed it at the first glance. Although it's pretty much the same as modding it manually. @IAdapter: You can auto-generate the whole AssemblyInfo.cs if you want ;) – Jaroslav Jandek Feb 12 '11 at 21:04
  • There is one more thing you should take in attention. Third component of the version is usually used to change current version of assembly/product/... Forth component can be used as a marker of internal build number, or as a way to provide updates for old assembly without version conflicts. – Sergio Rykov Feb 14 '11 at 14:43
1

You do it with the GetAssemblyIdentity task:

<Target Name="Version">
  <GetAssemblyIdentity
      AssemblyFiles="$(MSBuildProjectDirectory)\src\MyApp\bin\MyApp.exe">
  <Output
      TaskParameter="Assemblies"
      ItemName="AssemblyIdentities"/>
  </GetAssemblyIdentity>
  ...
</Target>

AssemblyIdentities is just a variable name. It could also be named MyAssemblyIdentities like in the MSDN link. The Version property reads the Version from your AssemblyInfo.cs.

Also this SO answer provides some examples on how to use GetAssemblyIdentity.

Community
  • 1
  • 1
Martin Buberl
  • 45,844
  • 25
  • 100
  • 144