views:

612

answers:

5

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.

+1  A: 

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

Paul Lemke
Thanks for the response, but that's already set (which is why the local build works). This doesn't solve the publishing issue.
manu08
+1  A: 

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.

Nicholas Cloud
I agree. For now I think I'm going to leave in the dummy method that just calls into each DLL I need to be published.
manu08
+1  A: 

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.

Stefan Egli
It's still a hack though. I shouldn't have to reference assemblies in my Web project that aren't used in the Web project. What happens in 6 months when we decide to cleanup unused assembly references?
manu08
+2  A: 

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.

manu08
A: 

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.

Scott Chamberlain
Thanks. I'll test it out when I get a chance and update accordingly
manu08
This appears to work, but again, if VS2010 can figure out what it needs to copy to bin\debug to run, it should use the same logic (at least for the minimum set of files) when it publishes.
manu08