I know this question mentions Visual Studio 2010
but I got here looking for the same problem...
I'm using Visual Studio 2012
and found a nice/elegant way to overcome this annoying situation. I think it'll also work in VS 2010
and is better than adding dummy empty files inside the empty folders.
When you create a publish profile with VS 2012
it will generate a MyPublishProfile.pubxml
file in the Properties\PublishProfiles
folder (My Project\PublishProfiles
for VB). These are MSBuild
files and one can edit them to customize the publish process. In our case we can inject a target into the publish process, before the publish actually occurs like this:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<AfterAddIisSettingAndFileContentsToSourceManifest>CreateEmptyFolders
</AfterAddIisSettingAndFileContentsToSourceManifest>
</PropertyGroup>
<Target Name="CreateEmptyFolders">
<Message Text="Adding empty folder to hold Files" />
<MakeDir Directories="$(_MSDeployDirPath_FullPath)\Files\MyEmptyFolder"/>
</Target>
</Project>
The property AfterAddIisSettingAndFileContentsToSourceManifest
holds the names of targets that will be invoked after the contents for the deployment package has been prepared. This is the perfect time to add additional files or folders to the package.
Code and text mixed from:
How to execute a PowerShell script only before a web deploy Publish task in VS 2012?
Web Deploy : Customizing a deployment package