Visual Studio 2010 发布 Web 功能不包括所有 DLL

发布于 2024-09-01 04:08:44 字数 595 浏览 10 评论 0原文

我有一个 ASP.NET MVC 2 应用程序。

  • Web 项目包含对 SomeProject 的引用
  • SomeProject 包含对ExternalAssembly1 和ExternalAssembly2 的引用。
  • SomeProject 显式调用ExternalAssembly1,但不调用ExternalAssembly2。
  • ExternalAssembly1 调用ExternalAssembly2

当我执行本地构建时, 一切都很酷。所有 DLL 都包含在 bin\debug 文件夹中。问题是,当我在 Visual Studio 2010 中使用“发布 Web”命令时,它会部署除ExternalAssembly2 之外的所有内容。

它似乎忽略了不直接使用的程序集(请记住,ExternalAssembly2 仅由ExternalAssembly1 使用)。

有什么方法可以告诉 Visual Studio 2010 包含ExternalAssembly2吗?

我可以编写一个调用ExternalAssembly2 的虚拟方法。这确实有效,但我真的不想让虚拟代码仅用于导致 VS2010 发布 DLL。

I have an ASP.NET MVC 2 application.

  • Web project contains a reference to SomeProject
  • SomeProject contains references to ExternalAssembly1 and ExternalAssembly2.
  • SomeProject explicitly calls into ExternalAssembly1, but NOT ExternalAssembly2.
  • ExternalAssembly1 calls into ExternalAssembly2

When I perform a local build everything is cool. All DLLs are included in the bin\debug folder. The problem is that when I use the Publish Web command in Visual Studio 2010, it deploys everything except ExternalAssembly2.

It appears to ignore assemblies that aren't directly used (remember, ExternalAssembly2 is only used by ExternalAssembly1).

Is there any way I can tell Visual Studio 2010 to include ExternalAssembly2?

I can write a dummy method that calls into ExternalAssembly2. This does work, but I really don't want to have dummy code for the sole purpose of causing VS2010 to publish the DLL.

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

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

发布评论

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

评论(13

‖放下 2024-09-08 04:08:45

在我看来,这些答案都不够。这似乎确实是一个真正的错误。如果我找到非黑客解决方案,或者微软修复了该错误,我将更新此回复。

更新:

似乎没有希望。
https://connect.microsoft .com/VisualStudio/feedback/details/731303/publish-web-feature-not-include-all-dlls

None of these answers are sufficient in my mind. This does seem to be a genuine bug. I will update this response if I ever find a non-hack solution, or Microsoft fixes the bug.

Update:

Doesn't seem promising.
https://connect.microsoft.com/VisualStudio/feedback/details/731303/publish-web-feature-not-including-all-dlls

猫腻 2024-09-08 04:08:45

我遇到了同样的问题(尽管不同的程序集)。如果我在 Web 项目中引用程序集,那么它们将包含在发布输出中,但无论如何都应该包含它们,因为它们是间接依赖项:

Web Project --->组件A--->程序集 B

构建时,程序集 A 和 B 将输出到 \bin 文件夹。发布时,仅程序集 A 输出到发布文件夹。

我尝试更改发布设置以包含 Web 项目中的所有 文件,但发布输出中存在不应部署的文件。

这对我来说似乎是一个错误。

I am having this same problem (different assemblies though). If I reference the assemblies in my web project, then they will get included in the publish output, but they should be included anyway because they are indirect dependencies:

Web Project ---> Assembly A ---> Assembly B

On build, assemblies A and B are outputed to the \bin folder. On publish, only assembly A is outputed to the publish folder.

I have tried changing the publish settings to include all files in the web project, but then I have files in my publish output that shouldn't be deployed.

This seems like a bug to me.

笑着哭最痛 2024-09-08 04:08:45

我在使用 VS2010 和 WCF 服务应用程序时遇到了同样的问题。

事实证明,如果您(直接或间接)引用的 DLL 部署到 GAC,则 VS 发布功能会将它们排除在外。当我从 GAC 中删除程序集后,发布功能就开始按预期工作。

我猜 VS 假设如果您的程序集可以位于您构建的计算机上的 GAC 中,那么它们也将位于目标计算机上的 GAC 中。至少就我而言,这个假设是错误的。

I had the same problem with VS2010 and a WCF Service Application.

It turns out that if your (directly or indirectly) referenced DLL's are deployed to GAC, the VS publishing feature excludes them. Once I removed the assemblies from GAC, publishing feature started working as expected.

I guess VS is assuming that if your assemblies can be located in GAC on the machine you build, they will be located in GAC on the target machine as well. At least in my case this assumption is false.

比忠 2024-09-08 04:08:45

我的测试表明,当我在 Web 项目中引用外部程序集时,它们就会被发布。我不必编写任何虚拟代码即可使其工作。这对我来说似乎是可以接受的。

我同意尼古拉斯的观点,这似乎是视觉工作室中的一个错误。至少我不知道这种行为的原因是什么。

My tests show that the external assemblies get published when I have a reference on them in the web project. I do not have to write any dummy code to make it work. This seems acceptable to me.

I agree with Nicholas that this seems to be a bug in visual studio. At least it escapes me what the reason for the behavior could be.

隔纱相望 2024-09-08 04:08:45

我已将此问题创建为 Microsoft Connect 上的错误。如果有人遇到它可以投票 https://connect.microsoft.com/VisualStudio/feedback/details/637071/publish-web-feature-not-include-all-dlls 然后希望我们能解决这个问题。

I have created this issue as a bug on Microsoft Connect. If anyone experiencing it could vote it up https://connect.microsoft.com/VisualStudio/feedback/details/637071/publish-web-feature-not-including-all-dlls then hopefully we'll get something done about it.

青春如此纠结 2024-09-08 04:08:45

如果您进入ExternalAssembly2参考属性列表并将“Copy Local”更改为“True”,我认为这可能会解决您的问题。

If you go into the ExternalAssembly2 reference property list and change the "Copy Local" to "True" i think that might solve your issue.

儭儭莪哋寶赑 2024-09-08 04:08:45

我不知道您是否仍在观看此内容,但我通过 这篇 MSDN 文章。在文件的“构建操作”下,选择“内容”,应将其包含在发布带来的文件列表中。

I don't know if you are watching this still but I found the solution (I had the exact same issue) via this MSDN article. Under "build action" for the file choose "Content" that should include it in the list of files publish brings over.

笔落惊风雨 2024-09-08 04:08:45

我在这里创建了一个新的连接错误 https://connect.microsoft.com/VisualStudio/feedback/details/731303/publish-web-feature-not-include-all-dlls

我还附上了重现此问题的解决方案和详细步骤。希望这次他们不会因为无法复制而关闭它。

如果您遇到缺少 dll 的问题,请为此连接问题投票。

I have created a new Connect bug here https://connect.microsoft.com/VisualStudio/feedback/details/731303/publish-web-feature-not-including-all-dlls

I've also attached a solution and detailed steps to reproduce this issue. Lets hope this time they won't close it as Can't Reproduce.

Vote for this connect issue if you experience the missing dll problem.

忆依然 2024-09-08 04:08:45

复制本地就成功了。我遇到了 Newtonsoft.Json 程序集包含在部署包中的问题。复制本地设置为 false。

Copy local did the trick. I had an issue that the Newtonsoft.Json assembly get included in the deploymeny package. Copy local was set to false.

惟欲睡 2024-09-08 04:08:45

我在网络项目中遇到了同样类型的问题。我有一个 Web 项目,它引用程序集 A,而程序集 A 又引用程序集 B。它运行良好一段时间,但今天坏了。我重建了解决方案,这次它正确部署了所有内容。

I am experiencing the same type of issue with a web project. I have a web project that references assembly A which references assembly B. It worked fine for some time but today it was broken. I did a rebuild of the solution and this time it deployed everything correctly.

记忆消瘦 2024-09-08 04:08:45

我今天也遇到了同样的问题。我发布了我的 Web 项目,并意识到并非所有参考 DLL 都在那里。特别是间接 DLL 引用。

事实证明,我发布到的目录磁盘空间不足(网络共享)。我有足够的空间来发布除少数间接引用 DLL 之外的所有文件。可悲的是 VS08 没有抛出任何错误。刚刚发布的文件很平常。我清理了一些硬盘空间,一切正常。

直到我尝试手动移动 DLL 才发现 HDD 空间问题。

I had this same problem today. I published my web project and realized that not all of the reference DLL's were there. In particular, the indirect DLL references.

It turns out that the directory in which I was publishing to was out of disk space (network share). I had just enough space to publish all the files except for few indirect reference DLL's. The sad part is that VS08 didn't throw any errors. It just published the files are usual. I cleared out some HDD space and everything worked fine.

I didn't find the HDD space issue until I tried to manually move the DLL's over.

满地尘埃落定 2024-09-08 04:08:45

就我而言,这是相当棘手的。
构建项目不需要引用ExternalAssembly2,但对于运行时至关重要,因为我们使用反射来配置Unity容器。
因此,我删除了引用 - 成功构建了项目,但出现运行时错误。
如果我保留引用,我可以构建并运行应用程序,但无法使用ExternalAssembly2 发布它 - 也会出现运行时异常。
这是由于内部 VS2010 程序集优化而发生的。

那么,我们在这里能做什么呢?
1. 放置一些不需要的代码来使用任何ExternalAssembly2 的类。
2. 逃避反射并使用静态程序集链接。

希望这对smbd有帮助。

in my case it is quite tricky.
Reference to ExternalAssembly2 is not required to Build the project but vital for run-time since we use reflection to configure Unity container.
So, I delete the reference - build the project successfully, but get run-time error.
If I preserve the reference I can Build and Run the application but I cannot Publish it with ExternalAssembly2 - get run-time exception as well.
This is happen because of internal VS2010 assemblies optimization.

So, what we can do here?
1. Put some unrequired peice of code to use any ExternalAssembly2's class.
2. escape from reflection and use static assemblies linking.

Hope this helps to smbd.

爱人如己 2024-09-08 04:08:45

我遇到了同样的问题,如果有类似的参考链接,这是一个 VS2010 错误:
网络项目 -->自定义项目 --> assembly1 -->(间接) assembly2。

现在我发现如果我在Web项目中引用Assembly1,那么Assembly2就会包含在bin文件夹中。
所以我必须添加一个额外的参考链接,例如:
网络项目--> assembly1 -->(间接) assembly2。
然后VS可以识别程序集2并将其dll文件包含在发布操作中。

I got the same problem and this is a VS2010 bug if there's a reference link like:
Web Project --> custom project --> assembly1 -->(indirectly) assembly2.

For now I find if I reference the Assembly1 in the web project, then assembly2 is included in the bin folder.
So I had to add an additional reference link like:
Web project --> assembly1 -->(indirectly) assembly2.
Then VS can recognize assembly2 and include its dll file in publish action.

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