0

I'm trying to add additional data to each file I'm deploying to iis.

In particular I need to add a version number to each deployment file during the build process or to the deployed/packaged files.

So far the only solution I could come up with is to have a pre or post build event that effectively adds a comment to each file, mostly to the html, css and javascript files which includes the version number.

Doing this would be fairly simple but it seems fairly hacky and was wondering if anyone knew a better way.

The information doesn't need to be a comment, could be metadata or any other means, as long as the file has a record of the version number in there is all that matters.

The version number is generated by teamcity and is put on a file on the file system which is used to add to the assemblies generated.

Thanks.

2
  • Are you building any dll's? Or just using JIT? Commented Jan 23, 2015 at 19:55
  • I am building several assemblies which their version number is being set according to our version number. But we also wanted to add a version number tag to each deployed file. I'm using TeamCity and MsDeploy to do the deployments. We use MsDeploy to automatically deploy to an internal site but we also package it, so its ready for live deployment if it gets the all clear. Commented Jan 26, 2015 at 9:15

1 Answer 1

1

For non compiled assemblies...hacking in some commented out version info is as good as any other idea.

For compiled assemblies.....you can update the AssemblyFileVersion property.

MyRevision will be populated some Task related to your source-control. I commented out the svn version of this, your source-control (and some Task) should be able to do this. So for demo purposes, I hard-coded a MyRevision value.

http://msbuildtasks.tigris.org/ and/or https://github.com/loresoft/msbuildtasks has the ( FileUpdate and SvnVersion ) tasks.

  <Target Name="VersionTagItTarget">

    <ItemGroup>
      <AssemblyInfoFiles Include="$(ProjectDir)\**\*AssemblyInfo.cs" />
    </ItemGroup>

    <PropertyGroup>
        <MyRevision>999</MyRevision>
    </PropertyGroup>    

<!--
    <SvnVersion LocalPath="$(MSBuildProjectDirectory)" ToolPath="$(SVNToolPath)">
      <Output TaskParameter="Revision" PropertyName="MyRevision" />
    </SvnVersion>
    -->

    <FileUpdate Files="@(AssemblyInfoFiles)"
    Regex="AssemblyFileVersion\(&quot;(\d+)\.(\d+)\.(\d+)\.(\d+)"
    ReplacementText="AssemblyFileVersion(&quot;$1.$2.$3.$(MyRevision)" />
  </Target>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.