Visual Studio 2010 Publish Web feature not includi

2019-03-08 22:25发布

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.

13条回答
一夜七次
2楼-- · 2019-03-08 22:46

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.

查看更多
做个烂人
3楼-- · 2019-03-08 22:48

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.

查看更多
放我归山
4楼-- · 2019-03-08 22:48

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.

查看更多
干净又极端
5楼-- · 2019-03-08 22:52

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.

查看更多
女痞
6楼-- · 2019-03-08 22:55

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.

查看更多
祖国的老花朵
7楼-- · 2019-03-08 22:56

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

查看更多
登录 后发表回答