First of all, if your going to use the Web Deployment Project to compile your DNN site/module you will want to spend some time at MSBulid site reading. Once you have setup your web deployment project (in my case I selected Merge each individual folder output to its own assembly) and build you will get an error with DNN 4.3.5 (and probably others) and the message is: aspnet_merge.exe" exited with code 1.
The first thing that you should do is go the ToolsàOptions menu in Visual Studio and under Project and Solutions select Build and Run. Then change the MSBuild verbosity to Diagnostic. This will cause the compiler to output details about what is wrong.
In my case, I discovered that there were two controls within the DNN code base (I had used the starter kit for this site) that are sharing the same code behind file. Since my option was to build all folders into it’s own .dll, the DNN code base is also compiled out. Since sharing the same code file is not allowed the compiler will generate the very helpful message above.
After changing the setting for Studio and compile you can look through the output and should find a message(s) regarding this. To resolve the problem you can exclude two files called: admin\containers\actions.ascx and admin\skins\menu.ascx. I have found other posts that these files aren’t used by DNN anyway. If the end goal is to create a DNN package install anyway, they won’t be included in your package. Another possible solution which I did not try is to use a setting called ExcludeFromBuild in the ItemGroup section of your build project to exclude all DNN folders.