构建异常“目标” '此项目中不存在”从 CCNET 1.6 调用 NAnt 0.91 时

发布于 2024-12-05 03:30:26 字数 2666 浏览 1 评论 0原文

我正在重构现有的 NAnt 构建脚本,以便能够在几乎任何项目中使用它们,并从 CruiseControl .NET 发送正确的值。不过,我遇到了一个问题,即目标设置不正确。

我已将对 NAnt 的调用定义如下:

  <tasks>
    <nant>
      <executable>$(NAntExecutablePath)</executable>
      <buildFile>D:\ci\default.build.xml</buildFile>
      <!--baseDirectory></baseDirectory-->
      <buildArgs>
        -D:SolutionFile="$(Batch_WorkingFolderTrunk)\MySolution.sln"
        -D:LocalDeployRoot=D:\ci\deploy\MyProject
      </buildArgs>
      <targetList>
        <target>build</target>
      </targetList>
    </nant>
  </tasks>

并且我的构建文件具有所需的任务

  <target name="clean">
    <exec program="${MSBuildPath}">
      <arg line='"${SolutionFile}"' />
      <arg line="/property:Configuration=${SolutionConfiguration}" />
      <arg value="/target:Clean" />
      <arg value="/verbosity:normal" />
      <arg value="/nologo" />
      <arg line='/logger:"${CcnetMsbuildLoggerPath}"' if="${file::exists('${CcnetMsbuildLoggerPath}')}"/>
    </exec>

    <delete>
      <fileset basedir=".">
        <include name="bin\**\*" />
        <include name="TestResults\**\*" />
      </fileset>
    </delete>
  </target>

      <target name="build" depends="clean">

        <delete>
          <fileset basedir="${LocalDeployRoot}">
            <include name="**\*"/>
          </fileset>
        </delete>

        <exec program="${MSBuildPath}">
          <arg line='"${SolutionFile}"' />
          <!--arg line='/property:Configuration="${SolutionConfiguration}"' /-->
          <arg line='/property:OutputPath="${LocalDeployRoot}"' />
          <!--arg line='/property:Platform="${SolutionPlatform}"' /-->
          <arg value="/target:Rebuild" />
          <arg value="/verbosity:normal" />
          <arg value="/nologo" />
          <arg line='/logger:"${CcnetMsbuildLoggerPath}"' if="${file::exists('${CcnetMsbuildLoggerPath}')}"/>
        </exec>
      </target>

我的错误消息指出

目标框架:Microsoft .NET Framework 4.0 指定目标:
构建

 [echo] 启动构建脚本

构建失败

此项目中不存在目标“ ”。

总时间:0.1秒。

有什么想法吗?

我可以通过命令行成功运行 NAnt 脚本:

D:\ci>nant-0.91\bin\nant.exe /f:default.build.xml build -D:SolutionFile="D:\ci\code\MyProject\MySolution.sln" -D:LocalDeployRoot= D:\ci\deploy\MyProject

I am refactoring my existing NAnt build scripts to be able to use them on just about any project and have the proper values sent over from CruiseControl .NET. I've come across an issue, though, where the Target isn't being set correctly.

I have defined my call to NAnt as follows:

  <tasks>
    <nant>
      <executable>$(NAntExecutablePath)</executable>
      <buildFile>D:\ci\default.build.xml</buildFile>
      <!--baseDirectory></baseDirectory-->
      <buildArgs>
        -D:SolutionFile="$(Batch_WorkingFolderTrunk)\MySolution.sln"
        -D:LocalDeployRoot=D:\ci\deploy\MyProject
      </buildArgs>
      <targetList>
        <target>build</target>
      </targetList>
    </nant>
  </tasks>

and my build file has the required required tasks

  <target name="clean">
    <exec program="${MSBuildPath}">
      <arg line='"${SolutionFile}"' />
      <arg line="/property:Configuration=${SolutionConfiguration}" />
      <arg value="/target:Clean" />
      <arg value="/verbosity:normal" />
      <arg value="/nologo" />
      <arg line='/logger:"${CcnetMsbuildLoggerPath}"' if="${file::exists('${CcnetMsbuildLoggerPath}')}"/>
    </exec>

    <delete>
      <fileset basedir=".">
        <include name="bin\**\*" />
        <include name="TestResults\**\*" />
      </fileset>
    </delete>
  </target>

      <target name="build" depends="clean">

        <delete>
          <fileset basedir="${LocalDeployRoot}">
            <include name="**\*"/>
          </fileset>
        </delete>

        <exec program="${MSBuildPath}">
          <arg line='"${SolutionFile}"' />
          <!--arg line='/property:Configuration="${SolutionConfiguration}"' /-->
          <arg line='/property:OutputPath="${LocalDeployRoot}"' />
          <!--arg line='/property:Platform="${SolutionPlatform}"' /-->
          <arg value="/target:Rebuild" />
          <arg value="/verbosity:normal" />
          <arg value="/nologo" />
          <arg line='/logger:"${CcnetMsbuildLoggerPath}"' if="${file::exists('${CcnetMsbuildLoggerPath}')}"/>
        </exec>
      </target>

My error message states

Target framework: Microsoft .NET Framework 4.0 Target(s) specified:
build

 [echo] Starting the build script

BUILD FAILED

Target ' ' does not exist in this project.

Total time: 0.1 seconds.

Any ideas out there?

I can run the NAnt script successfully via the command line:

D:\ci>nant-0.91\bin\nant.exe /f:default.build.xml build -D:SolutionFile="D:\ci\code\MyProject\MySolution.sln" -D:LocalDeployRoot=D:\ci\deploy\MyProject

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寒江雪… 2024-12-12 03:30:26

这似乎是 v1.4.4.83 之后一段时间引入的错误。解决方案是将节点更改为单行。在我的版本 1.4.4.83 配置中,我将 buildArgs 选项放在单独的行上以提高可读性。

我的解决方案是

<buildArgs>
  -D:SolutionFile="$(Batch_WorkingFolderTrunk)\MySolution.sln"
  -D:LocalDeployRoot=D:\ci\deploy\MyProject
</buildArgs>

改为

<buildArgs>-D:SolutionFile="$(Batch_WorkingFolderTrunk)\MySolution.sln" -D:LocalDeployRoot=D:\ci\deploy\MyProject</buildArgs>

This appears to be a bug introduced some time after v1.4.4.83. The solution was to change the node to be a single line. In my version 1.4.4.83 configuration, I have the buildArgs options on separate lines for increased readability.

My solution was to change

<buildArgs>
  -D:SolutionFile="$(Batch_WorkingFolderTrunk)\MySolution.sln"
  -D:LocalDeployRoot=D:\ci\deploy\MyProject
</buildArgs>

to

<buildArgs>-D:SolutionFile="$(Batch_WorkingFolderTrunk)\MySolution.sln" -D:LocalDeployRoot=D:\ci\deploy\MyProject</buildArgs>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文