[MonoDevelop] [Mono-list] Custom ITaks in MonoDevelop

Michael Hutchinson m.j.hutchinson at gmail.com
Sun Sep 12 21:17:20 EDT 2010

On Sun, Sep 12, 2010 at 3:41 PM,  <Krogerma at aol.com> wrote:
> Hello, Lists:
> I received some clarification from list members right after I submitted my
> last E-mail. I got waylayed for a while, but now I'm back on it. Thanks to
> the folks who helped me.
> The information I got indicated that xbuild had to be turned on within
> MonoDevelop if any Custom Tasks need to be called. I've done this. I get a
> couple of error messages:
>  "Error initializing task Message:  cannot cast from source type to
> destination type"
>  "Error initializing task CreateItem:  cannot cast from source type to
> destination type".
> This occurs in a simple file that does not even have any custom tasks in it
> (I actually commented them out in the .csproj file) that otherwise builds
> fine without the xbuild switch turned on in MonoDevelop.
> I just upgraded to mono 2.6.7 to continue with this work. I'm using the
> latest MonoDevelop, which I also downloaded at the same time.
> This seems to me like it might be an incorrect version of a dll somewhere.
> Does anybody have any advice?
> A snippet from the bottom of my .csproj file is:
>   <!-- This section is a very simple test to copy a file. -->
> <!--  <PropertyGroup>
>     <FileToCopy>TestClass1.txt</FileToCopy>
>   </PropertyGroup>
>   <PropertyGroup>
>     <Dest>bin\</Dest>
>   </PropertyGroup>
>   <Target Name="AfterBuild">
>     <Copy SourceFiles="$(FileToCopy)" DestinationFolder="$(Dest)" />
>   </Target> -->
> I'm starting simple here - only using the ITasks that are provided from
> Microsoft and seem to be provided in the Mono distribution, too. The
> AfterBuild Target is in the Mono version of Microsoft.Common.Targets, so I'm
> assuming it can be used the same way as in MSBuild.
> I'm including the solution file.
> If anyone can help us get this running, we'll submit my intern's report on
> this to the community.
> What we are (eventually) trying to achieve is to perform builds across
> Windows-VS, Windows-mono, Linux-mono and Mac-mono environments with the same
> solution and project files. Our plan entails putting certain build-wide
> variables into a configuration file that lives in the solution folder and
> that will be accessed to determine platform-specific directories and other
> platform-specific information.


The problem is that the executable that MD uses to build MSBuild
projects references the MSBuild 2.0 assemblies, so if your tasks
reference the 3.5 assemblies, your tasks will not be able to be cast
to the 2.0 ITask interface and the build will fail.

This was fixed in MonoDevelop master about a week ago - MD uses Cecil
to rewrite the builder executable into versions for 3.5 and 4.0 APIs,
depending on the project's ToolsVersion. Note that this means the 4.0
ToolsVersion requires a runtime that supports 4.0, e.g. Mono 2.8.

Michael Hutchinson

More information about the Monodevelop-list mailing list