问题
I need to exclude folders media, umbraco and umbraco_client from the publication of the project. These folders are rarely changed and I do not want to wait each time until they are copied during the publication on the FTP server. Here is my config local.pubxml:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>My_path</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeFoldersFromDeployment>media;umbraco;umbraco_client</ExcludeFoldersFromDeployment>
<MSDeployUseChecksum>true</MSDeployUseChecksum>
<AfterAddIisSettingAndFileContentsToSourceManifest>AddCustomSkipRules</AfterAddIisSettingAndFileContentsToSourceManifest>
</PropertyGroup>
<Target Name="AddCustomSkipRules">
<Message Text="Adding Custom Skip Rules" />
<ItemGroup>
<MsDeploySkipRules Include="SkipmediaFolder">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\media</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUmbracoFolder">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\umbraco</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUmbraco_clientConfig">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\umbraco_client</AbsolutePath>
<XPath>
</XPath>
</MsDeploySkipRules>
</ItemGroup>
</Target>
</Project>
After that media folder is not published, but umbraco and umbraco_client folders still continue to copy in the process of publication. After that, I excluded umbraco and umbraco_client folders from the project, but it also does not solve the problem. Any ideas? :)
回答1:
I make this work after some problems, perhaps it helps your case:
1.- Move your MsDeploySkipRules in a separate file named yourprojectname.wpp.targets in the same folder as .csproj, with the following content (you must put a filePath and dirPath for each folder with its wildcards):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<MsDeploySkipRules Include="SkipmediaFolderFiles">
<SkipAction></SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\media\\.*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipmediaFolderChildFolders">
<SkipAction></SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\media\\.*\\*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUmbracoFolderFiles">
<SkipAction></SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\umbraco\\.*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUmbracoFolderChildFolders">
<SkipAction></SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\umbraco\\.*\\*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUmbraco_clientFolderFiles">
<SkipAction></SkipAction>
<ObjectName>filePath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\umbraco_client\\.*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
<MsDeploySkipRules Include="SkipUmbraco_clientFolderChildFolders">
<SkipAction></SkipAction>
<ObjectName>dirPath</ObjectName>
<AbsolutePath>$(_DestinationContentPath)\\umbraco_client\\.*\\*</AbsolutePath>
<Apply>Destination</Apply>
<XPath></XPath>
</MsDeploySkipRules>
</ItemGroup>
</Project>
2.- After that (VERY IMPORTANT) save the file, close your Visual Studio and open it again. Many people fail at this point (they modify the file and try to deploy again without closing VS, and then they do not appreciate any change and they wrongly believe it does not work).
3.- Try to publish again.
Tested in Visual Studio 2015.
来源:https://stackoverflow.com/questions/39574562/excluding-folders-from-visual-studio-2015-publication