我已经将我的应用程序从.NET 1.1转换为.NET 3.5,不幸的是NAnt的标签不支持.NET 3.5。所以我试图使用标签直接启动msbuild。
以下是我对.NET 1.1的看法:
<solution solutionfile="MyApp.sln"
configuration="ServerDebug" outputdir="MyApp\bin\ServerDebug">
<assemblyfolders>
<include name="Dependencies\Libs\bin\ServerDebug"/>
</assemblyfolders>
</solution>
我将其转换为
<exec program="msbuild">
<arg value="MyApp.sln /p:Configuration=ServerDebug;OutDir=bin\ServerDebug\" />
</exec>
所以一切都运行正常,除了我无法弄清楚如何复制真正方便的标签,这给了编译器一个关于在哪里寻找依赖的提示。
我将什么传递给msbuild来复制功能?
答案 0 :(得分:5)
我认为可以使用以下两个选项中的一个来完成。使用 AdditionalLibPaths 或 AssemblySearchPaths ,其中描述了on MSDN。
如下所示:
<exec program="msbuild.exe">
<arg line="/p:Configuration=ServerDebug"/>
<arg line="/p:OutDir=bin\ServerDebug\" />
<arg line="/p:AssemblySearchPaths=Dependencies\Libs\bin\ServerDebug" />
<arg line="MyApp.sln" />
</exec>
答案 1 :(得分:3)
通过将以下内容添加到NAnt.exe.config,我能够使用.NET 3.5获得NAnt 0.86。这样做之后,project
标签内的构建文件中的这一位就是我所需要的。
<property name="nant.settings.currentframework" value="net-3.5" />
添加到NAnt.exe.config:
<framework
name="net-3.5"
family="net"
version="2.0"
description="Microsoft .NET Framework 3.5"
sdkdirectory="${path::combine(sdkInstallRoot, 'bin')}"
frameworkdirectory="${path::combine(installRoot, 'v3.5')}"
frameworkassemblydirectory="${path::combine(installRoot, 'v2.0.50727')}"
clrversion="2.0.50727"
>
<runtime>
<probing-paths>
<directory name="lib/net/2.0" />
<directory name="lib/net/neutral" />
<directory name="lib/common/2.0" />
<directory name="lib/common/neutral" />
</probing-paths>
<modes>
<strict>
<environment>
<variable name="COMPLUS_VERSION" value="v2.0.50727" />
</environment>
</strict>
</modes>
</runtime>
<reference-assemblies basedir="${path::combine(installRoot, 'v2.0.50727')}">
<include name="Accessibility.dll" />
<include name="mscorlib.dll" />
<include name="Microsoft.Build.Utilities.dll" />
<include name="Microsoft.Vsa.dll" />
<include name="Microsoft.VisualBasic.dll" />
<include name="Microsoft.VisualBasic.Compatibility.dll" />
<include name="Microsoft.VisualBasic.Compatibility.Data.dll" />
<include name="System.Configuration.dll" />
<include name="System.Configuration.Install.dll" />
<include name="System.Data.dll" />
<include name="System.Data.OracleClient.dll" />
<include name="System.Data.SqlXml.dll" />
<include name="System.Deployment.dll" />
<include name="System.Design.dll" />
<include name="System.DirectoryServices.dll" />
<include name="System.dll" />
<include name="System.Drawing.Design.dll" />
<include name="System.Drawing.dll" />
<include name="System.EnterpriseServices.dll" />
<include name="System.Management.dll" />
<include name="System.Messaging.dll" />
<include name="System.Runtime.Remoting.dll" />
<include name="System.Runtime.Serialization.Formatters.Soap.dll" />
<include name="System.Security.dll" />
<include name="System.ServiceProcess.dll" />
<include name="System.Transactions.dll" />
<include name="System.Web.dll" />
<include name="System.Web.Mobile.dll" />
<include name="System.Web.RegularExpressions.dll" />
<include name="System.Web.Services.dll" />
<include name="System.Windows.Forms.dll" />
<include name="System.Xml.dll" />
</reference-assemblies>
<reference-assemblies basedir="${environment::get-folder-path('ProgramFiles')}/Reference Assemblies/Microsoft/Framework/v3.5">
<include name="Microsoft.Build.Engine.dll" />
<include name="Microsoft.Build.Framework.dll" />
<include name="System.AddIn.Contract.dll" />
<include name="System.AddIn.dll" />
<include name="System.Core.dll" />
<include name="System.Data.DataSetExtensions.dll" />
<include name="System.Data.Linq.dll" />
<include name="System.DirectoryServices.AccountManagement.dll" />
<include name="System.Management.Instrumentation.dll" />
<include name="System.Net.dll" />
<include name="System.ServiceModel.Web.dll" />
<include name="System.Web.Extensions.Design.dll" />
<include name="System.Web.Extensions.dll" />
<include name="System.Windows.Presentation.dll" />
<include name="System.WorkflowServices.dll" />
<include name="System.Xml.Linq.dll" />
</reference-assemblies>
<reference-assemblies basedir="${environment::get-folder-path('ProgramFiles')}/Reference Assemblies/Microsoft/Framework/v3.0">
<include name="System.IdentityModel.dll" />
<include name="System.IdentityModel.Selectors.dll" />
<include name="System.IO.Log.dll" />
<include name="System.Printing.dll" />
<include name="System.Runtime.Serialization.dll" />
<include name="System.ServiceModel.dll" />
<include name="System.Speech.dll" />
<include name="System.Workflow.Activities.dll" />
<include name="System.Workflow.ComponentModel.dll" />
<include name="System.Workflow.Runtime.dll" />
<include name="WindowsBase.dll" />
</reference-assemblies>
<task-assemblies>
<!-- include MS.NET version-neutral assemblies -->
<include name="extensions/net/neutral/**/*.dll" />
<!-- include MS.NET 2.0 specific assemblies -->
<include name="extensions/net/2.0/**/*.dll" />
<!-- include MS.NET specific task assembly -->
<include name="NAnt.MSNetTasks.dll" />
<!-- include MS.NET specific test assembly -->
<include name="NAnt.MSNet.Tests.dll" />
<!-- include .NET 2.0 specific assemblies -->
<include name="extensions/common/2.0/**/*.dll" />
</task-assemblies>
<tool-paths>
<directory name="${path::combine(sdkInstallRoot, 'bin')}" />
<directory name="${path::combine(installRoot, 'v3.5')}" />
<directory name="${path::combine(installRoot, 'v2.0.50727')}" />
</tool-paths>
<project>
<readregistry
property="installRoot"
key="SOFTWARE\Microsoft\.NETFramework\InstallRoot"
hive="LocalMachine" />
<readregistry
property="sdkInstallRoot"
key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.1\WinSDKNetFxTools\InstallationFolder"
hive="LocalMachine"
failonerror="false" />
<property name="frameworkDirectoryV35" value="${path::combine(installRoot, 'v3.5')}" />
<fail if="${not(directory::exists(frameworkDirectoryV35))}">The Framework directory for .NET 3.5 does not exist.</fail>
<property name="referenceV35" value="${environment::get-folder-path('ProgramFiles')}/Reference Assemblies/Microsoft/Framework/v3.5" />
<fail if="${not(directory::exists(referenceV35))}">The Reference Assemblies directory for .NET 3.5 does not exist.</fail>
</project>
<tasks>
<task name="csc">
<attribute name="exename">${path::combine(frameworkDirectoryV35,'csc.exe')}</attribute>
<attribute name="supportsnowarnlist">true</attribute>
<attribute name="supportswarnaserrorlist">true</attribute>
<attribute name="supportskeycontainer">true</attribute>
<attribute name="supportskeyfile">true</attribute>
<attribute name="supportsdelaysign">true</attribute>
<attribute name="supportsplatform">true</attribute>
<attribute name="supportslangversion">true</attribute>
</task>
<task name="vbc">
<attribute name="exename">${path::combine(frameworkDirectoryV35,'vbc.exe')}</attribute>
<attribute name="supportsdocgeneration">true</attribute>
<attribute name="supportsnostdlib">true</attribute>
<attribute name="supportsnowarnlist">true</attribute>
<attribute name="supportskeycontainer">true</attribute>
<attribute name="supportskeyfile">true</attribute>
<attribute name="supportsdelaysign">true</attribute>
<attribute name="supportsplatform">true</attribute>
<attribute name="supportswarnaserrorlist">true</attribute>
</task>
<task name="jsc">
<attribute name="supportsplatform">true</attribute>
</task>
<task name="vjc">
<attribute name="supportsnowarnlist">true</attribute>
<attribute name="supportskeycontainer">true</attribute>
<attribute name="supportskeyfile">true</attribute>
<attribute name="supportsdelaysign">true</attribute>
</task>
<task name="resgen">
<attribute name="supportsassemblyreferences">true</attribute>
<attribute name="supportsexternalfilereferences">true</attribute>
</task>
<task name="al">
<attribute name="exename">${path::combine(sdkInstallRoot, 'bin/al.exe')}</attribute>
</task>
<task name="delay-sign">
<attribute name="exename">sn</attribute>
</task>
<task name="license">
<attribute name="exename">lc</attribute>
<attribute name="supportsassemblyreferences">true</attribute>
</task>
</tasks>
</framework>
答案 2 :(得分:1)
我现在已经与Nant和CC.Net进行配置管理了一段时间。我的经验我不建议使用Nant MSBuild任务,而最简单的方法是创建和任务,创建任务执行的.bat文件。有几个原因建议使用命令行Visual Studio,因为即使您使用contrib,也不能使用Nant轻松构建一个MSI包。这种方式更简单,更快捷。
--------- 2.0 ------------- “C:\ Program Files \ Microsoft Visual Studio 8 \ Common7 \ IDE \ devenv”C:\ YourProject \ YourSoultion.sln / Rebuild release
3.5 ---------- -------------- “C:\ Program Files \ Microsoft Visual Studio 9.0 \ Common7 \ IDE \ devenv”C:\ YourProject \ YourSoultion.sln / Rebuild release