我想构建一个使用 Microsoft.Build 名称的单声道项目。
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
整个文件可在此处获得。
但是,我收到这些错误:
$ 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
我究竟做错了什么?