views:

226

answers:

1

I have a Visual Studio 2008 Solution where the main output exe is a VB.Net Winforms exe which has several VB.Net and C# dll's linked from the same solution. The whole solution is under version control with subversion.

Now I want to automagically update by generated files with the current svn revision number. For this purpose I found this neat project: http://svnversiontasks.codeplex.com/ You also need the MSBuild.Communuity.Tasks for this to work.

There was a msbuild example on how to update the rev number for every single project in your solution which I use:

  <Import Project="$(MSBuildExtensionsPath)\SvnTools.Targets\SvnTools.Tasks.VersionManagement.Tasks" />
  <Target Name="build">
    <CreateItem Include="../**/AssemblyInfo.vb;../**/AssemblyInfo.cs;../**/Properties/AssemblyInfo.cs">
      <Output TaskParameter="Include" ItemName="AssemblyInfoFiles" />
    </CreateItem>
    <CreateItem Include="../**/*.vdproj;*.vdproj">
      <Output TaskParameter="Include" ItemName="DeploymentProjectFiles" />
    </CreateItem>
    <UpdateVersion AssemblyInfoFiles="@(AssemblyInfoFiles)" DeploymentProjectFiles="@(DeploymentProjectFiles)" Format="yyyy.mm.dd.rev" />
    <Exec Command="&quot;$(VS90COMNTOOLS)..\IDE\devenv&quot; ..\MyApp.sln /build" />
    <RevertVersionChange AssemblyInfoFiles="@(AssemblyInfoFiles)" DeploymentProjectFiles="@(DeploymentProjectFiles)" />
  </Target>

I modified the original file to also include the AssemblyInfo.vb file and saved it as a msbuild.proj file.

However if I execute msbuild from the console I see that the C# projects are updated (I can also confirm that from the properties of the output dll but my vb project remains unchanged:

  Reverting version number change: ../App1\AssemblyInfo.vb
  Updating version number (to rev 0) for file: ../App1\AssemblyInfo.vb
D:\Source\MyApp\MyAppDeploy\MyAppDeploy.csproj : warning : Version attribute not found, file not updated.

  Reverting version number change: ../App2\Properties\AssemblyInfo.cs
  Updating version number (to rev 0) for file: ../App2\Properties\AssemblyInfo.cs
  Successfully updated file.

Maybe the task does not support VB.Net. But maybe someone has a solution for this...

A: 

If you look into UpdateVersion task source code you should that it uses Regex to parse the AssemblyInfo file so it's not surprising if it doesn't work with vb file.

You could do what you want, only using MSBuild.Community.Tasks :

  • SvnVersion to get the Revision (You could also use the SvnGetProperty task from SvnVersionTasks)
  • AssemblyInfo to generate the assembly info with the right version. This tasks handle VB.
madgnome
I know, currently I am using SvnVersion to update my project (sorry I didn't mentioned that) but since the AssemblyInfo files are in the repo, they are allways marked as changed. And Svn Version Task has also a support for deployment projects.
SchlaWiener
Ok, the hint with the AssemblyInfo task was a good idea. Now I set the revision to my svn-revision before build and back to zero after build so the file is unchanged if I commit my changes.
SchlaWiener