Try our conversational search powered by Generative AI!

msbuild copy task not working correctly on publish


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.

Oct 22, 2010 10:59

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?

Oct 22, 2010 13:15

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:

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.