How can I capture the Messages from msbuild in cruise control? - cruisecontrol.net

I have Messages in my build file but I don't see them anywhere in my logs or trace files. I'm looking at ccnet logs and msbuild logs but I dont see any. Is that a setting some where?
Thanks

To capture MSBuild messages, you must configure a listener in CC.NET.
Add the logger tag in your configuration project:
<msbuild>
... your MSBuild configuration
<logger>C:\cc_net\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>

Related

Azure worker role gets published with the wrong service configuration

I'm trying to get the "publish to azure" functionality in VS2013 going for my worker-role cloud-service project.
The problem I'm having is that no matter what I change the service configuration settings to the application is always deployed with the Localservice configuration
My .azurePubxml:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AzureCredentials>{"ServiceManagementEndpoint":"https:\/\/management.core.windows.net\/","SubscriptionId":"redacted"}</AzureCredentials>
<AzureDeleteDeploymentOnFailure>False</AzureDeleteDeploymentOnFailure>
<AzureDeploymentLabel>MyWorkerRole</AzureDeploymentLabel>
<AzureDeploymentReplacementMethod>AutomaticUpgrade</AzureDeploymentReplacementMethod>
<AzureSlot>Staging</AzureSlot>
<AzureEnableRemoteDesktop>True</AzureEnableRemoteDesktop>
<AzureEnableWebDeploy>False</AzureEnableWebDeploy>
<AzureFallbackToDeleteAndRecreateIfUpgradeFails>False</AzureFallbackToDeleteAndRecreateIfUpgradeFails>
<AzureHostedServiceLabel>MyLabel</AzureHostedServiceLabel>
<AzureHostedServiceName>MyService</AzureHostedServiceName>
<AzureEnableIntelliTrace>False</AzureEnableIntelliTrace>
<AzureEnableProfiling>False</AzureEnableProfiling>
<AzureServiceConfiguration>Staging</AzureServiceConfiguration>
<AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>
<AzureStorageAccountLabel>webstorage</AzureStorageAccountLabel>
<AzureStorageAccountName>webstorage</AzureStorageAccountName>
<AzureAppendTimestampToDeploymentLabel>True</AzureAppendTimestampToDeploymentLabel>
</PropertyGroup>
</Project>
As you can see, the AzureServiceConfiguration is set to Staging.
If i look at the output from the build I can see these lines:
Target "ResolveServiceConfiguration" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Windows Azure Tools\2.6\Microsoft.WindowsAzure.targets" from project "path-to.ccproj" (target "CoreResolveServiceModel" depends on it):
3> Task "Message"
3> Target Profile: Local
3> Task "Message"
3> Service Configurations: ServiceConfiguration.Staging.cscfg;ServiceConfiguration.Production.cscfg;ServiceConfiguration.Local.cscfg
3> Task "Message"
3> Looking for a service configuration file named: ServiceConfiguration.Local.cscfg
3> Task "FindInList"
3> Task "Message"
3> Source Service Configuration: ServiceConfiguration.Local.cscfg
3> Task "Message"
3> Target Service Configuration: bin\Staging\ServiceConfiguration.cscfg
The end-result is that the ServiceConfiguration.Local.cscfg is used in the deployment instead of ServiceConfiguration.Staging.cscfg.
What does work though is to change the Service Configuration setting to staging under Development->Run/debug.
But this setting controls which configuration file is used when I run the app locally, so naturally I don't want to mess with it.
Also, if I use the Project->Package... option and choose staging I get the correct package and the correct config file generated.
I've also tried bulding manually with msbuild from commandline, works great as well.
Tried updating to azure sdk 2.6 in hopes that it would solve it, but no difference.
Should also say that I have this working in my web-role project. But for external reasons I had to split the worker-role to its own cloud project.
Update Some more info, I took a another closer look at the build log and found this:
1>------ Build started: Project: MyProject, Configuration: Debug Any CPU ------
1>Build started 6/5/2015 5:15:03 PM.
1>Building with tools version "12.0".
1>Target "_CheckForInvalidConfigurationAndPlatform" in file "C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets" from project "path_to_project.csproj" (entry point):
1>Task "Error" skipped, due to false condition; ( '$(_InvalidConfigurationError)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Task "Warning" skipped, due to false condition; ( '$(_InvalidConfigurationWarning)' == 'true' ) was evaluated as ( '' == 'true' ).
1>Using "Message" task from assembly "Microsoft.Build.Tasks.v12.0, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "Message"
1> Task Parameter:Text=Configuration=Debug
1> Task Parameter:Importance=Low
1> Configuration=Debug
So it seems that neither
<AzureServiceConfiguration>Staging</AzureServiceConfiguration>
<AzureSolutionConfiguration>Staging</AzureSolutionConfiguration>
from the .azurePubxml are actually being used as input to the build script.
It all seems to boil down to, where is the Publish to Azure function pulling its parameters from, if not from the .azurePubxml file?
Never got this working fully in VS2013 but now I've gone up to VS2015 and publish to Azure works as expected again.

How to configure log4j and Selenium Grid?

When I launch a Grid hub using Ant, the logging is all by default on the console. I would like to know if there is a way wherein I can alter the build.xml file of Selenium Grid and include a log4j logger into it. I understand that I can specify a log file to Ant itself using the -logfile option. But this would cause the log file to be overwritten everytime the grid is launched. I want to ensure that the log files are automatically renamed after a threshold is reached for better maintenance. Any help and if possible some examples on how to do it would be greatly appreciated (I am new to using log4j which is why I am asking for some sample for this specific need).
You need to specify the location of the Log4j archive as well as its configuration file when starting up Selenium. In the following example, I've updated the classpath to load the log4j.hub.properties configuration file located in the /etc/selenium directory and the log4j.jar located in the /usr/lib/selenium directory. I've also setup some additional log files:
java -classpath /etc/selenium:/usr/lib/selenium/log4j.jar:/usr/lib/selenium/selenium-server-standalone.jar -Dlog4j.configuration=log4j.hub.properties org.openqa.grid.selenium.GridLauncher -role hub -log /var/log/selenium/hub.debug.log > /var/log/selenium/hub.output.log 2> /var/log/selenium/hub.error.log &
Then you can have something like the following to achieve what you are looking for:
log4j.rootLogger=ALL, file
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=/var/log/selenium/hub.log
log4j.appender.file.Append=true
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} <%p> <%t> %m%n
You might want to look at this page for more information about how Selenium logging is working.

Cruise Control: Web-based Source Control Configuration

Currently I have this sourcecontrol config block.
<sourcecontrol type="svn">
<trunkUrl>https://SampleSVNOnlineRepository.com/12maksdde12d123ede12</trunkUrl>
<workingDirectory>c:\MyProject</workingDirectory>
<username>admin</username>
<password>mypassword</password>
</sourcecontrol>
Cruise Control Exception:
Source control failure : Unable to execute file [c:\MyProject\svn]. The file may not exist or may not be executable.]
What seems to be the problem here?
It means that CruiseControl.NET cannot find the svn executable. You'll have to specify it with the executable element, e.g:
<sourcecontrol type="svn">
...
<executable >absolute\path\tp\subversion\executable</element>
Did you checkout the project first by hand in that location? As I understood when I played with phpUnderControl, which uses CruiseControl, you do the first checkout by hand.

cruisecontrol <buildargs> nant parameter not being passed

I've been trying to use the param in my cruisecontrol build config file to no avail. When checking the cruisecontrol log file, whatever buildargs I try to pass are NOT passed to the call to nAnt.
Here's the nant task:
<nant>
<buildArgs>-D:CCFoo="Unknown" -D:foo="$(foo)"</buildArgs>
<executable>C:\MCR\Trunk\BuildLibrary\NAnt.exe</executable>
<baseDirectory>C:\MCR\Trunk\tek.Build</baseDirectory>
<buildFile>tek.build</buildFile>
<targetList>
<target>cc</target>
</targetList>
<buildTimeoutSeconds>1800</buildTimeoutSeconds>
</nant>
Here's what appears in the logfile for that call to nant:
2010-01-28 08:45:12,815 [TekWebsite:DEBUG] Starting process [C:\MCR\Trunk\BuildLibrary\NAnt.exe] in working directory [C:\MCR\Trunk\tek.Build] with arguments [-nologo -buildfile:tek.build -logger:NAnt.Core.XmlLogger -D:CCNetArtifactDirectory="C:\Program Files (x86)\CruiseControl.NET\server\builds" -D:CCNetBuildCondition=ForceBuild -D:CCNetBuildDate=2010-01-28 -D:CCNetBuildTime=08:45:12 -D:CCNetFailureUsers= -D:CCNetIntegrationStatus=Unknown -D:CCNetLabel=50 -D:CCNetLastIntegrationStatus=Failure -D:CCNetListenerFile="C:\Program Files (x86)\CruiseControl.NET\server\builds\ClarksWebsite_ListenFile.xml" -D:CCNetModifyingUsers= -D:CCNetNumericLabel=50 -D:CCNetProject=TekWebsite -D:CCNetProjectUrl=http://cor-str-mcr08/ccnet/server/local/project/TekWebsite/ViewProjectReport.aspx -D:CCNetRequestSource=Dashboard -D:CCNetWorkingDirectory="C:\Program Files (x86)\CruiseControl.NET\server" cc]
I'm thinking that maybe there's a config setting for cruisecontrol that tells it to ignore buildargs?
I've tried reordering the lines in the nant task, putting buildargs at the top as you see, and a few places in the middle and the bottom. I've tried the different syntaxes that are available for buildargs such as:
-D:CCFoo="Unknown"
-D:CCFoo=Unknown
-DCCFoo=Unknown
I figured this out - the ccnet.config file that's used by the ccnet daemon process won't reload the build config file until either:
a) the process is restarted OR
b) the ccnet.config file is altered or touched in some way.
So I just went into C:\Program Files (x86)\CruiseControl.NET\server.ccnet.config and added a space, saved and now the buildargs are being passed to nant. woohoo!
I had the exact same problem running some bat file but my reason was I has used:
<msbuild>
...
instead of
<exec>
...

CruiseControl.NET post-build actions

We have CC.NET setup on our ASP.NET app. When we build the project, the ASP.NET app is pre-compiled and copied to a network share, from which a server runs the application.
The server is a bit different from development box'es, and the next server in our staging environment differs even more. The difference is specific config files and so on - so I want to exclude some files - or delete them before the pre-compiled app is copied to a network share.
My config file looks like this:
<project name="Assembly.Web.project">
<triggers>
<intervalTrigger seconds="3600" />
</triggers>
<sourcecontrol type="svn">
<trunkUrl>svn://svn-server/MyApp/Web/Trunk</trunkUrl>
<workingDirectory>C:\build-server\Assembly\Web\TEST-HL</workingDirectory>
<executable>C:\Program Files (x86)\SVN 1.5 bin\svn.exe</executable>
<username>uid</username>
<password>pwd</password>
</sourcecontrol>
<tasks>
<msbuild>
<executable>C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\build-server\Assembly\Web\TEST-HL</workingDirectory>
<projectFile>C:\build-server\Assembly\Web\TEST-HL\Web\Web.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
<targets>Build</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
<publishers>
<buildpublisher>
<sourceDir>C:\build-server\Assembly\Web\PrecompiledWeb</sourceDir>
<publishDir>\\test-web01\Web</publishDir>
<useLabelSubDirectory>false</useLabelSubDirectory>
<alwaysPublish>false</alwaysPublish>
</buildpublisher>
</publishers>
</project>
As you can see, I use a buildPublisher to copy the pre-compiled files to the network share. What I want to do here, is either 1) delete certain files before they are copied or 2) replace those files after they have been copied.
I DO NOT want to have some app running watching specific files for change, and then after that replace the files with other ones. I want something to be either done by CC.NET, or triggered by CC.NET.
Can you launch a .bat file with CC.NET?
I use a NAnt task for all publishing, deploying, cleaning and so on.
Take a look at MSDEPLOY or Web Deployment Projects. There is a question that will provide more detail here
You have to use NAnt for those kind of stuff.
Here is the Task Reference of Nant..
Of course CruiseControl.NET can run a batch file, simply use the exec task. However, an easier answer might just be to have MSBuild do the task for you. It should be simple to add a few steps in the postcompile target.

Resources