I'm trying to include a file in an ASP.NET filesystem publish that's not included in the solution (it's autogenerated from a post-build script). According to these instructions, I should be able to add a reference to the file in my .pubxml
definition using the <_CustomFiles>
element. Here's what my .pubxml
file looks like:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>(publish URL here)</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
</PropertyGroup>
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="scripts\app.min.js" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Extra Files\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
</Project>
The second <PropertyGroup>
and the <Target>
elements were added by me.
However, Visual Studio isn't recognizing the <_CustomFiles>
element and the file isn't being included in the publish. Notice the green squiggly line underneath the element:
When I hover over it, the following error message is shown:
The element 'ItemGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element '_CustomFiles' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'
Why is this element not recognized by Visual Studio? What do I need to change in order to include this file in my filesystem publish?
Figured it out. I misunderstood the purpose of the <_CustomFiles>
element. It seems this is a custom element (i.e. not part of the XML schema, hence the VS warning) used to pass information to the <FilesForPackaginFromProject>
element below it.
It turns out this method was working for me, I was simply using the relative paths incorrectly.