Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't my project reference being picked up by the web deployment packaging in Visual Studio?

I have a Visual Studio 2010 solution with two projects:

  1. An ASP.NET MVC 3 web application.
  2. A class library.

The MVC application has a project reference to the class library.

When I use the "Build Deployment Package" option in Visual Studio to build the zip file with my web application for deployment, it does not include the class library. Thus, after deploying, I get an exception due to the missing assembly.

I have verified that the project reference is set to "Copy Local = true." When you build and debug the site, things work fine and the class library is in the bin folder. It's only when you build the deployment package that it goes missing.

If I switch from a project reference to a direct assembly reference, pointing to the bin/Debug/ClassLibrary.dll file, the package properly builds and includes the class library. I only see the issue when it's a project reference.

How can I get the class library as a project reference to be properly included in the web application package?

like image 748
Travis Illig Avatar asked Nov 14 '22 19:11

Travis Illig


1 Answers

I'm not sure how to fix this if you're doing the deploy from VS.NET, but I did figure out how to do it from a MSBuild script.

The basic syntax to create an MSDeploy/WebDeploy .zip package for a .csproj in MSBuild is like this:

<MSBuild Projects="Path\To\Project.csproj"
         Targets="ResolveReferences;Package"
         Properties="Configuration=Release;DeployOnBuild=true;DeployTarget=Package;PackageLocation=Path\To\Output.zip" />

Note the Targets="ResolveReferences;Package". I started with Targets="Package", but that only half works.

Apparently, if you want to get the assemblies created from project references, you need to call ResolveReferences first. Just building the package won't do that, and you'll be missing any assemblies that are included in the project output as the result of project references.

like image 182
Chris Hynes Avatar answered Dec 22 '22 07:12

Chris Hynes