2012-04-04 119 views
0

我已經幾乎破解了這個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較小,所以一些明顯缺失,而南特過程似乎沒有可以創建一個清單文件,或所有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> 

+0

出於好奇,爲了更好的背景:爲什麼你需要用NAnt構建?現在,您可以使用NAnt自定義的所有內容都可以在MSbuild中使用,除了命令行工具之外,您還可以直接從VS執行構建。 – skolima 2012-04-04 07:29:23

+0

好問題,說實話,我只是需要一些能夠在我們的新CI服務器(Atlassian Bamboo)上編譯的東西,我看到它同時兼有NAnt和MSBuild。如果MSBuild更容易在這種情況下工作,那麼CI服務器沒有安裝任何類型的VS,就是.NET框架。在過去的.NET 2.0 msbuild中,我們遇到了一些問題,無法獲取DLL的引用路徑(它只會選擇1),但如果可以克服,那就沒有問題了。 – Dominik 2012-04-04 07:34:32

+0

MSBuild在3.5和4.0版本中得到了很大改進,4.0終於與NAnt進行了功能校驗。它和一個普通的.Net Framework安裝一起安裝。 – skolima 2012-04-04 10:07:33

回答

0

我面臨同樣的問題,然後進行測試每個我發現,當一個程序從VS,資源文件屬性\資源編譯程序的.NET反射器組件.resx在程序集中有一個名稱appName.Properties.Resources.resources。當您在程序集資源文件中使用楠

<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> 
+0

很好的答案!對於任何人來說,我也在https://support.microsoft.com/en-us/kb/839861上找到了這個。「當你運行Resgen.exe時,如果你在轉換一個文件時沒有指定輸出文件的文件名基於XML的資源格式(.resx)文件添加到.resources文件中,Resgen.exe將創建與輸入文件具有相同文件名的.resources文件。如果基於XML的資源格式文件的文件名不是以應用程序的名稱空間名稱開頭,那麼.resources文件的文件名也不會包含此名稱空間名稱。「 – clairestreb 2016-10-13 16:38:18