Question

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...

Was it helpful?

Solution

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top