1

I'm working on an ASP.NET Project which can be published on a server by right-clicking the project in the project explorer of Visual Studio and selecting "Publish". On the server is a folder called "pictures" which shall not be removed while publishing. So i added a wpp.targets file to my project (in the same folder as the csproj file), but it seems to be that this file doesn't work when i use the publish function of VS.

What can be the cause for it?

This is my wpp.targets file:

<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <IncludeSetACLProviderOnDestination>False</IncludeSetACLProviderOnDestination>
  </PropertyGroup>
  <Target Name="AddCustomSkipRules">
    <Message Text="Adding Custom Skip Rules" />
    <ItemGroup>
      <MsDeploySkipRules Include="SkipDeletingPicturesFolder">
        <SkipAction>Delete</SkipAction>
        <ObjectName>filePath</ObjectName>
        <AbsolutePath>pictures</AbsolutePath>
      </MsDeploySkipRules>
    </ItemGroup>
  </Target>
</Project>
Patrick Pirzer
  • 1,649
  • 3
  • 22
  • 49
  • Check your publish profile. In VS right-click on your website -> Publish -> Settings -> Expand "File publish options" -> uncheck "Remove additional files at destination". – derloopkat Sep 27 '16 at 11:55
  • In the publish-dialog i have just the options "Remove all files before publish", "Precompile while publishing" and "Exclude files from the folder App_Data". "Remove additional files at destination" would be nice, but where is it? In my case i'm using VS Professional 2013. – Patrick Pirzer Sep 27 '16 at 12:14
  • I have VS 2013, it may be that you have a different version. – derloopkat Sep 27 '16 at 12:32
  • @derloopkat: "Remove additional files at destination" has replaced "Remove all files before publishing" in VS 2015. Unfortunately not in VS 2013. – Patrick Pirzer Sep 27 '16 at 12:32
  • In your code "pictures" doesn't look like an AbsolutePath. See for example http://stackoverflow.com/a/29688263/2516718 – derloopkat Sep 27 '16 at 12:50

1 Answers1

1

drag and drop a file into the pictures folder in solution explorer.then publish. your folder will now be available after publishing. I usually just drop a random image into the folder. remember the file has to be dropped into the folder in the solution explorer and not using your windows file explorer. having a file in your folder basically tell that this folder needs to be published.

Sujit.Warrier
  • 2,815
  • 2
  • 28
  • 47