Pergunta

I'm trying to creating a custom task to generate an intermediate .csproj file (see this post for the reason.)

The custom task is in a dll that presently references the .net 2.0 assemblies.

The experimental msbuild/xbuild setting of MonoDevelop is enabled to force MonoDevelop to use xbuild to build the project.

I am able to run this from the command line, via a project that references the task via a <UsingTask> element:

    ~/src/All/workspace/XBuildExt/bin/Debug> mono
    /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/3.5/xbuild.exe
    ../../XBuildExtTest.targets 
    XBuild Engine Version 2.10.8.0
    Mono, Version 2.10.8.0
    Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2011.

    Build started 2/27/2012 4:26:15 PM.
    __________________________________________________
    Project "/Users/bright/src/All/workspace/XBuildExt/XBuildExtTest.targets"        
    (default target(s)):
        Target Build:
            It works!
    Done building project
    "/Users/bright/src/All/workspace/XBuildExt/XBuildExtTest.targets".

    Build succeeded.
         0 Warning(s)
         0 Error(s)

However, the same code in a MonoTouch project fails with:

    Error initializing task GenerateMdToolProject: Cannot cast from 
    source type to destination type.
    Task "GenerateMdToolProject" execution -- FAILED

Questions:

  1. I've found this old post which indicates the problem was fixed in Mono 2.8. Is this also true of MonoTouch?
  2. Can I use .net 3.5 functionality (in particular System.Xml.Linq) for coding the custom task?
Foi útil?

Solução

I've found this old post which indicates the problem was fixed in Mono 2.8.

You misunderstood that post. It says this was fixed in MonoDevelop (not Mono) in early September 2010. So recent versions of MonoDevelop, like 2.8.x, will have the fix you mention.

The note about Mono 2.8 is about another requirement (of the original post question), i.e. having a runtime that supports .NET 4.0. You'll only have this if you're using Mono 2.8 (or later). Developing for MonoTouch requires Mono 2.10+ so this won't be an issue for you.

Is this also true of MonoTouch?

This does not apply to MonoTouch itself. The Mono version used inside the product (based on 2.10 anyway) is not what you use (except the smcs compiler) to execute MonoDevelop or (in your case) the xbuild (Mono's msbuild-compatible) tool.

IWO the parts of Mono that are included in MonoTouch are meant to be used on the simulator or device, not for building or executing the tooling.

Can I use .net 3.5 functionality (in particular System.Xml.Linq) for coding the custom task?

Yes. Once you have a .NET 4.0 runtime you'll have (thru the GAC) access the newer assemblies, including System.Xml.Linq, to run your msbuild tasks (as long as your paths and environment variables are set correctly, which they likely are if can run MonoDevelop).

Outras dicas

MonoDevelop doesn't use xbuild to build MonoTouch project, but custom code which only understands as much as necessary of the MSBuild project file.

This means that any special MSBuild logic you add to the project will go undetected.

There are plans for this to change in the future, but nothing has been decided (nor is there a timeline) yet.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top