Microsoft.WebSite.Publishing.targets 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <!--
  2. ***********************************************************************************************
  3. Microsoft.WebDeploy.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 build process for web deploy projects.
  8. Copyright (C) 2005 Microsoft Corporation. All rights reserved.
  9. ***********************************************************************************************
  10. -->
  11. <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  12. <UsingTask TaskName="FilterByItems" AssemblyFile="$(MSBuildThisFileDirectory)\Microsoft.Web.Publishing.Tasks.dll" Condition="Exists('Microsoft.Web.Publishing.Tasks.dll')"/>
  13. <UsingTask TaskName="CollectFilesinFolder" AssemblyFile="$(MSBuildThisFileDirectory)\Microsoft.Web.Publishing.Tasks.dll" Condition="Exists('Microsoft.Web.Publishing.Tasks.dll')"/>
  14. <UsingTask TaskName="CopyPipelineFiles" AssemblyFile="$(MSBuildThisFileDirectory)\Microsoft.Web.Publishing.Tasks.dll" Condition="Exists('Microsoft.Web.Publishing.Tasks.dll')"/>
  15. <!--***************************************************************-->
  16. <!-- Setting up the property like MS.Common.Targets files has it. -->
  17. <!--This is to handle some project doesn't include the MS.Common.Targets file-->
  18. <!--***************************************************************-->
  19. <PropertyGroup>
  20. <_WebProjectType>WebSite</_WebProjectType>
  21. <OutputPath Condition="'$(OutputPath)' == ''">$([System.IO.Path]::GetTempPath())WebSitePublish\$([System.IO.Path]::GetFileName($(MSBuildProjectDirectory)))-$(MSBuildProjectDirectory.GetHashCode())</OutputPath>
  22. <OutputPath Condition="'$(OutputPath)' != '' and !HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath>
  23. <OutDir Condition=" '$(OutDir)' == '' ">$(OutputPath)</OutDir>
  24. <!-- Example, bin\Debug\. Ensure OutDir has a trailing slash, so it can be concatenated -->
  25. <OutDir Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')">$(OutDir)\</OutDir>
  26. </PropertyGroup>
  27. <PropertyGroup Condition="'$(BaseIntermediateOutputPath)'=='' ">
  28. <BaseIntermediateOutputPath>$(OutputPath)obj\</BaseIntermediateOutputPath>
  29. <BaseIntermediateOutputPath Condition="!HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
  30. </PropertyGroup>
  31. <PropertyGroup Condition=" '$(IntermediateOutputPath)' == '' ">
  32. <IntermediateOutputPath Condition=" '$(PlatformName)' == 'AnyCPU' Or '$(PlatformName)' == ''">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
  33. <IntermediateOutputPath Condition=" '$(IntermediateOutputPath)' == '' ">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
  34. <IntermediateOutputPath Condition="!HasTrailingSlash('$(IntermediateOutputPath)')">$(IntermediateOutputPath)\</IntermediateOutputPath>
  35. </PropertyGroup>
  36. <Target Name="PrepareResourceNames" />
  37. <Target Name="ComputeIntermediateSatelliteAssemblies" />
  38. <Target Name="GetCopyToOutputDirectoryItems" />
  39. <Target Name="_SGenCheckForOutputs" />
  40. <Target Name="CreateManifestResourceNames" />
  41. <!--
  42. ============================================================
  43. Initialial setup
  44. ============================================================
  45. -->
  46. <PropertyGroup>
  47. <!-- Make sure OutputPath has a trailing slash on it -->
  48. <WDOutDir Condition="'$(OutDir)' != '$(OutputPath)'">$(OutDir)</WDOutDir>
  49. <CopyBeforeBuildTargetPath Condition="'$(CopyBeforeBuildTargetPath)' == ''">$(IntermediateOutputPath)AspnetCompileMerge\source</CopyBeforeBuildTargetPath>
  50. <_WDPSourceWebPhysicalPath>$(SourceWebPhysicalPath)</_WDPSourceWebPhysicalPath>
  51. <TempBuildDir Condition="'$(TempBuildDir)' == ''" >$(IntermediateOutputPath)TempBuildDir</TempBuildDir>
  52. <_ExcludeAppOffline Condition="'$(_ExcludeAppOffline)' ==''">true</_ExcludeAppOffline>
  53. <_ExcludeWebInfo Condition="'$(_ExcludeWebInfo)' ==''">true</_ExcludeWebInfo>
  54. </PropertyGroup>
  55. <PropertyGroup>
  56. <_SkipHiddenItems Condition="'$(_SkipHiddenItems)'==''">true</_SkipHiddenItems>
  57. </PropertyGroup>
  58. <ItemGroup>
  59. <ExcludeFromPackageFiles Include="$(SourceWebPhysicalPath)\App_Data\PublishProfiles\**\*.*"/>
  60. <ExcludeFromPackageFiles Include="$(SourceWebPhysicalPath)\*.publishproj"/>
  61. <ExcludeFromPackageFiles Include="$(SourceWebPhysicalPath)\app_offline.htm" Condition="'$(_ExcludeAppOffline)'== 'true'"/>
  62. <ExcludeFromPackageFiles Include="$(SourceWebPhysicalPath)\Bin\*.refresh" />
  63. <ExcludeFromPackageFiles Include="$(SourceWebPhysicalPath)\**\*.exclude" />
  64. <ExcludeFromPackageFiles Include="$(SourceWebPhysicalPath)\**\*.webinfo" Condition="'$(_ExcludeWebInfo)'=='true'" />
  65. </ItemGroup>
  66. <PropertyGroup Condition="'$(SourceWebMetabasePath)' != ''">
  67. <UseIis Condition="'$(UseIis)'==''">True</UseIis>
  68. <IisUrl Condition="'$(IisUrl)'==''">$(SourceWebProjectPath)</IisUrl>
  69. </PropertyGroup>
  70. <PropertyGroup Condition="'$(SourceWebMetabasePath)' == ''">
  71. <UseIis Condition="'$(UseIis)'==''">false</UseIis>
  72. </PropertyGroup>
  73. <!-- Create the output path as an item so that we can use %(FullPath) on it. -->
  74. <!-- _PublishedWebsites folder enables team build scenarios when OutDir is overiden -->
  75. <ItemGroup>
  76. <_WDOutputPathItem Condition="'$(WDOutDir)' != '' and !HasTrailingSlash('$(WDOutDir)')" Include="$(WDOutDir)\_PublishedWebsites\$(MSBuildProjectName)\"/>
  77. <_WDOutputPathItem Condition="'$(WDOutDir)' != '' and HasTrailingSlash('$(WDOutDir)')" Include="$(WDOutDir)_PublishedWebsites\$(MSBuildProjectName)\"/>
  78. <_WDOutputPathItem Condition="'$(WDOutDir)' == ''" Include="$(OutputPath)"/>
  79. <_WDPSourceWebPathItem Include="$(_WDPSourceWebPhysicalPath)"/>
  80. <_KeyFile Include="$(KeyFile)"/>
  81. </ItemGroup>
  82. <!-- AvailablePlatforms is the list of platform targets available. -->
  83. <PropertyGroup>
  84. <AvailablePlatforms>Any CPU</AvailablePlatforms>
  85. </PropertyGroup>
  86. <PropertyGroup>
  87. <WDTargetDir Condition="'$(WDTargetDir)' == ''">$(WDOutDir)\_PublishedWebsites\$(MSBuildProjectName)\</WDTargetDir>
  88. <_FullSourceWebDir>$(_WDPSourceWebPhysicalPath)</_FullSourceWebDir>
  89. <_FullKeyFile Condition="'$(KeyFile)' != ''">@(_KeyFile->'%(FullPath)')</_FullKeyFile>
  90. </PropertyGroup>
  91. <!--
  92. The set of properties passed to the aspnet_compiler when merge is not enabled
  93. -->
  94. <PropertyGroup>
  95. <_AspNetCompilerFixedNames Condition="'$(UseMerge)' != 'true'">$(UseFixedNames)</_AspNetCompilerFixedNames>
  96. <_AspNetCompilerKeyContainer Condition="'$(UseMerge)' != 'true'">$(KeyContainer)</_AspNetCompilerKeyContainer>
  97. <_AspNetCompilerMetabasePath Condition="'$(UseMetabasePath)' == 'true'">$(SourceWebMetabasePath)</_AspNetCompilerMetabasePath>
  98. <_AspNetCompilerSourceWebPath Condition="'$(UseMetabasePath)' != 'true'">$(_FullSourceWebDir)</_AspNetCompilerSourceWebPath>
  99. <_AspNetCompilerVirtualPath Condition="'$(UseMetabasePath)' != 'true'">$(SourceWebVirtualPath)</_AspNetCompilerVirtualPath>
  100. </PropertyGroup>
  101. <PropertyGroup>
  102. <BuildingProject>true</BuildingProject>
  103. </PropertyGroup>
  104. <PropertyGroup>
  105. <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>
  106. </PropertyGroup>
  107. <!--
  108. ============================================================
  109. Basic Hook in for WPP
  110. ============================================================
  111. -->
  112. <PropertyGroup>
  113. <WebPublishPipelineProjectDirectory Condition="'$(WebPublishPipelineProjectDirectory)'==''">$(MSBuildProjectDirectory)</WebPublishPipelineProjectDirectory>
  114. <DefaultDeployIisAppPhysicalPath Condition="'$(DefaultDeployIisAppPhysicalPath)'==''">$(MSBuildProjectDirectory)$(DefaultMsDeployAltSuffix)</DefaultDeployIisAppPhysicalPath>
  115. <FilesToIncludeForPublish>AllFilesInProjectFolder</FilesToIncludeForPublish>
  116. <!--We do want to exclude TransformAssistFile-->
  117. <ExcludeTransformAssistFilesFromPublish Condition="'$(ExcludeTransformAssistFilesFromPublish)'==''">True</ExcludeTransformAssistFilesFromPublish>
  118. <ExcludeGeneratedDebugSymbol Condition="'$(ExcludeGeneratedDebugSymbol)'=='' And '$(DebugSymbols)' == 'true'">False</ExcludeGeneratedDebugSymbol>
  119. <ProjectParametersXMLFile Condition="'$(ProjectParametersXMLFile)'=='' And Exists('$(MSBuildProjectDirectory)\Parameters.xml')">$(OutputPath)\Parameters.xml</ProjectParametersXMLFile>
  120. <_WDPDefaultIntermediateOutputPathPathRoot Condition="'$(_WPPDefaultIntermediateOutputPathPathRoot)' == ''">$(OutputPath)\</_WDPDefaultIntermediateOutputPathPathRoot>
  121. </PropertyGroup>
  122. <PropertyGroup Condition="'$(_WDPDefaultIntermediateOutputPath)' == ''">
  123. <_WDPDefaultIntermediateOutputPath>$(IntermediateOutputPath)</_WDPDefaultIntermediateOutputPath>
  124. <_WDPDefaultIntermediateOutputPath Condition="!$([System.IO.path]::IsPathRooted($(IntermediateOutputPath)))">$(_WDPDefaultIntermediateOutputPathPathRoot)$(IntermediateOutputPath)</_WDPDefaultIntermediateOutputPath>
  125. </PropertyGroup>
  126. <!--******************************************************-->
  127. <!--Include the WPP targets file-->
  128. <!--******************************************************-->
  129. <Import Project="$(MSBuildBinPath)\Microsoft.Common.targets" />
  130. <Import Project="Microsoft.Web.Publishing.targets" />
  131. <PropertyGroup>
  132. <!--In earlier version of WPP, Web.config transformation doesn't support anthing other than the Msbuild Project project folder to find the web.config-->
  133. <PreTransformWebConfigDependsOn>
  134. $(PreTransformWebConfigDependsOn);
  135. FixupTransformAssistFilesAsExclude;
  136. </PreTransformWebConfigDependsOn>
  137. </PropertyGroup>
  138. <ItemGroup>
  139. <_AllExecutableUnderBin Include="$(SourceWebPhysicalPath)\Bin\*.dll;$(SourceWebPhysicalPath)\Bin\*.exe"/>
  140. <ExcludeFromPackageFiles Include="@(_AllExecutableUnderBin -> '%(RelativeDir)%(FileName).xml')" Condition=" '$(ExcludeXmlAssemblyFiles)'=='true' "/>
  141. </ItemGroup>
  142. <Target Name="FixupTransformAssistFilesAsExclude"
  143. DependsOnTargets="CollectWebConfigsToTransform"
  144. Condition="'$(FixupTransformAssistFilesAsExclude)' != 'False'">
  145. <PropertyGroup>
  146. <_WDP_IdentifyTransformAssistFile>web\.[^\\\.]*\.config$</_WDP_IdentifyTransformAssistFile>
  147. </PropertyGroup>
  148. <!--Find all item with web.*.config-->
  149. <CollectFilesinFolder RootPath="$(WebPublishPipelineProjectDirectory)"
  150. RelativePathMatchs="$(_WDP_IdentifyTransformAssistFile)" >
  151. <Output TaskParameter="Result" ItemName="_WDP_WebConfigAssistFilesToFixupTemp" />
  152. </CollectFilesinFolder>
  153. <FilterByItems PipelineItems="@(FilesForPackagingFromProject)"
  154. Filter="@(_WDP_WebConfigAssistFilesToFixupTemp)">
  155. <Output TaskParameter="InFilter" ItemName="_WDP_WebConfigAssistFilesToFixup"/>
  156. </FilterByItems>
  157. <ItemGroup>
  158. <!--Change all web.*.config to full path and add DependentUpon with Web.config-->
  159. <FilesForPackagingFromProject Remove="@(_WDP_WebConfigAssistFilesToFixup)" />
  160. <FilesForPackagingFromProject Include="@(_WDP_WebConfigAssistFilesToFixup->'$(WebPublishPipelineProjectDirectory)%(Identity)')">
  161. <DependentUpon>Web.config</DependentUpon>
  162. </FilesForPackagingFromProject>
  163. </ItemGroup>
  164. </Target>
  165. <!--
  166. ============================================================
  167. _PrepareForBuild
  168. Sets up variables in preparation to build.
  169. ============================================================
  170. -->
  171. <Target Name="_PrepareForBuild">
  172. <!--
  173. Here converting to a property is required because TargetDir and TargetPath are defined
  174. to contain an item list. We want that item list to be expanded so that it can be used
  175. as a regular property value and not as an item-list-with-transform.
  176. -->
  177. <PropertyGroup>
  178. <WDTargetDir>$(WDTargetDir)</WDTargetDir>
  179. </PropertyGroup>
  180. <PropertyGroup>
  181. <_FullSourceWebDir>$(_FullSourceWebDir)</_FullSourceWebDir>
  182. </PropertyGroup>
  183. <MakeDir Directories="$(IntermediateOutputPath)" />
  184. </Target>
  185. <!--
  186. ============================================================
  187. _CollectFilesForCopyBeforeBuild
  188. Copy the web to a new folder excluding predefined items in @(ExcludeFromBuild)
  189. <ItemGroup>
  190. <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Test\**\*.*"/>
  191. <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\Images\**\*.*"/>
  192. </ItemGroup>
  193. The following support regular expreesion Exclude For example
  194. <PropertyGroup>
  195. <_WDPExcludeFullPathFromBuildRegEx>$(_WDPExcludeFullPathFromBuildRegEx);C:\\myfoo</_WDPExcludeFullPathFromBuildRegEx>
  196. <_WDPExcludeRelativePathFromBuildRegex>$(_WDPExcludeRelativePathFromBuildRegex);[^\\]*\.scc$;[^\\]*\.vssscc$;[^\\]*\.vspscc$</_WDPExcludeRelativePathFromBuildRegex>
  197. </PropertyGroup>
  198. <CopyBeforeBuildTargetPath Condition="'$(CopyBeforeBuildTargetPath)' == ''">$(IntermediateOutputPath)Source</CopyBeforeBuildTargetPath>
  199. ============================================================
  200. -->
  201. <ItemDefinitionGroup>
  202. <_WebFiles>
  203. <DestinationRelativePath></DestinationRelativePath>
  204. <Exclude>False</Exclude>
  205. <FromTarget>Unknown</FromTarget>
  206. <Category>Run</Category>
  207. <ProjectFileType>Default</ProjectFileType>
  208. </_WebFiles>
  209. </ItemDefinitionGroup>
  210. <Target Name="_CollectFilesForCopyBeforeBuild"
  211. DependsOnTargets="$(_CollectFilesForCopyBeforeBuildDependsOn)">
  212. <!--********************************************************************-->
  213. <!-- Enforce that all items have these metadata values -->
  214. <!-- Default for Exclude is False -->
  215. <!--********************************************************************-->
  216. <CollectFilesinFolder RootPath="$(_WDPSourceWebPhysicalPath)"
  217. ExcludeFullPathMatchs="$(_WDPExcludeFullPathFromBuildRegEx)"
  218. ExcludeRelativePathMatchs="$(_WDPExcludeRelativePathFromBuildRegex)">
  219. <Output TaskParameter="Result" ItemName="_WebFilesNoMetadata" />
  220. </CollectFilesinFolder>
  221. <PropertyGroup>
  222. <_OriginalSourceWebPhysicalFullPath>$([System.IO.Path]::GetFullPath($(SourceWebPhysicalPath)))</_OriginalSourceWebPhysicalFullPath>
  223. <_OriginalSourceWebPhysicalFullPath Condition="!HasTrailingSlash('$(_OriginalSourceWebPhysicalFullPath)')">$(_OriginalSourceWebPhysicalFullPath)\</_OriginalSourceWebPhysicalFullPath>
  224. </PropertyGroup>
  225. <!-- For Team Build scenarios when WAP is used the exclude may be different from the source path -->
  226. <ItemGroup Condition ="'$(_WDPSourceWebPhysicalPath)' != '$(SourceWebPhysicalPath)'">
  227. <_WebFilesExclude Include="%(ExcludeFromBuild.Identity)">
  228. <SourceRelativePath Condition="$([System.String]::new(%(ExcludeFromBuild.FullPath)).StartsWith($(_OriginalSourceWebPhysicalFullPath), StringComparison.OrdinalIgnoreCase ))" >$([System.String]::new(%(ExcludeFromBuild.FullPath)).SubString($(_OriginalSourceWebPhysicalFullPath.Length)))</SourceRelativePath>
  229. </_WebFilesExclude>
  230. <_WebFilesExclude Condition="'%(SourceRelativePath)'==''">
  231. <SourceRelativePath>%(Identity)</SourceRelativePath>
  232. </_WebFilesExclude>
  233. <_WebFilesNoMetadata Remove="%(_WebFilesExclude.SourceRelativePath)" Condition="'%(_WebFilesExclude.SourceRelativePath)' != ''"/>
  234. </ItemGroup>
  235. <!-- Log debug for potential issue -->
  236. <WriteLinesToFile Condition ="$(EnablePackageProcessLoggingAndAssert) And '$(_WDPSourceWebPhysicalPath)' != '$(SourceWebPhysicalPath)'"
  237. Encoding="utf-8"
  238. File="$(IntermediateOutputPath)\_WebFilesExclude.txt"
  239. Lines="@(_WebFilesExclude->'
  240. Files:%(Identity)
  241. SourceRelativePath:%(SourceRelativePath)')"
  242. Overwrite="True" />
  243. <!-- _WebFilesNoMetadata doesn't have metadata yet, need to fill the data. Fill in the metadata now for CopyPipelineFiles to use -->
  244. <ItemGroup>
  245. <_WebFiles Include="$([System.IO.Path]::Combine($(_WDPSourceWebPhysicalPath), %(_WebFilesNoMetadata.Identity)))" >
  246. <DestinationRelativePath>%(_WebFilesNoMetadata.Identity)</DestinationRelativePath>
  247. </_WebFiles>
  248. </ItemGroup>
  249. <!-- For backwards compatability -->
  250. <ItemGroup Condition ="'$(_WDPSourceWebPhysicalPath)' == '$(SourceWebPhysicalPath)'">
  251. <_WebFiles Remove="@(ExcludeFromBuild)" />
  252. </ItemGroup>
  253. <MakeDir Directories="$(IntermediateOutputPath)" />
  254. <WriteLinesToFile Condition="$(EnablePackageProcessLoggingAndAssert)"
  255. Encoding="utf-8"
  256. File="$(IntermediateOutputPath)\webfilesToBeCopied.txt"
  257. Lines="@(_WebFiles->'
  258. Files:%(Identity)
  259. FromTarget:%(FromTarget)
  260. DestinationRelativePath:%(DestinationRelativePath)')"
  261. Overwrite="True" />
  262. </Target>
  263. <Target Name="_CopyBeforeBuild"
  264. Condition=" '$(EnableCopyBeforeBuild)' == 'true' or '@(ExcludeFromBuild)' != '' "
  265. DependsOnTargets="_CollectFilesForCopyBeforeBuild">
  266. <ItemGroup>
  267. <_WDPAllExtraFilesUnderTempFolder Condition="'$(CopyBeforeBuildTargetPath)' != ''" Include="$(CopyBeforeBuildTargetPath)\**" />
  268. <_WDPAllExtraFilesUnderTempFolder
  269. Remove="@(FilesForPackagingFromProject->'$(CopyBeforeBuildTargetPath)\%(DestinationRelativePath)')" />
  270. </ItemGroup>
  271. <!-- Remove all extra files in the temp folder that's not in the @(FilesForPackagingFromProject) -->
  272. <Delete Files="@(_WDPAllExtraFilesUnderTempFolder)" />
  273. <!-- This method supports incremental copy, instead of a full copy everytime -->
  274. <!-- We've already expanded the path as relative path to the project. There is no need for sourceDirectory -->
  275. <CopyPipelineFiles PipelineItems="@(_WebFiles)"
  276. SourceDirectory="$(MSBuildProjectDirectory)"
  277. TargetDirectory="$(CopyBeforeBuildTargetPath)"
  278. SkipMetadataExcludeTrueItems="True"
  279. UpdateItemSpec="False"
  280. DeleteItemsMarkAsExcludeTrue ="True">
  281. <Output TaskParameter="UpdatedPipelineItems" ItemName="_WebFilesCopied"/>
  282. </CopyPipelineFiles>
  283. <PropertyGroup>
  284. <_AspNetCompilerSourceWebPath>$(CopyBeforeBuildTargetPath)</_AspNetCompilerSourceWebPath>
  285. </PropertyGroup>
  286. </Target>
  287. <!--
  288. ============================================================
  289. Clean
  290. ============================================================
  291. -->
  292. <Target Name="Clean">
  293. <PropertyGroup>
  294. <Clean>true</Clean>
  295. </PropertyGroup>
  296. <RemoveDir Condition="Exists('$(CopyBeforeBuildTargetPath)')" Directories="$(CopyBeforeBuildTargetPath)"/>
  297. <RemoveDir Condition="Exists('$(TempBuildDir)')" Directories="$(TempBuildDir)" />
  298. <RemoveDir Condition="Exists('$(WDTargetDir)')" Directories="$(WDTargetDir)" />
  299. </Target>
  300. <!--
  301. ============================================================
  302. Reference Resolving
  303. Updates the bin folder with the lastest .refresh files
  304. ============================================================
  305. -->
  306. <Target Name="_ResolveAssemblyReferencesWithRefreshFile" DependsOnTargets="_PrepareForBuild">
  307. <ItemGroup>
  308. <References_RefreshFile Include="$(_FullSourceWebDir)\Bin\*.refresh"/>
  309. </ItemGroup>
  310. <ReadLinesFromFile File="%(References_RefreshFile.Identity)" Condition=" '%(References_RefreshFile.Identity)' != '' ">
  311. <Output TaskParameter="Lines" ItemName="References_ReferenceRelPath" />
  312. </ReadLinesFromFile>
  313. <CombinePath BasePath="$(_FullSourceWebDir)" Paths="@(References_ReferenceRelPath)">
  314. <Output TaskParameter="CombinedPaths" ItemName="References" />
  315. </CombinePath>
  316. <Copy
  317. SourceFiles="@(References->'%(FullPath)')"
  318. DestinationFolder="$(_FullSourceWebDir)\Bin\"
  319. Condition="!Exists('%(References.Identity)')"
  320. ContinueOnError="true"
  321. SkipUnchangedFiles="true"
  322. Retries="$(CopyRetryCount)"
  323. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
  324. </Target>
  325. <!--
  326. ============================================================
  327. AfterResolveReferences
  328. ============================================================
  329. -->
  330. <Target Name="AfterResolveReferences">
  331. <Copy SourceFiles="@(ReferencePath->'%(FullPath)')"
  332. DestinationFolder="$(_FullSourceWebDir)\Bin\"
  333. ContinueOnError="true"
  334. SkipUnchangedFiles="true"
  335. Retries="$(CopyRetryCount)"
  336. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
  337. <Copy SourceFiles="@(ReferenceComWrappersToCopyLocal); @(ResolvedIsolatedComModules); @(_DeploymentLooseManifestFile); @(NativeReferenceFile)"
  338. DestinationFolder="$(_FullSourceWebDir)\bin"
  339. SkipUnchangedFiles="true"
  340. Retries="$(CopyRetryCount)"
  341. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
  342. <Copy SourceFiles="@(ReferenceCopyLocalPaths)"
  343. DestinationFiles="@(ReferenceCopyLocalPaths->'$(_FullSourceWebDir)\bin\%(DestinationSubDirectory)%(Filename)%(Extension)')"
  344. SkipUnchangedFiles="true"
  345. Retries="$(CopyRetryCount)"
  346. RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"/>
  347. </Target>
  348. <!--
  349. ============================================================
  350. Build
  351. The main build entry point.
  352. ============================================================
  353. -->
  354. <PropertyGroup>
  355. <BuildDependsOn>
  356. _PrepareForBuild;
  357. ResolveProjectReferences;
  358. _ResolveAssemblyReferencesWithRefreshFile;
  359. ResolveReferences;
  360. _CopyBeforeBuild;
  361. </BuildDependsOn>
  362. <PipelineDeployPhaseAfterTargets Condition="'$(DeployOnBuild)'=='True'">_CopyBeforeBuild</PipelineDeployPhaseAfterTargets>
  363. </PropertyGroup>
  364. <Target
  365. Name="Build"
  366. DependsOnTargets="$(BuildDependsOn)" />
  367. <!--
  368. ============================================================
  369. CopyToOutputDir
  370. From the temp building location copy the output to the actual oput dir
  371. ============================================================
  372. -->
  373. <ItemDefinitionGroup>
  374. <_WDPOutputFiles>
  375. <DestinationRelativePath></DestinationRelativePath>
  376. <Exclude>False</Exclude>
  377. <FromTarget>Unknown</FromTarget>
  378. <Category>Run</Category>
  379. <ProjectFileType>Default</ProjectFileType>
  380. </_WDPOutputFiles>
  381. </ItemDefinitionGroup>
  382. <Target Name="_CollectFilesForCopyToOutputDir"
  383. DependsOnTargets="$(_CollectFilesForCopyToOutputDirDependsOn)">
  384. <PropertyGroup>
  385. <_TempDirFullPath>$(MSBuildProjectDirectory)\$(TempBuildDir)</_TempDirFullPath>
  386. </PropertyGroup>
  387. <MakeDir Directories="$(_TempDirFullPath)" />
  388. <!--********************************************************************-->
  389. <!-- Enforce that all items have these metadata values -->
  390. <!-- Default for Exclude is False -->
  391. <!--********************************************************************-->
  392. <CollectFilesinFolder RootPath="$(_TempDirFullPath)"
  393. ExcludeFullPathMatchs="$(_WDPExcludeFullPathToOutputDirRegEx)"
  394. ExcludeRelativePathMatchs="$(_WDPExcludeRelativePathToOutputDirRegex)">
  395. <Output TaskParameter="Result" ItemName="_WDPOutputFilesNoMetadata" />
  396. </CollectFilesinFolder>
  397. <!-- _WDPOutputFilesNoMetadata doesn't have metadata yet, need to fill the data. Fill in the metadata now for CopyPipelineFiles to use -->
  398. <ItemGroup>
  399. <_WDPOutputFiles Include="@(_WDPOutputFilesNoMetadata)" >
  400. <DestinationRelativePath>%(_WDPOutputFilesNoMetadata.Identity)</DestinationRelativePath>
  401. </_WDPOutputFiles>
  402. </ItemGroup>
  403. <MakeDir Directories="$(IntermediateOutputPath)" />
  404. <WriteLinesToFile Condition="$(EnablePackageProcessLoggingAndAssert)"
  405. Encoding="utf-8"
  406. File="$(IntermediateOutputPath)\WDPOutputFilesToBeCopied.txt"
  407. Lines="@(_WDPOutputFiles->'
  408. Files:%(Identity)
  409. FromTarget:%(FromTarget)
  410. DestinationRelativePath:%(DestinationRelativePath)')"
  411. Overwrite="True" />
  412. </Target>
  413. <PropertyGroup>
  414. <_CopyToOutputDirDependsOn>
  415. $(_CopyToOutputDirDependsOn);
  416. CoreCopyToOutputDir;
  417. CleanTempBuildDir
  418. </_CopyToOutputDirDependsOn>
  419. </PropertyGroup>
  420. <Target Name="CopyToOutputDir" DependsOnTargets="$(_CopyToOutputDirDependsOn)"/>
  421. <Target Name="CoreCopyToOutputDir"
  422. Condition=" '$(CopyToOutputDir)' != 'False'"
  423. DependsOnTargets="_CollectFilesForCopyToOutputDir">
  424. <ItemGroup>
  425. <_WDPAllExtraFilesUnderTargetDir Condition="'$(WDTargetDir)' != ''" Include="$(WDTargetDir)\**" />
  426. <_WDPAllExtraFilesUnderTargetDir
  427. Remove="@(_WDPOutputFiles->'$(WDTargetDir)\%(DestinationRelativePath)')" />
  428. </ItemGroup>
  429. <!-- Remove all extra files in the temp folder that's not in the @(FilesForPackagingFromProject -->
  430. <Delete Files="@(_WDPAllExtraFilesUnderTargetDir)" />
  431. <!-- This method supports incremental copy, instead of a full copy everytime -->
  432. <!-- @(_WDPOutputFiles) contain relative path to $(TempBuildDir), pass in sourceDirectory -->
  433. <CopyPipelineFiles PipelineItems="@(_WDPOutputFiles)"
  434. SourceDirectory="$(TempBuildDir)"
  435. TargetDirectory="$(WDTargetDir)"
  436. SkipMetadataExcludeTrueItems="True"
  437. UpdateItemSpec="False"
  438. DeleteItemsMarkAsExcludeTrue ="True">
  439. <Output TaskParameter="UpdatedPipelineItems" ItemName="_WDPOutputFilesCopied"/>
  440. </CopyPipelineFiles>
  441. </Target>
  442. <!--
  443. ============================================================
  444. CleanTempBuildDir
  445. Clean Temp Build Dir
  446. ============================================================
  447. -->
  448. <Target Name="CleanTempBuildDir"
  449. Condition="'$(CleanTempBuildDir)' == 'True'">
  450. <RemoveDir Directories="$(TempBuildDir)" />
  451. </Target>
  452. <!--
  453. This is required for setup project support
  454. -->
  455. <Target Name="BuiltProjectOutputGroup" DependsOnTargets="_PrepareForBuild">
  456. <ItemGroup>
  457. <_BuiltProjectOutputGroupOutput Include="$(WDTargetDir)**\*.*"/>
  458. <BuiltProjectOutputGroupOutput Include="@(_BuiltProjectOutputGroupOutput)">
  459. <TargetPath>%(_BuiltProjectOutputGroupOutput.SubFolder)%(_BuiltProjectOutputGroupOutput.RecursiveDir)%(Filename)%(Extension)</TargetPath>
  460. </BuiltProjectOutputGroupOutput>
  461. </ItemGroup>
  462. </Target>
  463. </Project>