Using Automaton w/AssemblyInfoTask

Topics: Developer Forum, User Forum
Mar 7, 2007 at 2:21 PM
Does anybody have a way to make this work? I've tried adding code to do checkin/checkout, but it basically throws me into an infinite CI loop, as every time the assembly info file is checked in, it fires off a CI...

ANY help would be appreciated...

Thanks
Larry
Mar 12, 2007 at 1:45 PM
Hmm thats interesting...you might try something like this...look at the user name that the assembly info file is checked in under - perhaps something like 'tfsservice' or 'tfsbuild'. What we want to do is to block this account from kicking off a Continuous Integration Build.

Programmatically, one can use one of the inbuilt filters for this. Lets say our exclusive account TFSx caused the assembly info checkin, then when the owner or committer is TFSx: don't kick off a build.

So in the TeamEvents portion of the code, where Automaton has the subscribe event, you would want to set up a filter to the checkin event, something like:
FilterString = "\"Owner\"<>'Domain\\"+"TFSx' OR \"Committer\"<>'Domain\\" +"TFSx'";

That way we filter TFSx out and this could stop the infinite looping. If Automaton causes the checkin to the AssemblyInfo file then we want to blot out the Automaton account.

Hope this helps.
Developer
Mar 15, 2007 at 1:29 AM
Hi Larry,

We had the same problem with CI (http://msdn2.microsoft.com/en-us/library/ms364045(vs.80).aspx) before, but not with Automaton. Shinichi's solution was the one that we used to resolve this issue.

Currently, we use AssemblyInfo Task together with Automaton, and they two work peacefully together. We didn't do anything special. I attached the customization portion of the .proj file below for your reference. Hope this helps.

<!--Set Version Number-->
<PropertyGroup>
<!-- Assembly version properties. Add others here AutoIncrement-->
<AssemblyBuildNumberType>AutoIncrement</AssemblyBuildNumberType>
<AssemblyBuildNumberFormat>0000</AssemblyBuildNumberFormat>
<AssemblyRevisionType>DateString</AssemblyRevisionType>
<AssemblyRevisionFormat>MMddy</AssemblyRevisionFormat>
<AssemblyMajorVersion>00</AssemblyMajorVersion>
<AssemblyMinorVersion>01</AssemblyMinorVersion>
<AssemblyBuildNumber></AssemblyBuildNumber>
<AssemblyRevision></AssemblyRevision>

<AssemblyFileBuildNumberType>AutoIncrement</AssemblyFileBuildNumberType>
<AssemblyFileBuildNumberFormat>0000</AssemblyFileBuildNumberFormat>
<AssemblyFileRevisionType>DateString</AssemblyFileRevisionType>
<AssemblyFileRevisionFormat>MMddy</AssemblyFileRevisionFormat>
<AssemblyFileMajorVersion>00</AssemblyFileMajorVersion>
<AssemblyFileMinorVersion>01</AssemblyFileMinorVersion>
<AssemblyFileBuildNumber></AssemblyFileBuildNumber>
<AssemblyFileRevision></AssemblyFileRevision>

<!-- TF.exe -->
<TF>"$(TeamBuildRefPath)\..\tf.exe"</TF>
<!-- AssemblyInfo file spec -->
<AssemblyInfoSpec>AssemblyInfo.cs</AssemblyInfoSpec>
</PropertyGroup>
<!-- Set this to non-existent file to force rebuild. -->
<ItemGroup>
<IntermediateAssembly Include="$(SolutionRoot)\foobar.dll" />
</ItemGroup>

<!-- Import the task -->
<UsingTask AssemblyName="AssemblyInfoTask, Version=1.0.51130.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" TaskName="AssemblyInfo" />

<!--Get changesets/workitems belonging to a particular sub folder (only)-->
<PropertyGroup>
<GetChangesetForFolder>Source/YourProject</GetChangesetForFolder>
</PropertyGroup>
<Target Name="CoreLabel" Condition=" '$(IsDesktopBuild)'!='True'" DependsOnTargets="$(CoreLabelDependsOn)">
<!-- Label all the latest non deleted files in workspace -->
<Label Condition=" '$(SkipLabel)'!='True'" Workspace="$(WorkspaceName)" Name="$(BuildNumber)" Version="W$(WorkspaceName)" Files="$/$(TeamProject)/$(GetChangesetForFolder)" Child="$(ChildLabel)" Comments="$(LabelTaskComment)" Recursive="True" />
</Target>

<!-- In case of Build failure, the AfterCompile target is not executed. Undo the changes -->
<Target Name="BeforeOnBuildBreak" Condition="'$(IsDesktopBuild)'!='true'">
<CreateItem Include="$(SolutionRoot)\Source\YourProject\**\Properties\$(AssemblyInfoSpec)">
<Output ItemName="AssemblyInfoFiles" TaskParameter="Include" />
</CreateItem>
<Exec WorkingDirectory="$(SolutionRoot)" Command="$(TF) undo /noprompt /recursive $(AssemblyInfoSpec)" />
</Target>

<!--Get the latest for all the AssemblyInfo.cs files -->
<Target Name="BeforeClean" Condition="'$(IsDesktopBuild)'!='true'">
<CreateItem Include="$(SolutionRoot)\Source\YourProject\**\Properties\$(AssemblyInfoSpec)">
<Output ItemName="AssemblyInfoFiles" TaskParameter="Include" />
</CreateItem>
<Exec WorkingDirectory="$(SolutionRoot)" Command="$(TF) checkin /comment:"Auto-Build: Version Update" /noprompt /override:"Auto-Build: Version Update" /recursive /notes:"Promise to do smoke test (Y/N)?"="Y";"Put in your checkin comments yet (Y/N)?"="Y" $(AssemblyInfoSpec)" />
</Target>

<!-- Update AssemblyInfo and Return max version number -->
<Target Name="UpdateAssemblyInfoFiles_ForTFS">
<CreateItem Include="$(SolutionRoot)\Source\YourProject\**\Properties\$(AssemblyInfoSpec)">
<Output ItemName="AssemblyInfoFiles" TaskParameter="Include" />
</CreateItem>
<Exec WorkingDirectory="$(SolutionRoot)" Command="$(TF) get $(AssemblyInfoSpec) /force /recursive /noprompt" />
<Exec WorkingDirectory="$(SolutionRoot)" Command="$(TF) checkout /recursive $(AssemblyInfoSpec)" />
<AssemblyInfo AssemblyInfoFiles="@(AssemblyInfoFiles)"
AssemblyMajorVersion="$(AssemblyMajorVersion)"
AssemblyMinorVersion="$(AssemblyMinorVersion)"
AssemblyBuildNumber="$(AssemblyBuildNumber)"
AssemblyRevision="$(AssemblyRevision)"
AssemblyBuildNumberType="$(AssemblyBuildNumberType)"
AssemblyBuildNumberFormat="$(AssemblyBuildNumberFormat)"
AssemblyRevisionType="$(AssemblyRevisionType)"
AssemblyRevisionFormat="$(AssemblyRevisionFormat)"
AssemblyFileMajorVersion="$(AssemblyFileMajorVersion)"
AssemblyFileMinorVersion="$(AssemblyFileMinorVersion)"
AssemblyFileBuildNumber="$(AssemblyFileBuildNumber)"
AssemblyFileRevision="$(AssemblyFileRevision)"
AssemblyFileBuildNumberType="$(AssemblyFileBuildNumberType)"
AssemblyFileBuildNumberFormat="$(AssemblyFileBuildNumberFormat)"
AssemblyFileRevisionType="$(AssemblyFileRevisionType)"
AssemblyFileRevisionFormat="$(AssemblyFileRevisionFormat)">
<Output TaskParameter="MaxAssemblyVersion" PropertyName="MaxAssemblyVersion" />
<Output TaskParameter="MaxAssemblyFileVersion" PropertyName="MaxAssemblyFileVersion" />
</AssemblyInfo>
</Target>
Mar 15, 2007 at 2:19 PM
Yep, ideally we shouldn't have to filter on anything and there should only be one associated build - no infinite loops. However I do believe that if one is stuck with the loop - the filtering works.

I tried to filter on the user that does the check-in, but apparently you can achieve the same result by filtering on other properties as well. We just need to identify a unique flag for the infinite loops. This person filtered on the unique comment associated with the automated build.

http://blogs.msdn.com/gautamg/archive/2006/05/02/588193.aspx

Hope this helps and good luck to you.