There are two ways to do this:
- Always build B's package after B is built or
- Always build B's package before A is built
The advantage of the first is that A has to know less about B. The advantage of the second is that B can be built during development without the step of building the package.
As you may know, Visual Studio projects are MSBuild projects. You can edit them in Visual Studio by choosing Unload Project and then Edit from the project's context menu in the Solution Explorer. It is often easier and sometimes necessary to add build steps this way than through the Build Events editor. If you want to leave a clue about the customization of the project file, you can add a "rem" command to Pre-build event field.
In either of the above cases, the Package target of project B must be run before the Build target of project A. Choosing the second case above, add this MSBuild task to A's BeforeBuild target.
<MSBuild
Projects="relative-or-absolute/path/to/B.xxproj"
Targets="Package">
</MSBuild>