在 Visual Studio 中构建 WCF 项目时的输出目录 [英] Output directory when building a WCF project in Visual Studio

查看:27
本文介绍了在 Visual Studio 中构建 WCF 项目时的输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个设置为在 Debug x86 中构建的 Visual Studio 2010 解决方案.因此,Visual Studio 将输出路径设置为 \bin\x86\Debug,这似乎很合乎逻辑.

I have a Visual Studio 2010 solution that is set to build in Debug x86. Visual Studio therefore sets the output path to \bin\x86\Debug, which seems logical enough.

该解决方案包含约50个项目;启动项目是WCF项目.

The solution contains about 50 projects; the start-up project is a WCF project.

当我进行构建时,我希望所有输出 dll 都转到 \bin\x86\Debug,因为这是在项目设置中设置的.但奇怪的是,我看到在 bin\x86\Debug 中的 \bin 中创建了 dll.如果输出路径未设置为该目录,为什么 Visual Studio 会将任何 dll 放在 \bin 中?好像所有的dll都去\bin\x86\Debug,所有的dll除了启动项目都去\bin.知道为什么会这样做吗?(我们有其他不使用 WCF 的解决方案,他们没有这个问题.)

When I do a build, I would expect all output dlls to go to \bin\x86\Debug, as that is what is set in the project settings. But weirdly, I see dlls being created in bin\x86\Debug and in \bin. Why would Visual Studio put any dll in \bin if the output path is not set to that directory? It seems that all dlls go to \bin\x86\Debug, and all dlls except for the start-up project go into \bin. Any idea why it would do that? (We have other solutions that don't use WCF, and they don't have this problem.)

另一个烦恼是,如果我从 Visual Studio 运行服务,然后尝试在 Web 浏览器中访问我的服务,方法是转到 http://localhost:1240/MyService.svc,它不起作用,因为/bin中缺少启动项目dll.因此,我必须手动将这个 dll 从 \bin\x86\Debug 复制到 \bin,以便找到所有 dll 并且服务正常运行.(我们当然可以添加一个自定义的构建后步骤来进行复制,但您会认为会有更好的方法!)

The other annoyance is if I run the service from Visual Studio and then try to access my service in a web browser, by going to http://localhost:1240/MyService.svc, it doesn't work, because the start-up project dll is missing from /bin. I therefore have to manually copy this one dll from \bin\x86\Debug to \bin, so that all dlls are found and the service runs normally. (We could of course add a custom post-build step that does the copy, but you'd think there'd be a better way!)

对于那些在 WCF 项目中工作的人,您是否将输出路径保留在 \bin\x86\Debug 中?(也许有一种方法可以配置服务,例如在 web.config 或 .svc 文件中,以便它知道二进制文件位于 \bin\x86\Debug 而不是 \bin?)或者您是否将输出路径更改为\bin 以便您可以直接从 Visual Studio 运行您的服务?

To those of you working on WCF projects, do you leave the output path at \bin\x86\Debug? (Perhaps there is a way to configure the service, eg in the web.config or .svc file, so that it knows the binaries are in \bin\x86\Debug instead of \bin?) Or do you change the output path to \bin so that you can run your service straight from Visual Studio?

推荐答案

如果您打开 WCF Hosting 项目的属性页并转到选项卡 Build,则在此标记的输出部分下有一个文本框,其中包含输出二进制文件.

If you open the property page of you WCF Hosting project and goto tab Build, under the Output section of this tag there is a textbox that contains the location of the output binaries.

对于 WCF 项目,无论构建类型如何(例如调试、发布),二进制文件都应转到 bin 目录.确保此值已正确配置.

For a WCF project the binaries should go to bin directory irrespective of the build type (suc as Debug, Release). Make sure this value has been configured correctly.

需要为每个构建类型\配置配置该值.

The value needs to be configured for each build type\configuration.

这篇关于在 Visual Studio 中构建 WCF 项目时的输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆