Visual Studio 2010 Publish Web feature not including all DLLs

DeploymentVisual Studio-2010asp.net Mvc-2Build ProcessMsdeploy

Deployment Problem Overview


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.

Deployment Solutions


Solution 1 - Deployment

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

Solution 2 - Deployment

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.

Solution 3 - Deployment

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.

Solution 4 - Deployment

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.

Solution 5 - Deployment

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.

Solution 6 - Deployment

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

Solution 7 - Deployment

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.

Solution 8 - Deployment

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.

Solution 9 - Deployment

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.

Solution 10 - Deployment

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.

Solution 11 - Deployment

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.

Solution 12 - Deployment

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.

Solution 13 - Deployment

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionreustmdView Question on Stackoverflow
Solution 1 - DeploymentreustmdView Answer on Stackoverflow
Solution 2 - DeploymentNicholas CloudView Answer on Stackoverflow
Solution 3 - DeploymentAntti RauhalaView Answer on Stackoverflow
Solution 4 - DeploymentStefan EgliView Answer on Stackoverflow
Solution 5 - DeploymenttgallardView Answer on Stackoverflow
Solution 6 - DeploymentPaul LemkeView Answer on Stackoverflow
Solution 7 - DeploymentScott ChamberlainView Answer on Stackoverflow
Solution 8 - DeploymentmdonatasView Answer on Stackoverflow
Solution 9 - DeploymentMaurice CGP PetersView Answer on Stackoverflow
Solution 10 - DeploymentNJ3181View Answer on Stackoverflow
Solution 11 - DeploymentEbbnFlowView Answer on Stackoverflow
Solution 12 - DeploymentIgorView Answer on Stackoverflow
Solution 13 - DeploymentChris LiView Answer on Stackoverflow