EntityFramework.targets 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  2. <PropertyGroup>
  3. <EnableDefaultEntityDeployItems Condition="'$(EnableDefaultEntityDeployItems)' == ''">True</EnableDefaultEntityDeployItems>
  4. </PropertyGroup>
  5. <!-- This .targets file can be used by updating Microsoft.Common.targets to
  6. include the line below (as the last import element just before the end project tag)
  7. <Import Project="$(MSBuildBinPath)\Microsoft.Data.Entity.targets" Condition="Exists('$(MSBuildBinPath)\Microsoft.Data.Entity.targets')"/>
  8. -->
  9. <!-- The below ensures that "EntityDeploy" is available in the VS Build Action dropdown -->
  10. <ItemGroup>
  11. <AvailableItemName Include="EntityDeploy" />
  12. </ItemGroup>
  13. <PropertyGroup>
  14. <!-- EntityDeployIntermediateResourcePath is the path used to store resources generated from
  15. the EDMX file before they are embedded in the build target -->
  16. <EntityDeployIntermediateResourcePath>$(IntermediateOutputPath)edmxResourcesToEmbed\</EntityDeployIntermediateResourcePath>
  17. </PropertyGroup>
  18. <UsingTask TaskName="EntityDeploySplit"
  19. AssemblyFile="Microsoft.Data.Entity.Build.Tasks.dll" />
  20. <UsingTask TaskName="EntityDeploy"
  21. AssemblyFile="Microsoft.Data.Entity.Build.Tasks.dll" />
  22. <UsingTask TaskName="EntityDeploySetLogicalNames"
  23. AssemblyFile="Microsoft.Data.Entity.Build.Tasks.dll" />
  24. <UsingTask TaskName="EntityClean"
  25. AssemblyFile="Microsoft.Data.Entity.Build.Tasks.dll" />
  26. <PropertyGroup>
  27. <!-- EntityDeployDependsOn deliberately left empty so others can override this -->
  28. <EntityDeployDependsOn></EntityDeployDependsOn>
  29. <BuildDependsOn>
  30. EntityDeploy;
  31. $(BuildDependsOn)
  32. </BuildDependsOn>
  33. </PropertyGroup>
  34. <PropertyGroup>
  35. <CleanDependsOn>
  36. $(CleanDependsOn);
  37. EntityClean;
  38. </CleanDependsOn>
  39. </PropertyGroup>
  40. <Target Name="EntityDeploy"
  41. DependsOnTargets="$(EntityDeployDependsOn)"
  42. Condition="'@(EntityDeploy)' != ''">
  43. <CallTarget Targets="EntityDeployNonEmbeddedResources" />
  44. <CallTarget Targets="EntityDeployEmbeddedResources" />
  45. <CallTarget Targets="EntityDeploySetLogicalNames" />
  46. </Target>
  47. <!-- Split the EDMX files into two groups: those whose resources need to be embedded
  48. and those whose resources need to be copied
  49. Note: this also assigns the EntityDeployRelativeDir metadata to each
  50. item so that the same metadata can be used regardless of whether the
  51. underlying item is a link or a normal file -->
  52. <Target Name="EntityDeploySplit" >
  53. <EntityDeploySplit
  54. Sources="@(EntityDeploy)" >
  55. <Output TaskParameter="EmbeddingItems" ItemName="EntityDeployEmbeddingItems" />
  56. <Output TaskParameter="NonEmbeddingItems" ItemName="EntityDeployCopyingItems" />
  57. </EntityDeploySplit>
  58. <Message Condition="'$(EntityDeployDebug)'=='true'"
  59. Text="EntityDeploySplit: EntityDeployEmbeddingItems = @(EntityDeployEmbeddingItems)" />
  60. <Message Condition="'$(EntityDeployDebug)'=='true'"
  61. Text="EntityDeploySplit: EntityDeployCopyingItems = @(EntityDeployCopyingItems)" />
  62. </Target>
  63. <!-- Generate to $(OutputPath) the CSDL, MSL and SSDL resources from the EDMX
  64. files set to copy their outputs to the output directory (use SSDL as marker
  65. file as that is the last one generated) -->
  66. <Target Name="EntityDeployNonEmbeddedResources"
  67. DependsOnTargets="EntityDeploySplit"
  68. Inputs="@(EntityDeployCopyingItems)"
  69. Outputs="@(EntityDeployCopyingItems->'$(OutputPath)%(EntityDeployRelativeDir)%(Filename).ssdl')" >
  70. <EntityDeploy
  71. Sources="@(EntityDeployCopyingItems)"
  72. OutputPath="$(OutputPath)" >
  73. </EntityDeploy>
  74. </Target>
  75. <!-- Generates to $(EntityDeployIntermediateResourcePath) the CSDL, MSL and SSDL
  76. resources from the EDMX files set to embed their outputs (use SSDL as marker
  77. file as that is the last one generated) -->
  78. <Target Name="EntityDeployEmbeddedResources"
  79. DependsOnTargets="EntityDeploySplit"
  80. Inputs="@(EntityDeployEmbeddingItems)"
  81. Outputs="@(EntityDeployEmbeddingItems->'$(EntityDeployIntermediateResourcePath)%(EntityDeployRelativeDir)%(Filename).ssdl')" >
  82. <EntityDeploy
  83. Sources="@(EntityDeployEmbeddingItems)"
  84. OutputPath="$(EntityDeployIntermediateResourcePath)" >
  85. </EntityDeploy>
  86. </Target>
  87. <Target Name="EntityClean"
  88. Condition="'@(EntityDeploy)' != ''">
  89. <EntityClean
  90. Sources="@(EntityDeploy)"
  91. ResourceOutputPath="$(EntityDeployIntermediateResourcePath)"
  92. OutputPath="$(OutputPath)"
  93. />
  94. </Target>
  95. <!-- Define the CSDL/MSL/SSDL files generated from @(EntityDeployEmbeddingItems)
  96. as part of the EmbeddedResource ItemGroup which includes them in the build target
  97. Note: this must happen regardless of whether the EntityDeployEmbeddedResources target is
  98. skipped due to incremental build -->
  99. <Target Name="EntityDeploySetLogicalNames"
  100. DependsOnTargets="EntityDeploySplit">
  101. <!-- First define the resources to be embedded
  102. Note: ignore resources which are not in @(EntityDeployEmbeddingItems) - this ignores
  103. resources generated by previous runs which have now had their MetadataArtifactProcessing
  104. changed to "CopyToOutput" -->
  105. <ItemGroup>
  106. <EntityDeployResourcesToEmbed Include="@(EntityDeployEmbeddingItems->'$(EntityDeployIntermediateResourcePath)%(EntityDeployRelativeDir)%(Filename).csdl')" />
  107. <EntityDeployResourcesToEmbed Include="@(EntityDeployEmbeddingItems->'$(EntityDeployIntermediateResourcePath)%(EntityDeployRelativeDir)%(Filename).msl')" />
  108. <EntityDeployResourcesToEmbed Include="@(EntityDeployEmbeddingItems->'$(EntityDeployIntermediateResourcePath)%(EntityDeployRelativeDir)%(Filename).ssdl')" />
  109. </ItemGroup>
  110. <Message Condition="'$(EntityDeployDebug)'=='true'"
  111. Text="EntityDeploySetLogicalNames: EntityDeployResourcesToEmbed = @(EntityDeployResourcesToEmbed)" />
  112. <!-- Now update their logical names and add them to the list of resources to be embedded -->
  113. <EntityDeploySetLogicalNames
  114. Sources="@(EntityDeployResourcesToEmbed)"
  115. ResourceOutputPath="$(EntityDeployIntermediateResourcePath)" >
  116. <Output TaskParameter="ResourcesToEmbed" ItemName="EmbeddedResource"/>
  117. </EntityDeploySetLogicalNames>
  118. </Target>
  119. </Project>