如何在 NANT 或 csc.exe 中包含对 Web 服务的引用?

发布于 2024-10-03 15:34:43 字数 891 浏览 0 评论 0原文

我正在尝试自动化我们的构建过程。为此,我需要将 asp.Net 网站中的 app_code 编译为 dll,以便我可以针对代码运行 NUnit 测试。在你建议我只使用类库之前,我会说我同意你的观点,但是我的上级持不同的观点并否决了在我们的网站中使用 dll。

我遇到的问题是 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>

如果有其他方法可以实现我的目标,请告诉我。

Im trying to automate our build process. To do this i need to compile the app_code in a asp.Net website to a dll so i can run NUnit test against the code. Before you suggest that i just use a class library, i will say that i agree with you, my superiors however, take a different view and have vetoed the use of dlls in our web sites.

The problem i have is that the app_code classes reference web services. How do i get the csc task to include these when compiling the code into a class library? The nant target i have so far is:

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

If there is another way of achieving my goals then please let me know.

Al

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

睫毛溺水了 2024-10-10 15:34:43

您最有可能要做的是生成 Web 服务代理类并将其编译到您的项目中。为此,请查看 wsdl 任务,该任务是 NantContrib

您将能够执行如下操作:

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

What you're most likely after is generating the web service proxy class and compiling that into into your project. To do this, have a look at the wsdl task that is part of NantContrib.

You'll be able to do something like the following:

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

You can then take the output of that task (MyProxy.cs) and compile it into your project.

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文