NAnt< msbuild>定制输出目录 [英] NAnt <msbuild> custom output directory

查看:151
本文介绍了NAnt< msbuild>定制输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NAnt的新手,已经能够创建<target>其中

1)从当前文件夹中删除任何代码

2)从SVN导出新代码

3)在默认目录PrecompiledWeb文件夹(它是一个Web应用程序)中构建代码

这里是:

<target name="export" description="export code from svn">
    <delete dir="${Delete.Dir}"></delete>
    <exec program="svn" commandline="export ${MySVN.Repos} ${MySVN.Dest}" />
    <msbuild project="${Solution.Filename}">
        <property name="Configuration" value="Release"/>
    </msbuild>
</target>

我想指定一个自定义输出目录("PrecompiledWeb"除外).这可能吗,请您告诉我必要的标签/属性吗?

谢谢!

编辑

多亏了Scott和Si,我离解决方案越来越近了,但是我仍然没有任何可行的方法.那里的评论使我在 MSBuild的输出路径属性.使用他们的代码:

<?xml version="1.0"?>
<project name="test" default="build" basedir="." xmlns="http://nant.sf.net/schemas/nant-0.84.win32.net-1.0.xsd">
    <target name="build">
        <exec program="${framework::get-framework-directory('net-3.5')}/msbuild.exe">
          <arg value="${Full.Path}\Code\MySolution.sln" />
          <arg value="/p:OutputPath=${Full.Path}\Output\" />
        </exec>
    </target>
</project>

这将成功运行;但是,在我的包含网站和类库的解决方案中,它会将类库dll发布到指定的输出路径,但它会 still 将实际网站发布到默认的PrecompiledWeb文件夹.

有人对从NAnt更改PrecompiledWeb文件夹路径有任何建议吗?

再次感谢所有得到帮助的人!

编辑2个最终解决方案

这是我终于能够开始工作的地方(针对.net 4更新):

<exec program="${framework::get-framework-directory('net-4.0')}/msbuild.exe">
    <arg value="${Full.Path}\Code\MySolution.sln" />
    <arg value="/t:Rebuild" />
    <arg value="/t:ResolveReferences" />
    <arg value="/t:_CopyWebApplication" />
    <arg value="/p:OutDir=${Build.Output}bin\" />
    <arg value="/p:WebProjectOutputDir=${Build.Output}" />
    <arg value="/p:Configuration=Release" />
</exec>

解决方案

一个可以指定并覆盖msbuild的某些属性.为了指定输出目录,请覆盖 OutputDir 属性.

<target name="export" description="export code from svn">
        <delete dir="${Delete.Dir}" />
        <exec program="svn" commandline="export ${MySVN.Repos} ${MySVN.Dest}" />
        <msbuild project="${Solution.Filename}">
            <property name="Configuration" value="Release"/>
            <property name="OutputDir" value="${Output.Dir}"/>
        </msbuild>
</target>

I'm new to NAnt and have been able to create a <target> which

1) Deletes any code from the current folder

2) Exports fresh code from SVN

3) Builds the code in the default directory which is the PrecompiledWeb folder (its a web app)

Here it is:

<target name="export" description="export code from svn">
    <delete dir="${Delete.Dir}"></delete>
    <exec program="svn" commandline="export ${MySVN.Repos} ${MySVN.Dest}" />
    <msbuild project="${Solution.Filename}">
        <property name="Configuration" value="Release"/>
    </msbuild>
</target>

I want to specify a custom output directory (other than "PrecompiledWeb"). Is this possible and could you please show me the necessary tag/property?

Thank you!

EDIT

Thanks to Scott and Si, I'm getting closer to a solution, but I still don't have anything that works. There comments led me to this article on MSBuild's Output Path Property. Using their code:

<?xml version="1.0"?>
<project name="test" default="build" basedir="." xmlns="http://nant.sf.net/schemas/nant-0.84.win32.net-1.0.xsd">
    <target name="build">
        <exec program="${framework::get-framework-directory('net-3.5')}/msbuild.exe">
          <arg value="${Full.Path}\Code\MySolution.sln" />
          <arg value="/p:OutputPath=${Full.Path}\Output\" />
        </exec>
    </target>
</project>

This will sucessfully run; however, in my solution which contains a web site and a class library, it publishes the class library dll to the specified output path, but it still publishes the actual web site to the default PrecompiledWeb folder.

Does anyone have any suggestions for how to change the PrecompiledWeb folder path from NAnt?

Thanks again to everyone who's helped!

Edit 2 Final Solution

Here is what I finally was able to get working (updated for .net 4):

<exec program="${framework::get-framework-directory('net-4.0')}/msbuild.exe">
    <arg value="${Full.Path}\Code\MySolution.sln" />
    <arg value="/t:Rebuild" />
    <arg value="/t:ResolveReferences" />
    <arg value="/t:_CopyWebApplication" />
    <arg value="/p:OutDir=${Build.Output}bin\" />
    <arg value="/p:WebProjectOutputDir=${Build.Output}" />
    <arg value="/p:Configuration=Release" />
</exec>

解决方案

One can specify and override some of properties for msbuild. In order to specify the output directory, override the OutputDir property.

<target name="export" description="export code from svn">
        <delete dir="${Delete.Dir}" />
        <exec program="svn" commandline="export ${MySVN.Repos} ${MySVN.Dest}" />
        <msbuild project="${Solution.Filename}">
            <property name="Configuration" value="Release"/>
            <property name="OutputDir" value="${Output.Dir}"/>
        </msbuild>
</target>

这篇关于NAnt&lt; msbuild&gt;定制输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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