2010-11-23 66 views
3

我试图自动化我们的构建过程。为此,我需要将asp.Net网站中的app_code编译为dll,以便我可以对代码运行NUnit测试。在你建议我只使用一个类库之前,我会说我同意你的观点,然而,我的上级却采取了不同的观点,并否决了我们网站中dll的使用。如何在NANT或csc.exe中包含对Web服务的引用?

我遇到的问题是app_code类引用了Web服务。如何在将代码编译到类库中时将csc任务包括在内?我目前为止的目标是:

<target name="Compile"> 
    <property name="nant.settings.currentframework" value="net-3.5" /> 
    <csc target="library" output="DocSysAppCode.dll" debug="true"> 
     <sources> 
     <include name="D:\Inetpub\DocSys\App_Code\Common\*.cs" /> 
     <include name="D:\Inetpub\DocSys\App_Code\DocSys\SiteLegislation.generated.cs" /> 
     </sources> 
     <resources> 
     <include name="D:\DocSysQueue\Web References\WS_DocSys\*.*" /> 
     <include name="D:\DocSysQueue\app.config" /> 
     </resources> 
    </csc> 
</target> 

如果还有其他方法可以实现我的目标,那么请让我知道。

回答

1

你最有可能后生成的Web服务代理类,并在编译成到您的项目是什么。为此,请查看NantContrib中的wsdl任务。

你就可以做一些类似如下:

<target name="generate-proxy"/> 
    <wsdl path="${wsdl.url}" language="CS" namespace="svc" outfile="MyProxy.cs" verbose="true" /> 
</target> 

然后,您可以采取的任务(MyProxy.cs)的输出,它编译到您的项目。

<target name="Compile" depends="generate-proxy"> 
    <property name="nant.settings.currentframework" value="net-3.5" /> 
    <csc target="library" output="DocSysAppCode.dll" debug="true"> 
     <sources> 
     <include name="MyProxy.cs" /> 
     <include name="D:\Inetpub\DocSys\App_Code\Common\*.cs" /> 
     <include name="D:\Inetpub\DocSys\App_Code\DocSys\SiteLegislation.generated.cs" /> 
     </sources> 
    </csc> 
</target> 
+0

谢谢,在发布这个问题后不久,我发现了wsdl.exe – 2010-11-25 09:01:44

相关问题