Since I just did something similar, despite the age of this question, thatβs what I ended up doing. It is not perfect, but it works.
Set the post-build event in the project that you are actually building. In the build event, you can reference your current location using the $(ProjectDir) variable. Set up a path that points to the "normal" location of the DLL that you will need after creating it. I think in your case it will be the bin directory of the NServiceBus project.
You can get to the _PublishedWebsites directory using the $(WebProjectOutputDir) variable. When created locally, this points to the same directory as the built project. However, when msbuild is invoked with a non-standard output directory (aka from TFS), it changes to the publication directory.
xcopy /Y /S "$(ProjectDir)..\path to needed dll" "$(WebProjectOutputDir)\bin"
Your assemblies should work both locally and in your build environment using this script. The only downside is that it is a little fragile because you need to specify the exact name and relative location of the missing DLLs.
source share