NAnt资源链接/构建

时间:2012-04-04 07:22:57

标签: vb.net nant

我几乎已经破解了这个NAnt的东西,而我所能说的是Visual Studio在编译时肯定“隐藏”了很多东西。

我现在通过NAnt成功编译了我的VB.NET应用程序,但它没有运行,它出现了错误:

Could not find any resources appropriate for the specified culture or the neutral culture.
Make sure "APP3.Resource.resources" was correctly embedded or linked into assembly "APP3" at compile time, or that all the satellite assemblies required are loadable and fully signed.

当我在Visual Studio中编译并运行时,一切正常。

构建文件包含正在编译的所有项目的所有.resx文件,在NAnt构建过程中我没有收到任何错误。

任何想法都将受到赞赏: - )

哦,我注意到我的EXE小了6kb,所以显然缺少某些东西,并且NAnt进程似乎也没有创建清单文件,或者所有XML文件,我认为这是正常的?

<?xml version="1.0"?>
<project name="APP3" default="build" basedir="..\">
<description>APP3 build</description>
<property name="nant.settings.currentframework" value="net-3.5" />
<property name="projectversion" value="3.8.0" />
<property name="project.config" value="debug" />

<target name="init">
    <call target="${project.config}" />
</target>

<target name="debug">
    <property name="project.config" value="debug" />
    <property name="build.debug" value="true" />
    <property name="basedir.suffix" value="-debug" />
</target>

<target name="release">
    <property name="project.config" value="release" />
    <property name="build.debug" value="false" />
    <property name="basedir.suffix" value="-release" />
</target>

<target name="clean">
    <delete file="${project::get-base-directory()}${project::get-name()}_${projectversion}${basedir.suffix}\APP3_DataClasses.dll" failonerror="false" />
    <delete file="${project::get-base-directory()}${project::get-name()}_${projectversion}${basedir.suffix}\classUtilities.dll" failonerror="false" />
    <delete file="${project::get-base-directory()}${project::get-name()}_${projectversion}${basedir.suffix}\APP3.exe" failonerror="false" />
</target>

<target name="build-classutilities" depends="init, clean" description="compiles the     APP3 utilities class">
    <property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}_${projectversion}${basedir.suffix}"/>
    <mkdir dir="${build.dir}" />
    <vbc target="library" output="${build.dir}/classUtilities.dll" debug="${build.debug}" rootnamespace="classUtilities">
        <imports>
            <import namespace="Microsoft.VisualBasic" />
            <import namespace="System" />
            <import namespace="System.Collections" />
            <import namespace="System.Collections.Generic" />
            <import namespace="System.Data" />
            <import namespace="System.Diagnostics" />
            <import namespace="System.Linq" />
            <import namespace="System.Xml.Linq" />
        </imports>
        <sources>
            <include name="${project::get-base-directory()}/classUtilities/Utilities.vb" />
        </sources>
        <resources>
            <include name="${project::get-base-directory()}/classUtilities/*.resx" />
            <include name="${project::get-base-directory()}/classUtilities/My Project/*.resx" />
        </resources>
        <references>
            <include name="System.dll" />
            <include name="System.Data.dll" />
            <include name="System.Core.dll" />
            <include name="System.Xml.dll" />
            <include name="System.Xml.Linq.dll" />
        </references>
    </vbc>
</target>

<target name="build-dataclasses" depends="build-classutilities" description="compiles the APP3 data classes">
    <property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}_${projectversion}${basedir.suffix}"/>
    <mkdir dir="${build.dir}" />
    <vbc target="library" output="${build.dir}/APP3_DataClasses.dll" debug="${build.debug}" rootnamespace="APP3_DataClasses">
        <imports>
            <import namespace="Microsoft.VisualBasic" />
            <import namespace="System" />
            <import namespace="System.Collections" />
            <import namespace="System.Collections.Generic" />
            <import namespace="System.Configuration" />
            <import namespace="System.Data" />
            <import namespace="System.Diagnostics" />
            <import namespace="System.Xml" />
            <import namespace="System.Xml.Linq" />
            <import namespace="Iesi.Collections" />
        </imports>
        <sources>
            <include name="${project::get-base-directory()}/APP3_DataClasses/**/*.vb" />
        </sources>
        <resources prefix="APP3_DataClasses">
            <include name="${project::get-base-directory()}/APP3_DataClasses/*.resx" />
            <include name="${project::get-base-directory()}/APP3_DataClasses/My Project/*.resx" />
            <include name="${project::get-base-directory()}/APP3_DataClasses/*.hbm.xml" />
        </resources>
        <references>
            <include name="System.dll" />
            <include name="System.Core.dll" />
            <include name="System.Xml.dll" />
            <include name="System.Xml.Linq.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\Iesi.Collections.dll" />
        </references>
    </vbc>
</target>

<target name="build" description="compiles the source code" depends="build-dataclasses">
    <property name="build.dir" value="${project::get-base-directory()}/${project::get-name()}_${projectversion}${basedir.suffix}"/>
    <mkdir dir="${build.dir}" />
    <copy file="C:\Dev\NHibernate-2.1.2\Required_Bins\NHibernate.dll" tofile="${build.dir}/NHibernate.dll" />
    <copy file="C:\Dev\NHibernate-2.1.2\Required_Bins\Iesi.Collections.dll" tofile="${build.dir}/Iesi.Collections.dll" />
    <copy file="C:\Dev\NHibernate-2.1.2\Required_Bins\log4net.dll" tofile="${build.dir}/log4net.dll" />
    <copy file="${project::get-base-directory()}/APP3/hibernate.cfg.xml" tofile="${build.dir}/hibernate.cfg.xml" />
    <copy file="C:\Dev\LumenWorks.Framework\LumenWorks.Framework.3.8.0\LumenWorks.Framework.IO.dll" tofile="${build.dir}/LumenWorks.Framework.IO.dll" />
    <copy file="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.Office.Interop.Word.dll" tofile="${build.dir}/Microsoft.Office.Interop.Word.dll" />
    <copy file="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\office.dll" tofile="${build.dir}/office.dll" />
    <copy file="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.Vbe.Interop.dll" tofile="${build.dir}/Microsoft.Vbe.Interop.dll" />
    <copy file="${project::get-base-directory()}/APP3/app.config" tofile="${build.dir}/APP3.exe.config" />
    <copy todir="${build.dir}">
        <fileset basedir="C:\Dev\NHibernate-2.1.2\Required_For_LazyLoading\Castle\">
            <include name="*.dll" />
        </fileset>
    </copy>
    <vbc target="winexe" output="${build.dir}/APP3.exe" debug="${build.debug}" rootnamespace="APP3">
        <imports>
            <import namespace="Microsoft.VisualBasic" />
            <import namespace="System" />
            <import namespace="System.Collections" />
            <import namespace="System.Collections.Generic" />
            <import namespace="System.Configuration" />
            <import namespace="System.Data" />
            <import namespace="System.Data.SqlClient" />
            <import namespace="System.Diagnostics" />
            <import namespace="System.Drawing" />
            <import namespace="System.Windows.Forms" />
            <import namespace="System.IO" />
            <import namespace="System.Xml" />
        </imports>
        <sources>
            <include name="${project::get-base-directory()}/${project::get-name()}/*.vb" />
            <include name="${project::get-base-directory()}/${project::get-name()}/classes/*.vb" />
            <include name="${project::get-base-directory()}/${project::get-name()}/historical/*.vb" />
            <include name="${project::get-base-directory()}/${project::get-name()}/Modules/*.vb" />
            <include name="${project::get-base-directory()}/${project::get-name()}/My Project/*.vb" />
        </sources>
        <resources prefix="APP3" dynamicprefix="true">
            <include name="${project::get-base-directory()}/${project::get-name()}/*.resx" />
            <include name="${project::get-base-directory()}/${project::get-name()}/My Project/*.resx" />
        </resources>
        <references>
            <include name="Microsoft.VisualBasic.dll" />
            <include name="System.dll" />
            <include name="System.Data.dll" />
            <include name="System.Windows.Forms.dll" />
            <include name="System.configuration.dll" />
            <include name="System.Drawing.dll" />
            <include name="${build.dir}/APP3_DataClasses.dll" />
            <include name="${build.dir}/classUtilities.dll" />
            <include name="System.Xml.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\Iesi.Collections.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\NHibernate.dll" />
            <include name="C:\Dev\NHibernate-2.1.2\Required_Bins\log4net.dll" />
            <include name="C:\Dev\LumenWorks.Framework\LumenWorks.Framework.3.8.0\LumenWorks.Framework.IO.dll" />
            <include name="C:\Program Files (x86)\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.Office.Interop.Word.dll" />
        </references>
    </vbc>
</target>

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,然后用程序.NET Reflector测试了每个程序集我发现当从VS编译程序时,程序集中的资源文件Properties \ Resources.resx有一个名字的 appName.Properties.Resources.resources 即可。当你使用nAnt时

<resources>
    <include name="${proj_dir}/Properties/Resources.resx"/>
</ resources>
程序集资源文件中的

名称为 Resources.resources

我解决了这个问题如下。

<target name="example">
    <copy file="${proj_dir}/Properties/Resources.resx" tofile="${proj_dir}/Properties/appName.Properties.Resources.resx"/>
    <csc target="winexe" output="${bin_dir}/appName.exe">
        <sources>
            <include name="${proj_dir}/*.cs"/>
            <include name="${proj_dir}/Properties/*.cs"/>                           
        </sources>
            <resources>
            <include name="${proj_dir}/Properties/appName.Properties.Resources.resx"/>
        </resources>
    </csc>
    <delete file="${proj_dir}/Properties/appName.Properties.Resources.resx"/>
</target>