msbuild copy task not working correctly on publish

Vote:
 

I have several Copy tasks in the AfterBuild target of my project. Some copy dll dependencies to the /bin folder by using the $(TragetDir) variable ($(OutDir) works too). This works fine.

But then I have some files that should go in the web root, i.e. one level above the bin folder. I have the DestinationFolder for these set to $(TargetDir)\..\%(RecursiveDir). This works fine when i build the project and the files end up where they should. But when I do a publish from VS the ".." seems to be ignored - the files end up in the bin folder.

I know I could solve this by declaring my own variable with a static path, but I want to be able to automatically get the files in the right place, no matter if it is built locally or when doing a publish.

#44964
Oct 22, 2010 10:59
Vote:
 

It turns out that the files in the bin folder were not the ones i tired to copy. In fact, nothing is copied at all. This is logical because the publish option only includes files belonging to the project and files that are needed to run the project. But how can I hook into the publish task to include my own files?

#44969
Oct 22, 2010 13:15
Vote:
 

This is how you make it work with web deploy, the target you should extend is CopyAllFilesToSingleFolderForPackageDependsOn and stuff your files in the FilesForPackagingFromProject collection. More details: http://stackoverflow.com/questions/3137880/how-to-get-visual-studio-publish-functionality-to-include-files-from-post-build

#51518
Jun 11, 2011 9:34
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.