Monday, August 9, 2010

Changing the Projects Version

The following code may be used in the Macro Studio. It will update the AssemblyInfo files to reflect them with a given version. When the files are required to be chacked out, it will happen automatically.

''' <summary>
''' For all projects in the solution,
''' change the version to a given version
''' </summary>
''' <remarks>some items in the solution might produce an exception
''' for istance if they are not loaded, or they have no vesion
''' </remarks>
Sub ChangeVersionProperties()
Dim sol = DTE.Solution
Dim projectT As EnvDTE.Project = sol.Projects.Item(1)
Dim newVersion As String = "1.200.0.9"

For Each project As EnvDTE.Project In sol.Projects
Try
Debug.Write(project.Name)
Debug.Write(
" changes from ")
Debug.Write(project.Properties.Item(
"AssemblyFileVersion").Value)
Debug.WriteLine(
" to " + newVersion)
project.Properties.Item(
"AssemblyFileVersion").let_Value(newVersion)
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(project.Name +
" kon niet gezet worden: " + ex.Message)
End Try
Next
End Sub

No comments: