What in my CruiseControl.NET configuration is causing this exception? - msbuild

In attempting to set up a build for a demo project I am working on, I received the following exception:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Documents and Settings\Administrator\Local Settings\Temp\1bea7440-959c-4dd4-89ad-05dcd00e369c\ThoughtWorks.CruiseControl.MsBuild.dll'
Question: What don't I have configured correctly?
Below is my task block from my ccnet.config file:
<tasks>
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<workingDirectory>C:\CCWorkingDirectory\DemoApplication</workingDirectory>
<projectFile>DemoApplication.sln</projectFile>
<!--<buildArgs>/noconsolelogger /v:quiet
/p:Configuration=Debug
/p:ReferencePath="C:\Program Files\NUnit 2.4.7\bin"
</buildArgs>-->
<targets>ReBuild</targets >
<timeout>600</timeout >
<!--<logger>c:\Program Files\CruiseControl.NET\server\Rodemeyer.MsBuildToCCNet.dll</logger >-->
</msbuild>
</tasks>

You need to include ThoughtWorks.CruiseControl.MsBuild.dll in the working directory of your application.
So you need to put ThoughtWorks.CruiseControl.MsBuild.dll in C:\CCWorkingDirectory\DemoApplication
Here's a link about the MSBuild tag.
You could alternatively include it in the logger tag like so:
<logger>
C:\Program Files\CruiseControl.NET\server\
ThoughtWorks.CruiseControl.MsBuild.dll
</logger>

Related

Unable to find MSDeploy task within MSBuild

I am trying to use the MSDeploy task within MSBuild (instead of calling it form the command line). I assumed this task was built in to MSBuild but I seem to be having trouble finding the task. The error Im getting is below. I have just re-installed the Web Deploy Tool to see if it might help.
C:\CLIENTS\DAM\Components\Umbraco\SiteTemplate_v6_1_6\Build>msbuild MSBuildScript.csproj -t:Deploy_v2
Microsoft (R) Build Engine version 4.0.30319.17929
[Microsoft .NET Framework, version 4.0.30319.18052]
<!-- some other stuff -->
error MSB4036: The "MSDeploy" task was not found. Check
the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and imple
ments the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks
files located in the "c:\Windows\Microsoft.NET\Framework\v4.0.30319" directory.
v10.0 can vary (v11.0 for example)
Do a search for your "Microsoft.WebApplication.targets" file and alter the import statement to match.
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- Bunch of Other Stuff -->
<Target Name="AllTargetsWrapped">
<CallTarget Targets="ShowVariables" />
</Target>
<Target Name="ShowVariables" >
<Message Text="MSBuildExtensionsPath = $(MSBuildExtensionsPath)" />
</Target>

Does CRuise Control use nAnt or MSbuild?

I am having issues understanding Cruise Control.
I would like to create a build automation in order to perform the build in my project. To do that I created the following entry in the ccnet.config file
<project name="My Web Release " description="Web config">
<workingDirectory>d:\GIT</workingDirectory>
<triggers/>
<sourcecontrol type="git">
<repository>GIT REPO</repository>
<branch>release-name</branch>
<autoGetSource>true</autoGetSource>
<fetchSubmodules>true</fetchSubmodules>
<executable>C:\Program Files (x86)\Git\cmd\git.exe</executable>
<tagOnSuccess>false</tagOnSuccess>
<commitBuildModifications>false</commitBuildModifications>
<commitUntrackedFiles>false</commitUntrackedFiles>
<tagCommitMessage> Build {0}</tagCommitMessage>
<tagNameFormat>Build-{0}</tagNameFormat>
<committerName>Build</committerName>
<committerEMail>build#build.com</committerEMail>
<workingDirectory>$(workingDirectory)\Sources\WEB</workingDirectory>
<timeout>600000</timeout>
</sourcecontrol>
<tasks>
<msbuild>
<executable>c:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
<buildFile>BuildScript.xml</buildFile>
<targets>NewBuild</targets>
<logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</tasks>
<publishers>
<xmllogger />
<artifactcleanup cleanUpMethod="KeepLastXBuilds" cleanUpValue="50" />
</publishers>
</project>
And I do have a BuildScript.xml file.
My question is:
Is this a nAnt or MSBUILD script?
I am asking because I am trying to follow the documentation but I get a lot of issues regarding unknown tasks and so on.
For instance, this:
<property name="configuration" value="CLOSED" />
Would generate a unknown "property" task.
I am looking at MSBuild documentation to use a Move task.
and I got to this line:
<move file="originPath" tofile="TargetPath"/>
But I get:
BuildScript.xml(18,3): error MSB4036: The "Move" task was not
found. C heck the following: 1.) The name of the task in the project
file is the same as the name of the task class. 2.) The task class is
"public" and implements the Microsoft.Build.Framework.ITask interface.
3.) The task is correctly declared w ith in the project file, or in the *.tasks files located in the "C:
\Windows\Microsoft.NET\Framework\v2.0.50727" directory.
What is driving me crazy is that it was working before we migrated to Cruise Control.
Is this being interpreted as nAnt or MSBuild? Any ideas on why I am getting these errors?
It looks like your mixing nant and msbuild, if it was msbuild it would look like
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Tools="4.0">
<Target Name="Move">
<PropertyGroup>
<configuration>CLOSED</configuration>
</PropertyGroup>
<Move SourceFiles="Somefilefile" DestinationFolder="c:\temp"/>
</Target>
</Project>
So casing was an issue and that you need to specify the tools version as move is available from 4.0.

CruiseControl.Net error: Unknown plugin for <msbuild>

I'm trying to get CruiseControl.Net working with MSBuild (this is my first exposure to CruiseControl.Net). I thought I'd done the configuration correctly, however I just get the following error message when starting up:
[cc]Jun-22 20:02:55 Main - error setting config file on controller
net.sourceforge.cruisecontrol.CruiseControlException: error configuring project MyProject
at *SNIP*
Caused by: net.sourceforge.cruisecontrol.CruiseControlException: Unknown plugin for: <msbuild>
at *SNIP*
[cc]Jun-22 20:02:55 Main - error configuring project MyProject
As far as I can work out, this would appear to indicate that I'm missing the MSBuild plugin, however all documentation that I can find indicates that the MSBuild plugin has been included with CruiseControl.Net since version 1.0
I'm using the latest binary release (v 2.8.3)
Here is my config xml:
<project name="MyProject">
<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>
<bootstrappers></bootstrappers>
<modificationset quietperiod="10">
<filesystem folder="C:\snip\main"/>
</modificationset>
<schedule interval="60">
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
<workingDirectory>C:\snip\main</workingDirectory>
<projectFile>MyProject.sln</projectFile>
<buildArgs>/p:Configuration=Debug /v:diag</buildArgs>
<targets>Build;Test</targets>
<timeout>900</timeout>
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
</schedule>
<log />
<publishers />
</project>
Any advice on how I can troubleshoot this would be much appreciated.
Aggg - it appears that I have unwittingly downloaded CruiseControl, instead of CruiseControl.Net (and to make things even more confusing I was looking at CruiseControl.Net documentation)

Unable to publish using msbuild or aspnet_compiler using cc.net

I am trying to automate publishing a project having many solutions in cc.net. I am using msbuild which in turn calls a aspnetcompiler xml file. Problem is my directory contains many solutions and when I run aspnetcompiler it gives me the following error.
errorASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS
I have tried all possible solutions given at many forums. But I am confused how to explicitly tell aspnet_compiler to execute a particular project out of 20 projects.
I am using the ccnet build to call aspnet complier
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<!--msbuild exe directory -->
<workingDirectory>C:\cc\test\code\</workingDirectory>
<!--your working directory -->
<projectFile>C:\Program Files\CruiseControl.NET\server\AspNetCompilerConfiguration.xml</projectFile>
<!--the configuration xml file which will hold AspNetCompiler lines-->
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
</msbuild>
this is my AspNetCompilerConfiguration.xml file
<Project
xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
name = "AspNetPreCompile"
DefaultTargets = "PrecompileWeb">
<Target Name = "PrecompileWeb">
<AspNetCompiler
VirtualPath = "test"
PhysicalPath = "C:\cc\test\code\"
TargetPath = "C:\cc\testitr\deploy\"
Force = "true"
Debug = "true"
Updateable = "true"/>
</Target>
</Project>
Now I want to run C:\cc\test\code\Com.Project1.sln. but i dont know how to tell aspnet compiler. Any idea how to do this and then publish this.
First of all: you can't publish website by scirpt with aspnet_compiler but you can (Release-mode-)compile website which is generally the same thing. Or you can use MsBuild by the way I describe in this post.
I recommend you to group your ASP.NET Websites to solution files and build them. Then you have less params and you can test the build with Visual Studio.
Here is how you can use some params in your cc.net build file for msbuild-scirpt:
<msbuild>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<!--msbuild exe directory -->
<workingDirectory>C:\cc\test\code\</workingDirectory>
<!--your working directory -->
<projectFile>C:\Program Files\CruiseControl.NET\server\AspNetCompilerConfiguration.xml</projectFile>
<!--the configuration xml file which will hold AspNetCompiler lines-->
<logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
<!--Build arguments. You can have multiple projects or msbuild sections in cc.net.config-->
<buildArgs>/p:Configuration=Debug;MyAttribute1=MyValue1;MyAttribute2=MyValue2;</buildArgs>
<!--targets, if not default (here PrecompileWeb) -->
<targets>Build;Analyze</targets>
</msbuild>
Then you can modify your AspNetCompilerConfiguration.xml (better name in my opinion would be something like MyWebSites.msbuild) to take params:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" name = "AspNetPreCompile" DefaultTargets = "PrecompileWeb">
<!--Conditions are params from ccnet.config (or command line)-->
<PropertyGroup Condition="'$(MyAttribute1)' == MyValue1" >
<MySolution>c:\mything.sln</MySolution>
</PropertyGroup>
<PropertyGroup Condition="'$(MyAttribute1)' != MyValue1" >
<MySolution>c:\some_other.sln</MySolution>
</PropertyGroup>
<!--This way you could import other msbuild-scirpts to manage separate files-->
<!--<Import Project="Morexml.msbuild"/>-->
<Target Name="Build">
<Exec Command="echo hello world 1!"/>
<MSBuild Projects="$(MySolution)" Targets="Rebuild" ContinueOnError="false" StopOnFirstFailure="false" />
</Target>
<Target Name="Analyze">
<Exec Command="echo hello world 2!"/>
</Target>
<!--default, for example, here call some tasks -->
<!--default is not used when targets are specified -->
<Target Name="PrecompileWeb">
<CallTarget Targets="Build" />
<CallTarget Targets="Analyze" Condition="'$(MyAttribute2)' != 'MyValue2'" />
</Target>
</Project>
You can configure your solution .sln-file with Visual Studio or Notepad. However it should have your websites, something like this:
Project("{ABCD1234-7377-472B-9ABA-BC803B73C123}") = "MyWebSite", "http://localhost/MyWebSite", "{12345678-5FD6-4177-B210-54045B098ABC}"
ProjectSection(WebsiteProperties) = preProject
Debug.AspNetCompiler.VirtualPath = "/MyWebSite"
Debug.AspNetCompiler.PhysicalPath = "..\..\MyWebSite\"
Debug.AspNetCompiler.TargetPath = "C:\MyPublishedWebsite\"
Debug.AspNetCompiler.Updateable = "false"
Debug.AspNetCompiler.ForceOverwrite = "true"
...
There you can see the properties. There is no need for IIS any configuration. (Just check your released Web.Config (Release/Debug, etc. settings) or maybe use some msbuild-Target to handle that.)
Hope this helps!

CruiseControl.net, msbuild, /p:OutputPath and CCNetArtifactDirectory

I'm trying to setup CruiseControl.net at the moment. So far it works nice, but I have a Problem with the MSBuild Task.
According to the Documentation, it passes CCNetArtifactDirectory to MSBuild. But how do I use it?
I tried this:
<buildArgs>
/noconsolelogger /p:OutputPath=$(CCNetArtifactDirectory)\test
</buildArgs>
But that does not work. In fact, it kills the service with this error:
ThoughtWorks.CruiseControl.Core.Config.Preprocessor.EvaluationException: Reference to unknown symbol CCNetArtifactDirectory
Documentation is rather sparse, and google und mainly offers modifying the .sln Project file, which is what I want to avoid in order to be able to manually build this project later - I would really prefer /p:OutputPath.
The CCNetArtifactDirectory is passed to the MSBuild by default, so you dont need to worry about it. MSBuild will place the build output in the "bin location" relevant to the working directory that you have specified.
<executable>c:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<workingDirectory>C:\data\projects\FooSolution\</workingDirectory>
<projectFile>FooSolution.sln</projectFile>
<buildArgs>/noconsolelogger /p:Configuration=Debug </buildArgs>
So in the above example your build output will be put in C:\data\projects\FooSolution[ProjectName]\bin\Debug. Should you want to output to a different location you may want to look at of the tag in CCNET.
<publishers>
<xmllogger />
<buildpublisher>
<sourceDir>C:\data\projects\FooSolution\FooProject\bin\Debug</sourceDir>
<publishDir>C:\published\FooSolution\</publishDir>
<useLabelSubDirectory>false</useLabelSubDirectory>
</buildpublisher>
</publishers>
This will allow you to publish your output to a different location.
You can use the artifact directory variable inside the MSBuild script itself. Here's an example of how I'm running FxCop right now from my CC.Net MSBuild script (this script is what CC.Net points to - there is also a "Build" target in the script that includes an MSBuild task against the SLN to do the actual compilation):
<Exec
Command='FxCopCmd.exe /project:"$(MSBuildProjectDirectory)\FXCopRules.FxCop" /out:"$(CCNetArtifactDirectory)\ProjectName.FxCop.xml"'
WorkingDirectory="C:\Program Files\Microsoft FxCop 1.35"
ContinueOnError="true"
IgnoreExitCode="true"
/>
Parameters like CCNetArtifactDirectory are passed to external programs using environment variables. They are available in the external program but they aren't inside CCNET configuration. This often leads to confusion.
You can use a preprocessor constant instead:
<cb:define project.artifactDirectory="C:\foo">
<project>
<!-- [...] -->
<artifactDirectory>$(project.artifactDirectory)</artifactDirectory>
<!-- [...] -->
<tasks>
<!-- [...] -->
<msbuild>
<!-- [...] -->
<buildArgs>/noconsolelogger /p:OutputPath=$(project.artifactDirectory)\test</buildArgs>
<!-- [...] -->
</msbuild>
<!-- [...] -->
</tasks>
<!-- [...] -->
</project>