Microsoft.Web.Publishing.AllFilesInProjectFolder.targets 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!--
  2. ***********************************************************************************************
  3. Microsoft.Web.Publishing.AllFilesInProjectFolder.targets
  4. WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
  5. created a backup copy. Incorrect changes to this file will make it
  6. impossible to load or build your web deploy projects from the command-line or the IDE.
  7. This file defines the steps in the standard package/publish process for collecting all files in the project folder.
  8. Copyright (C) Microsoft Corporation. All rights reserved.
  9. ***********************************************************************************************
  10. -->
  11. <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  12. <!--Import task from our dll-->
  13. <UsingTask TaskName="CollectFilesinFolder" AssemblyFile="..\Microsoft.Web.Publishing.Tasks.dll"/>
  14. <UsingTask TaskName="EscapeTextForRegularExpressions" AssemblyFile="..\Microsoft.Web.Publishing.Tasks.dll"/>
  15. <UsingTask TaskName="FilterByItems" AssemblyFile="..\Microsoft.Web.Publishing.Tasks.dll"/>
  16. <UsingTask TaskName="GetPublishingLocalizedString" AssemblyFile="..\Microsoft.Web.Publishing.Tasks.dll"/>
  17. <!--ImportBefore Extension-->
  18. <PropertyGroup>
  19. <ImportByWildcardBeforeMicrosoftWebPublishingAllFilesInProjectFolderTargets Condition="'$(ImportByWildcardBeforeMicrosoftWebPublishingAllFilesInProjectFolderTargets)'==''">true</ImportByWildcardBeforeMicrosoftWebPublishingAllFilesInProjectFolderTargets>
  20. </PropertyGroup>
  21. <Import Project="$(MSBuildThisFileDirectory)\$(MSBuildThisFileName)\ImportBefore\*" Condition="'$(ImportByWildcardBeforeMicrosoftWebPublishingAllFilesInProjectFolderTargets)' == 'true' and exists('$(MSBuildThisFileDirectory)\$(MSBuildThisFileName)\ImportBefore')"/>
  22. <PropertyGroup>
  23. <PublishPipelineCollectFilesCore>
  24. $(PublishPipelineCollectFilesCore);
  25. CollectFilesFromProjectFolder;
  26. </PublishPipelineCollectFilesCore>
  27. <_CollectFiles_IncludeIgnorableFile Condition="'$(_CollectFiles_IncludeIgnorableFile)'==''">False</_CollectFiles_IncludeIgnorableFile>
  28. <!--Overwrite the default behavior. Don't remove the web.debug.config -->
  29. <ExcludeTransformAssistFilesFromPublish Condition="'$(ExcludeTransformAssistFilesFromPublish)'==''">False</ExcludeTransformAssistFilesFromPublish>
  30. <CollectFilesFromProjectFolder_ExcludeSccFiles Condition="'$(CollectFilesFromProjectFolder_ExcludeSccFiles)'==''">True</CollectFilesFromProjectFolder_ExcludeSccFiles>
  31. </PropertyGroup>
  32. <!--********************************************************************-->
  33. <!-- Task SetExcludeFromProjectFolder -->
  34. <!--********************************************************************-->
  35. <PropertyGroup>
  36. <SetExcludeFromProjectFolderDependsOn Condition="'$(SetExcludeFromProjectFolderDependsOn)'==''">
  37. </SetExcludeFromProjectFolderDependsOn>
  38. </PropertyGroup>
  39. <Target Name="SetExcludeFromProjectFolder"
  40. DependsOnTargets="$(SetExcludeFromProjectFolderDependsOn)">
  41. <!--Get Localized string before display message-->
  42. <GetPublishingLocalizedString
  43. ID="PublishLocalizedString_DefaultExcludeIntermediateOutputFolderMessage"
  44. LogType="Message" />
  45. <GetPublishingLocalizedString
  46. ID="PublishLocalizedString_DefaultExcludeFileExtentionOutMessage"
  47. LogType="Message" />
  48. <GetPublishingLocalizedString
  49. ID="PublishLocalizedString_DefaultExcludeSourceControlItems"
  50. LogType="Message" />
  51. <!--Maybe we need to introduce @(_ExcludeFromProjectFolder)-->
  52. <ItemGroup>
  53. <!--Split item to _KnowProjectItems is to keep the metadata for item collection.
  54. Please see http://msdn.microsoft.com/en-us/library/bb629388.aspx for known Project item collection.-->
  55. <_KnownProjectItems Include="@(EmbeddedResource)" />
  56. <_KnownProjectItems Include="@(None)" />
  57. <_KnownProjectItems Include="@(Content)" />
  58. <_KnownProjectItems Include="@(Compile)" />
  59. <!--Explicit exclude all files under the obj folder -->
  60. <_ProjectBaseIntermediateOutputPath Include="$(BaseIntermediateOutputPath)"/>
  61. </ItemGroup>
  62. <!--Create the rgulare expression to exclude all root folder *.out, all folder *.scc and all folder*.vspscc file-->
  63. <!--Note split by semicolon (;)-->
  64. <PropertyGroup>
  65. <_ExcludeRelativePathFromProjectFolder>^[^\\]*\.out$</_ExcludeRelativePathFromProjectFolder>
  66. </PropertyGroup>
  67. <!--Create the rgulare expression to exclude all Intermedidate output path.-->
  68. <EscapeTextForRegularExpressions Text="@(_ProjectBaseIntermediateOutputPath->'%(FullPath)')">
  69. <Output TaskParameter="Result" PropertyName="_ExcludeFullPathFromProjectFolder" />
  70. </EscapeTextForRegularExpressions>
  71. </Target>
  72. <!--********************************************************************-->
  73. <!-- Task CollectFilesFromProjectFolder_ExcludeSccFiles -->
  74. <!--********************************************************************-->
  75. <PropertyGroup>
  76. <CollectFilesFromProjectFolder_ExcludeSccFilesDependsOn>
  77. $(OnBeforeCollectFilesFromProjectFolder_ExcludeSccFiles);
  78. $(CollectFilesFromProjectFolder_ExcludeSccFilesDependsOn);
  79. SetExcludeFromProjectFolder;
  80. </CollectFilesFromProjectFolder_ExcludeSccFilesDependsOn>
  81. </PropertyGroup>
  82. <Target Name="CollectFilesFromProjectFolder_ExcludeSccFiles"
  83. DependsOnTargets="$(CollectFilesFromProjectFolder_ExcludeSccFilesDependsOn)"
  84. Condition="$(CollectFilesFromProjectFolder_ExcludeSccFiles)">
  85. <!--Note split by semicolon (;)-->
  86. <PropertyGroup>
  87. <_ExcludeRelativePathFromProjectFolder>$(_ExcludeRelativePathFromProjectFolder);[^\\]*\.scc$;[^\\]*\.vssscc$;[^\\]*\.vspscc$</_ExcludeRelativePathFromProjectFolder>
  88. </PropertyGroup>
  89. <CallTarget Targets="$(OnAfterCollectFilesFromProjectFolder_ExcludeSccFiles)" RunEachTargetSeparately="false" />
  90. </Target>
  91. <!--********************************************************************-->
  92. <!-- Task CollectFilesFromProjectFolder -->
  93. <!--********************************************************************-->
  94. <PropertyGroup>
  95. <CollectFilesFromProjectFolderDependsOn>
  96. $(OnBeforeCollectFilesFromProjectFolder);
  97. $(CollectFilesFromProjectFolderDependsOn);
  98. SetExcludeFromProjectFolder;
  99. CollectFilesFromProjectFolder_ExcludeSccFiles;
  100. </CollectFilesFromProjectFolderDependsOn>
  101. </PropertyGroup>
  102. <Target Name="CollectFilesFromProjectFolder"
  103. DependsOnTargets="$(CollectFilesFromProjectFolderDependsOn)" >
  104. <!--Get Localized string before display message-->
  105. <GetPublishingLocalizedString
  106. ID="PublishLocalizedString_GatherAllFilesInProjectFolderExceptExclusion"
  107. LogType="Message" />
  108. <CollectFilesinFolder RootPath="$(WebPublishPipelineProjectDirectory)"
  109. ExcludeFullPathMatchs="$(_ExcludeFullPathFromProjectFolder)"
  110. ExcludeRelativePathMatchs="$(_ExcludeRelativePathFromProjectFolder)"
  111. SkipHiddenItems="$(_SkipHiddenItems)">
  112. <Output TaskParameter="Result" ItemName="_AllFilesUnderProjectFolderNoMetadata" />
  113. </CollectFilesinFolder>
  114. <!--The first two lines keeps the _KnowProjectItem's item metadata-->
  115. <FilterByItems PipelineItems="@(_AllFilesUnderProjectFolderNoMetadata)"
  116. Filter="@(_KnownProjectItems)">
  117. <Output TaskParameter="OutFilter" ItemName="_AllFilesUnderProjectFolderExceptKnownProjectItems"/>
  118. </FilterByItems>
  119. <ItemGroup>
  120. <!--Readd _KnowProjectItem's to keep item metadata. First for non-Link file -->
  121. <FilesForPackagingFromProject Include="@(_KnownProjectItems)" Condition="'%(_KnownProjectItems.Link)'==''">
  122. <DestinationRelativePath>%(_KnownProjectItems.Identity)</DestinationRelativePath>
  123. <FromTarget>CollectFilesFromProjectFolder.KonwnProjectItems</FromTarget>
  124. <Category>AllFilesInProjectFolder</Category>
  125. </FilesForPackagingFromProject>
  126. <FilesForPackagingFromProject Include="@(_KnownProjectItems)" Condition="'%(_KnownProjectItems.Link)'!='' And $(EnableCollectLinkFilesInProject)">
  127. <DestinationRelativePath>%(_KnownProjectItems.Link)</DestinationRelativePath>
  128. <FromTarget>CollectFilesFromProjectFolder.KonwnProjectItems</FromTarget>
  129. <Category>AllFilesInProjectFolder</Category>
  130. <Exclude>$(ExcludeLinkFilesInProject)</Exclude>
  131. <ProjectFileType>Link</ProjectFileType>
  132. </FilesForPackagingFromProject>
  133. <FilesForPackagingFromProject Include="@(_AllFilesUnderProjectFolderExceptKnownProjectItems)" >
  134. <DestinationRelativePath>%(_AllFilesUnderProjectFolderExceptKnownProjectItems.Identity)</DestinationRelativePath>
  135. <FromTarget>CollectFilesFromProjectFolder.ExceptKonwnProjectItems</FromTarget>
  136. <Category>AllFilesInProjectFolder</Category>
  137. </FilesForPackagingFromProject>
  138. </ItemGroup>
  139. <CallTarget Targets="$(OnAfterCollectFilesFromProjectFolder)" RunEachTargetSeparately="false" />
  140. </Target>
  141. <!--ImportAfter Extension-->
  142. <PropertyGroup>
  143. <ImportByWildcardAfterMicrosoftWebPublishingAllFilesInProjectFolderTargets Condition="'$(ImportByWildcardAfterMicrosoftWebPublishingAllFilesInProjectFolderTargets)'==''">true</ImportByWildcardAfterMicrosoftWebPublishingAllFilesInProjectFolderTargets>
  144. </PropertyGroup>
  145. <Import Project="$(MSBuildThisFileDirectory)\$(MSBuildThisFileName)\ImportAfter\*" Condition="'$(ImportByWildcardAfterMicrosoftWebPublishingAllFilesInProjectFolderTargets)' == 'true' and exists('$(MSBuildThisFileDirectory)\$(MSBuildThisFileName)\ImportAfter')"/>
  146. </Project>