Reputation: 7449
I am using Umbraco Forms and do not want that the forms included on the development environment are included on the production environment; however I would like them to be included in source control.
Therefore my current setup includes the files under source control as per standard; however to exclude the forms data (App_Plugins/UmbracoForms/Data) I excluded the folder from the project (.CSPROJ). The problem is that after publishing (to file), the data files are always being included anyway, even if they are excluded.
Is there something else going on in the build process that is copying these files to the publish directory?
Upvotes: 1
Views: 791
Reputation: 81
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
Upvotes: 1
Reputation: 1056
It sort of depends on how you are doing the publish. If you are just publishing through visual studio, you can add some parameters to the PropertyGroups of your csproj.
<ExcludeFoldersFromDeployment>App_Plugins\UmbracoForms\Data</ExcludeFoldersFromDeployment>
There is also some talk about doing this here: Web Deployment FAQ. If you do some googling about ExcludeFoldersFromDeployment
you'll find some other ways to do this if you are calling MSBuild yourself.
/p:ExcludeFoldersFromDeployment="App_Plugins\UmbracoForms\Data"
Upvotes: 0