NAnt和MSBuild命令行问题 [英] NAnt and MSBuild command line woes

查看:152
本文介绍了NAnt和MSBuild命令行问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将NAnt配置为自动化我的构建过程-一旦确定了这一步骤,我将集成单元测试.

I'm trying to configure NAnt to automate my build process - once I've got this step nailed, I'll be integrating the unit tests.

也许我不完全知道我想要什么,所以如果有完全不同的方式来完成所有这些操作,请纠正我...

Perhaps I don't exactly know what I want, so please correct me if there is a completely different way of doing all of this...

我想要两个NAnt目标,一个快速执行,调试构建以确保一切正常且测试通过,另一个目标进行正确的编译和发布(它是一个Web应用程序项目)

I want two NAnt targets, one to do quick, debug builds to make sure everything works and the tests pass, and another target to do a proper compile and publish (its a web application project)

我的问题是...

  1. 我无法让MSBuild仅编译dll,它总是与之一起复制所有Web应用程序的垃圾文件(图像,css,.aspx文件等).有办法阻止这种情况吗?如果可以,怎么办?
  2. 当我使用/t:Compile进行编译时,它仍为dll创建.pdb文件.这样对吗?我以为这些是供调试器使用的,因此在进行发行版编译时不应该出现这些内容吗?

这是完整发布(发布)的NAnt目标:

here is my NAnt target for the full release compile (publish):

<target name="build.deploy" description="Compile Web Site." depends="init">
    <exec basedir="." program="C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe" commandline=" MyProj/Interface/Interface.csproj /nologo
        /t:Compile
        /t:ResolveReferences;_CopyWebApplication
        /p:OutDir=../../deploy/bin/
        /p:WebProjectOutputDir=../../deploy/;AspNetConfiguration=Release"
        workingdir="." failonerror="true" />
</target>

感谢您的帮助!

P.S.如果有更简单的方法,我不必使用msbuild.我尝试首先使用CSC,但无法解决我遇到的所有引用问题.建议非常欢迎

P.S. I dont have to use msbuild if there is an easier way. I tried to use CSC first, but I couldnt resolve all the referencing problems i was getting. Suggestions very welcome

推荐答案

我建议不要使用直接调用MSBuild的方法,而是使用 msbuild任务.

Rather than invoke MSBuild directly, I'd suggest using the NAnt-Contrib msbuild task.

例如,在我的协议缓冲区项目中,我有以下内容:

For instance, in my Protocol Buffers project I have this:

<target name="build"
        description="Builds all C# code">
  <msbuild project="${src}/ProtocolBuffers.sln">
    <property name="Configuration"
              value="${build-configuration}" />
  </msbuild>
</target>

build-configurationRelease时,它不会构建PDB.这取决于您如何在Visual Studio中设置项目-您可以仍然可以为优化的发行版构建PDB.

When build-configuration is Release it doesn't build the PDBs. This depends on how you've got the project set up in Visual Studio though - you can still build PDBs for the optimised release version.

至于额外的垃圾"内容-它会执行Visual Studio中的任何构建.如果您可以在VS中搞乱,以所需的方式切换各种选项,那么它也可以在NAnt/MSBuild中正常工作.

As for the "extra junk" stuff - it will do whatever a build in Visual Studio does. If you can mess around in VS to switch various options the way you want them, it should work fine from NAnt/MSBuild too.

这篇关于NAnt和MSBuild命令行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆