【问题标题】:Simple HelloWorld build script简单的 HelloWorld 构建脚本
【发布时间】:2009-08-28 18:06:05
【问题描述】:

我有一个简单的 HelloWorld 应用程序,我正在尝试使用 NAnt 构建它。然而,即使使用最简单的构建文件,我仍然无法让它工作。下面是我的 HelloWorld.build 文件。

<?xml version="1.0"?>
<project name="Hello World" default="build">
<property name="nant.settings.currentframework" value="net-3.5"/>
<target name="build">
    <echo>Hello</echo>
    <exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"         
        commandline="HelloWorld /t:Clean /p:Configuration=Debug /v:q" workingdir="." /> 
</target>

这是结果。

C:\webdev\HelloWorld>c:\nant-0.86-beta1\bin\NAnt.exe build
NAnt 0.86 (Build 0.86.2898.0; beta1; 12/8/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/webdev/HelloWorld/HelloWorld.build
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: build

 [property] Target framework changed to "Microsoft .NET Framework 3.5".

BUILD FAILED

INTERNAL ERROR

System.NullReferenceException: Object reference not set to an instance of an object.
   at NAnt.Core.FrameworkInfo.get_Version()
   at NAnt.Core.Project.UpdateTargetFrameworkProperties()
   at NAnt.Core.Tasks.PropertyTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Project.InitializeProjectDocument(XmlDocument doc)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()

Please send bug report to nant-developers@lists.sourceforge.net.

Total time: 0 seconds.

此外,当我尝试手动设置要使用的 .NET 框架时,我得到以下信息:

C:\webdev\HelloWorld>c:\nant-0.86-beta1\bin\NAnt.exe -t:net-3.5
NAnt 0.86 (Build 0.86.2898.0; beta1; 12/8/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Microsoft .NET Framework 3.5 (net-3.5) is not installed, or not correctly configured.

    Object reference not set to an instance of an object.

但是,配置文件确实有 .NET 3.5 的条目。这是 NAnt-0.86-beta 和 Visual C# 2008 Express Edition。我完全偏离轨道了吗?如果是这样,是否有人可能拥有可以重复使用的模板构建文件?

谢谢。

【问题讨论】:

  • 请将构建文件添加到您的问题中

标签: c# .net .net-3.5 nant


【解决方案1】:

我在一个非常简单的控制台应用程序上尝试了您的构建文件,除了调整命令行参数之外,它对我来说一切都很好。

您是否尝试过重新安装 .net 框架 3.5,因为它看起来肯定丢失了(如果您尝试使用 3.5 框架目录中的确切路径从 cmd 行执行 msbuild 会发生什么?)

<?xml version="1.0"?>
<project name="HelloWorld" default="build">
    <property name="nant.settings.currentframework" value="net-3.5"/>
    <target name="build">    
        <echo>Hello</echo>       
        <exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe" commandline="HelloWorld.sln /t:Clean /p:Configuration=Debug /v:q" workingdir="." />
    </target>
</project>

我的项目的输出如下所示

NAnt 0.86(内部版本 0.86.2898.0;beta1;08/12/2007) 版权所有 (C) 2001-2007 Gerry Shaw http://nant.sourceforge.net 构建文件:file:///C:/Documents and Settings/krystan/My Documents/Visual Studio 2008/项目/HelloWorld/test.build 目标框架:Microsoft .NET Framework 3.5 指定的目标:构建 建造: [回声] 你好 [执行] Microsoft (R) 构建引擎版本 3.5.30729.1 [执行] [Microsoft .NET 框架,版本 2.0.50727.3082] [执行] 版权所有 (C) Microsoft Corporation 2007。保留所有权利。 [执行] 构建成功 总时间:0.2秒。

【讨论】:

  • 我同意这一点 - 安装 3.5 并从那里开始,即使您的配置文件设置为使用它,如果它不存在于盒子上,您将无法访问它。
【解决方案2】:

有时这个错误是因为构建服务器没有安装 sdk。

尝试安装 windows sdk。可以在Microsoft Download Center上下载

可能需要额外的步骤才能让nant识别sdk,请参考这个Page Brook's Blog Post

【讨论】:

    【解决方案3】:

    Nant 0.86 中有一个错误,请参阅 http://sourceforge.net/tracker/index.php?func=detail&aid=1986551&group_id=31650&atid=402868 了解更多信息。

    您可以下载已修复此错误的 Nant nightly build(当前为 nant-0.86-nightly-2009-05-05)。

    【讨论】:

      猜你喜欢
      • 2019-05-08
      • 1970-01-01
      • 2021-05-13
      • 1970-01-01
      • 2011-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多