how to work with scheduling in ccnet config - msbuild

I am working in cruise control. I want,my window service should be make a build every day twice aroud morning 9 am and evening 7 pn.how to set all my senario on in ccnet.config.below is my ccnet.config
<project name="aaa">
<webURL>http://localhost:333/ccnet/</webURL>
<triggers>
<intervalTrigger seconds="300" buildCondition="ForceBuild" />
</triggers>
<tasks>
</project>

You'll want to use a scheduleTrigger:
<project name="aaa">
<webURL>http://localhost:333/ccnet/</webURL>
<triggers>
<scheduleTrigger time="9:00" buildCondition="ForceBuild" />
<scheduleTrigger time="19:00" buildCondition="ForceBuild" />
</triggers>
<tasks />
</project>

Related

how to set msbuild script path in ccnet.config using cruise control.net

I am getting below execption when i am trying to run script using cruise control.please look into my code and let me know where i am doing mistake
<build date="2013-07-02 16:38:56" buildtime="00:00:00" error="true" buildcondition="ForceBuild">MSBUILD : error MSB1008: Only one project can be specified.
Switch: e:\mybuild.xml
ccnet.config file
<cruisecontrol>
<project name="Visteon">
<webURL>http://localhost:333/ccnet/</webURL>
<triggers>
<intervalTrigger seconds="110" buildCondition="ForceBuild" />
</triggers>
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>E:\workingproject_5145</workingDirectory>
<projectFile>myproject.sln</projectFile>
<buildArgs>msbuild e:\mybuild.xml /t:Buildrun</buildArgs>
<timeout>120</timeout>
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
</project>
</cruisecontrol>
my scriptsis defined in mybuild.xml which is below mentioned
<Target Name="GetSource">
<Message Text="Checking out trunk into $(SourceDirectory)" />
<SvnCheckout RepositoryPath="$(SvnCheckoutPath)"
LocalPath="$(CheckOutPath)"
UserName="aa"
Password="aa">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnCheckout>
</Target>
<Target Name="Buildrun" DependsOnTargets="GetSource;Clean;" />
<Target Name="Clean">
<!-- Clean, then rebuild entire solution -->
<MSBuild Projects="$(CheckOutPath)\myproject.sln" Targets="Clean;Rebuild" />
</Target>
Your projectFile should be the xml file...(that is a .msbuild file)
I think this is what you want.
<projectFile>mybuild.xml</projectFile>
<buildArgs>/t:Buildrun</buildArgs>
LONG VERSION:
<executable>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>E:\workingproject_5145</workingDirectory>
<projectFile>myproject.sln</projectFile>
<buildArgs>msbuild e:\mybuild.xml /t:Buildrun</buildArgs>
So it's gonna concatenate these values
$executable $workingDirectory $projectFile $buildArgs
So you get something like this:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe E:\workingproject_5145\myproject.sln msbuild e:\mybuild.xml /t:Buildrun
which is not what you want.
If you make the values like this:
<executable>C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>E:\workingproject_5145</workingDirectory>
<projectFile>mybuild.xml</projectFile>
<buildArgs>/t:Buildrun</buildArgs>
You'll get something like this:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe "E:\workingproject_5145\mybuild.xml" /t:Buildrun

how to run msbuild script through cruise control

I am getting execption when i am running cruise control by iis or cctray and below is ccnet.config.i wanted to run my scrip through cruise control .please let me know how to relove this issue
<project name="Visteon">
<webURL>http://localhost/ccnet/</webURL>
<triggers>
<intervalTrigger seconds="110" buildCondition="ForceBuild" />
</triggers>
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
</executable>
<workingDirectory>E:\workingfolder_123</workingDirectory>
<buildArgs>E:\CCnet.xml /p:Configuration=release</buildArgs>
<timeout>1800</timeout>
<!-- 30 minutes -->
<logger>C:\Program Files\CruiseControl.NET\server\
ThoughtWorks.CruiseControl.MSBuild.dll</logger>
</msbuild>
</tasks>
</project>
</cruisecontrol>
my scripts is like this
<Target Name="GetSource">
<Message Text="Checking out trunk into $(SourceDirectory)" />
<SvnCheckout RepositoryPath="$(SvnCheckoutPath)"
LocalPath="$(CheckOutPath)"
UserName="aa"
Password="aa">
<Output TaskParameter="Revision" PropertyName="Revision" />
</SvnCheckout>
</Target>
<Target Name="Build" DependsOnTargets="GetSource;Clean;" />
<Target Name="Clean">
<!-- Clean, then rebuild entire solution -->
<MSBuild Projects="$(CheckOutPath)\SUPPLIER_SOFTWARE.sln" Targets="Clean;Rebuild" />
</Target>
Try using the CruiseControl Template below
<project name="MyCodeFolder Project" queue="MyQueue" queuePriority="1">
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<workingDirectory>D:\Projects\MyCodeFolder</workingDirectory>
<projectFile>CCnet.xml</projectFile>
<buildArgs>/noconsolelogger /nologo /p:Configuration=Release</buildArgs>
<targets>
</targets>
<timeout>4800</timeout>
</msbuild>
</tasks>
As for the build script you will need the root to have Project node and set default target name main as the entry point. Please see below:
<Project DefaultTargets="Main">
<Target Name="Main">
//Do Something
</Target>
</Project>
You are missing project file tag e.g.
<projectFile>your_msbuild_script-here</projectFile>
http://build.sharpdevelop.net/ccnet/doc/CCNET/MsBuild%20Task.html
I'm also not sure what exactly E:\CCnet.xml is. If this is your msbuild file, put it
inside <projectFile/> and try again.
I hope that helps.

I want to run a task for al files and exclude those who did not change

I have two buildtargets to check my code quality.
I run the following buildtargets every time i compile. This takes up too much time and i would like them to only check the files that did change.
In other words i want to filter files that did not change from the ItemGroup CppCheckFiles / LinterFiles.
<Target Name="CppCheck">
<ItemGroup>
<CppCheckFiles Include="*main.c" />
<CppCheckFiles Include="Source/*/*.c" />
</ItemGroup>
<Message Text="$(Configuration) starting." Importance="High" />
<Exec Command="C:\Cppcheck\cppcheck.exe %(CppCheckFiles.FullPath) --enable=style --template="{file}({line}): error:{severity}-{id}: {message}"" />
</Target>
<Target Name="SPLint">
<ItemGroup>
<LinterFiles Include="*main.c" />
<LinterFiles Include="Source/*/*.c" />
<LinterFiles Include="Source/*/*.h" />
</ItemGroup>
<Message Text="$(Configuration) starting." Importance="High" />
<Exec Command="splintCaller %(LinterFiles.FullPath)" />
</Target>
I know that the regular build process does this and i wonder if i have to go so fas as to write my own task.
hmm.. this sounds interesting. I can't help you. But it would be nice if the cppcheck wiki or manual had some small example project that did this.
Some people use cppcheck in commit hooks. I've tried it with GIT myself (I added a linux shell script). And there is a TortoiseSVN plugin you can try (http://sourceforge.net/apps/phpbb/cppcheck/viewtopic.php?f=3&t=443).
The solution is incremental Build. Where MSBuild compares Timestamps to exclude complete Buildtargets if nothing changed.
The following target creates a timesstamp for each file and skippes those files that did not change.
cppcheck.exe returns -1 if an error was detected and the timestamp is not written.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="CppCheck" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CppCheckFiles Include="*main.c" />
<CppCheckFiles Include="Source/*/*.c" />
</ItemGroup>
<Target Name="CppCheck"
Inputs="#(CppCheckFiles)"
Outputs="CCPCheck\%(CppCheckFiles.Filename)%(CppCheckFiles.Extension).stamp">
<Exec Command="C:\Cppcheck\cppcheck.exe %(CppCheckFiles.FullPath) --enable=style --template="{file}({line}): error:{severity}-{id}: {message}"" />
<MakeDir Directories="CCPCheck"/>
<Touch Files="CCPCheck\%(CppCheckFiles.Filename)%(CppCheckFiles.Extension).stamp" AlwaysCreate = "true" />
</Target>
</Project>

Match subdirectories with wildcards using Apache Ant?

I'm trying to setup a build file and I was curious if you can use wildcards in a property to denote filepaths? Or what a better way to tackle this problem is?
As you can see below I want all the files or directories in ${dirtwo} that start with "foo-" to be resolved, versus having to manually include each directory/file as a property.
<?xml version="1.0" encoding="UTF-8"?>
<project name="core" default="build" basedir=".">
<property name="dirone" value="path/to/dir/one" />
<property name="dirtwo" location="path/to/dir/two/foo-*" />
<target name="phpmd" description="Generate pmd.xml using PHPMD">
<exec executable="phpmd">
<arg line="${dirone},${dirtwo}
xml
codesize,design,naming,unusedcode
--reportfile ${basedir}/build/logs/pmd.xml" />
</exec>
</target>
...
</project>
Currently, all I get are errors no matter how I try to use a wildcard or escape one.
Buildfile: /var/www/server/project/build.xml
phpmd:
[exec] The given file "/var/www/server/project/path/to/dir/two/foo-*" does not exist.
[exec] Result: 1
An Ant DirSet matches directories against includes/excludes patterns. You could combine it with Pathconvert as shown below.
<?xml version="1.0" encoding="UTF-8"?>
<project name="core" default="build" basedir=".">
<property name="mybase.dir" location="/path/to/your/base/dir" />
<dirset dir="${mybase.dir}" includes="**/foo-*" id="directories" />
<pathconvert pathsep=", " property="directory-list" refid="directories" />
<target name="phpmd" description="Generate pmd.xml using PHPMD">
<exec executable="phpmd">
<arg line="${directory-list}
xml
codesize,design,naming,unusedcode
--reportfile ${basedir}/build/logs/pmd.xml" />
</exec>
</target>
</project>
To test the results of dirset and pathconvert, you can use:
<echo message="${directory-list}" />

MSBuild MSBuildCommunityTasks Task Time

I have a MSBuild project and I want the current date to be added to a zip file that I am creating.
I am using the MSBuildCommunityTasks.
<!-- Import the CommunityTasks Helpper -->
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
On the website http://msbuildtasks.tigris.org/ I can see a task called time. I have not been able to find doc on how to use Time.
In msbuild 4 you can now
$([Namespace.Type]::Method(..parameters…))
$([Namespace.Type]::Property)
$([Namespace.Type]::set_Property(value))
so I am using
$([System.DateTime]::Now.ToString(`yyyy.MMdd`))
those ticks around the format are backticks not '
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Deploy" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
<!-- Include MSBuild tasks here -->
<ItemGroup>
<DefaultExclude Include="****" />
</ItemGroup>
<Target Name="Deploy" >
<Time Format="yyyy-MM-dd">
<Output TaskParameter="FormattedTime" PropertyName="buildDate" />
</Time>
<Message Text="Deploying ...."></Message>
<Copy SourceFiles="#(DeploymentFiles)" DestinationFolder="C:\CCNET\$(buildDate)\bin\" />
</Target>
</Project>
Maslow's answer is correct (I can't comment on it or I would); I would only add to it that you have to be careful when implicitly calling System.DateTime.Parse.
A parsed string value like $([System.DateTime]::Parse("1970-01-01T00:00:00.0000000Z") doesn't seem to end up with a Kind of DateTimeKind.Utc.
But you can use nested property functions to make it work; like this (to get the Unix timestamp):
$([System.DateTime]::UtcNow.Subtract($([System.DateTime]::Parse("1970-01-01T00:00:00.0000000Z").ToUniversalTime())).TotalSeconds.ToString("F0"))