IAdapter
IAdapter

Reputation: 64707

How to set the version of a project in VS?

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

Upvotes: 5

Views: 20175

Answers (2)

Martin Buberl
Martin Buberl

Reputation: 47114

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.

Upvotes: 1

Jaroslav Jandek
Jaroslav Jandek

Reputation: 9563

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)" />

Upvotes: 6

Related Questions