Task is to form Visual Studio 2010 project so, that during any build or publish some foo.exe
utility should be copied to output (bin
) directory.
Early I have made PostBuildEvent task in .csproj (MSBuild-file):
<PropertyGroup>
<PostBuildEvent>
Copy "$(SolutionDir)Tools\foo.exe" "$(ProjectDir)$(OutDir)foo.exe"
</PostBuildEvent>
</PropertyGroup>
But this is not universal. During publishing (Visual Studio 2010) foo.exe
appears in bin
directory, but is not copied to output publish directory. Maybe I do everything completely wrong and there is standard mechanism to include files in projects to be later, during build or publish, copied to bin
?
There is and it is not dependent on post build events.
Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".
See MSDN.
In Solution Explorer, please select files you want to copied to output directory and assign two properties: - Build action = Content - Copy to Output Directory = Copy Always
This will do the trick.
Try adding a reference to the missing dll's from your service/web project directly. Adding the references to a different project didn't work for me.
I only had to do this when publishing my web app because it wasn't copying all the required dll's.
I only have the need to push files during a build, so I just added a Post-build Event Command Line entry like this:
You can set this by right-clicking your Project in the Solution Explorer, then Properties > Build Events
In my case, setting
Copy to Output Directory
toCopy Always
and Build did not do the trick, while Rebuild did.Hope this helps someone!