This issue that App_Plugins get published is actually configured by the UmbracoCms package from NuGet. It allows you to publish the project including Umbraco. But it adds additional folders as well. When installing Umbraco on the project, it adds 2 Import
to the .csproj file.
<Import Project="..\packages\UmbracoCms.{version_number}\build\UmbracoCms.props" Condition="Exists('..\packages\UmbracoCms.{version_number}\build\UmbracoCms.props')" />
<Import Project="..\packages\UmbracoCms.{version_number}\build\UmbracoCms.targets" Condition="Exists('..\packages\UmbracoCms.{version_number}\build\UmbracoCms.targets')" />
In this UmbracoCms.props
file it refers to the property CopyAllFilesToSingleFolderForPackageDependsOn
that is defined in MSBuild.
This task gets executed when the files are being packaged.
Within this property, it mentions the task AddUmbracoFilesToOutput
.
This task is found in the UmbracoCms.targets
.
Within this task, it defines a task named FilesForPackagingFromProject
which is used in WebDeploy. In this task it uses all the Elements named CustomFilesToInclude
. As you can see there is the following line:
<CustomFilesToInclude Include=".\App_Plugins\**\*">
<Dir>App_Plugins</Dir>
</CustomFilesToInclude>
It does not matter if you exclude the files, it will always be adding this because of the above line.
How to resolve this?
We cannot change this UmbracoCms.targets
file so we have to take other options since we don't want to change the way Umbraco has specified these files.
What we can do is specifying excludes ourselves by doing this thesame way Umbraco did.
Add a new Target, an ItemGroup and add the element ExcludeFromPackageFolders
, specify the Include
attribute and fill this with the values.
<Target Name="ExcludeUmbracoFormsData">
<ItemGroup>
<ExcludeFromPackageFolders Include="App_Plugins\UmbracoForms\Data">
</ExcludeFromPackageFolders>
</ItemGroup>
</Target>
Then add a PropertyGroup with the Property CopyAllFilesTOSingleFolderForPackageDependsOn
and specify the name of the target you just created.
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
ExcludeUmbracoFormsData;
</CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
Alternative