在Mono项目中使用Microsoft程序集的问题

时间:2012-12-10 15:53:30

标签: c# mono assemblies

我想用mono创建一个使用Microsoft.Build名称的项目。

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

整个文件可用here

但是,我收到了这些错误:

$ mcs LoggerImpl.cs
LoggerImpl.cs(4,17): error CS0234: The type or namespace name `Build' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
LoggerImpl.cs(5,17): error CS0234: The type or namespace name `Build' does not exist in the namespace `Microsoft'. Are you missing an assembly reference?
LoggerImpl.cs(15,41): error CS0246: The type or namespace name `IEventSource' could not be found. Are you missing a using directive or an assembly reference?
LoggerImpl.cs(28,44): error CS0246: The type or namespace name `ProjectStartedEventArgs' could not be found. Are you missing a using directive or an assembly reference?
LoggerImpl.cs(36,43): error CS0246: The type or namespace name `BuildFinishedEventArgs' could not be found. Are you missing a using directive or an assembly reference?
LoggerImpl.cs(52,41): error CS0246: The type or namespace name `BuildErrorEventArgs' could not be found. Are you missing a using directive or an assembly reference?
LoggerImpl.cs(62,43): error CS0246: The type or namespace name `BuildWarningEventArgs' could not be found. Are you missing a using directive or an assembly reference?
Compilation failed: 7 error(s), 0 warnings

与smcs相同。这很奇怪,因为gacutil将Microsoft.Build列为已安装的程序集:

$gacutil -l Microsoft.Build
The following assemblies are installed into the GAC:
Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Number of items = 1

甚至安装了Microsoft.Build.Framework(也使用过):

$ gacutil -l Microsoft.Build.Framework
The following assemblies are installed into the GAC:
Microsoft.Build.Framework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Framework, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Number of items = 3

我做错了什么?

1 个答案:

答案 0 :(得分:2)

Microsoft.Build.dll存在,但您需要引用它:

mcs LoggerImpl.cs -r:Microsoft.Build.dll