简体   繁体   中英

Mono xbuild uses dmcs instead of gmcs

I have the following code:

using System;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace MyTasks
{
    public class SimpleTask : Task
    {
            public override bool Execute()
            {
                    return true;
            }
    }
}

I have the following MSBuild script:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Target Name="Build">
      <MakeDir Directories= "bin"/>
      <Csc Sources="SimpleTask.cs" References="Microsoft.Build.Utilities,Microsoft.Build.Framework"      TargetType="library"
           OutputAssembly=".\bin\SimpleTask.dll" />
   </Target>
</Project>

It fails with the following message:

broersa@build01:~/task$ xbuild SimpleTask.proj
XBuild Engine Version 2.10.8.1
Mono, Version 2.10.8.1
Copyright (C) Marek Sieradzki 2005-2008, Novell 2008-2011.

Build started 5/27/2012 12:08:32 PM.
__________________________________________________
Project "/home/broersa/task/SimpleTask.proj" (default target(s)):
        Target Build:
                Tool /usr/bin/dmcs execution started with arguments:  /out:./bin/SimpleTask.dll SimpleTask.cs /target:library /reference:Microsoft.Build.Utilities,Microsoft.Build.Framework
: error CS0006: Metadata file `Microsoft.Build.Utilities' could not be found
        Task "Csc" execution -- FAILED
        Done building target "Build" in project "/home/broersa/task/SimpleTask.proj".-- FAILED
Done building project "/home/broersa/task/SimpleTask.proj".-- FAILED

Build FAILED.
Errors:

/home/broersa/task/SimpleTask.proj (default targets) ->
(Build target) ->

        : error CS0006: Metadata file `Microsoft.Build.Utilities' could not be found

         0 Warning(s)
         1 Error(s)

Time Elapsed 00:00:00.4351060

Xbuild calls the dmcs compiler but the Microsoft.Build.Utilites assembly has references to .net 2.0 assemblies. When I compile by hand with gmcs (2.0) it works. But I can't get it working with xbuild.

在Project xml标记中将Toolsversion设置为2.0。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM