I have a Visual Studio 2010 solution with two projects:
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With