Just how do I sync the SVN alteration number with my ASP.NET internet site?
We do this with xUnit.net for our automated builds. We make use of
CruiseControl.net (and also are experimenting with TeamCity). The MSBuild job that we compete continual assimilation instantly transforms the construct number for us, so the resulting construct ZIP documents has an effectively versioned set of DLLs and also EXEs.
Our MSBuild file has a UsingTask reference for a DLL which does normal expression substitutes : (you rate to utilize this DLL, as it is covered by the MS - PL certificate too)
<UsingTask AssemblyFile="3rdParty\CodePlex.MSBuildTasks.dll" TaskName="CodePlex.MSBuildTasks.RegexReplace"/>
Next, we extract the construct number, which is given instantly by the CI system. You can additionally get your resource control carrier to give the resource alteration number if you desire, yet we located the construct # in the CI system was better, due to the fact that not just can see the assimilation results by the CI construct number, that additionally gives a link back to the changeset (s) which were consisted of in the construct.
<!-- Cascading attempts to find a build number --> <PropertyGroup Condition="'$(BuildNumber)' == ''"> <BuildNumber>$(BUILD_NUMBER)</BuildNumber> </PropertyGroup> <PropertyGroup Condition="'$(BuildNumber)' == ''"> <BuildNumber>$(ccnetlabel)</BuildNumber> </PropertyGroup> <PropertyGroup Condition="'$(BuildNumber)' == ''"> <BuildNumber>0</BuildNumber> </PropertyGroup>
(We attempt BUILD_NUMBER, which is from TeamCity, after that ccnetlabel, which is from CC.net, and also if neither exists, we fail to 0, to make sure that we can examine the automated construct manuscript by hand.)
Next, we have a job which establishes the construct number right into a GlobalAssemblyInfo.cs documents that we link right into every one of our tasks :
<Target Name="SetVersionNumber"> <RegexReplace Pattern='AssemblyVersion\("(\d+\.\d+\.\d+)\.\d+"\)' Replacement='AssemblyVersion("$1.$(BuildNumber)")' Files='GlobalAssemblyInfo.cs'/> <Exec Command="attrib -r xunit.installer\App.manifest"/> </Target>
This locate the AssemblyVersion feature, and also changes the a.b.c.d variation number with a.b.c.BuildNumber. We will generally leave the resource explored the tree with the first 3 components of the building contractor number dealt with, and also the 4th at absolutely no (f.e., today it is 184.108.40.206).
In your construct procedure, see to it the SetVersionNumber job precedes your construct job. At the end, we utilize our Zip job to whiz up the construct outcomes to make sure that we have a background of the binaries for every single automated construct.
$rev and also others like it are alterations for the specific documents, so they will not transform unless the documents adjustments. The number on the page is (more than likely, I'm thinking below) the svn alteration number for the entire task. That is various than the documents alterations, which others have actually been indicating.
In this instance I think that CCNET is drawing the alteration variety of the task and also revising a component of the page with that said number. Any kind of CI remedy need to have the ability to do this, set this up myself with CCNET and also Teamcity (although not pages, yet automated versioning of deployment/assembly variations).
In order for you to do this, make use of a CI remedy that sustains it, or utilize your construct procedure (MSbuild/Nant) to store that variation and also write it to the documents prior to "releasing" it.
You can do it by including the adhering to throughout your code
So as an example @Jeff did :
<div id="svnrevision">svn revision: $Id:$</div>
and also when signed in the web server changed $Id :$ with the existing alteration number. I additionally found this reference.
There is additionally $ Date :$ , $ Rev :$ , $ Revision :$