zeroc.icebuilder.msbuild.csharp.targets 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Copyright (c) 2009-2018 ZeroC, Inc. All rights reserved. -->
  3. <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  4. <Choose>
  5. <When Condition="'$(MSBuildAssemblyVersion)' == '' or '$(MSBuildAssemblyVersion)' &lt; '15.0'">
  6. <PropertyGroup>
  7. <SliceCompileAssemblyDir>net45</SliceCompileAssemblyDir>
  8. </PropertyGroup>
  9. </When>
  10. <Otherwise>
  11. <PropertyGroup>
  12. <SliceCompileAssemblyDir>netstandard2.0</SliceCompileAssemblyDir>
  13. </PropertyGroup>
  14. </Otherwise>
  15. </Choose>
  16. <!-- Import our custom MSbuild tasks used to build Ice for CSharp projects -->
  17. <UsingTask TaskName="IceBuilder.MSBuild.Slice2CSharpTask"
  18. AssemblyFile="$(MSBuildThisFileDirectory)..\tools\$(SliceCompileAssemblyDir)\zeroc.icebuilder.msbuild.dll"/>
  19. <UsingTask TaskName="IceBuilder.MSBuild.Slice2CSharpDependTask"
  20. AssemblyFile="$(MSBuildThisFileDirectory)..\tools\$(SliceCompileAssemblyDir)\zeroc.icebuilder.msbuild.dll"/>
  21. <!-- Import IceBuilder common settings -->
  22. <Import Project="$(MSBuildThisFileDirectory)\zeroc.icebuilder.msbuild.common.props"/>
  23. <ItemGroup>
  24. <PropertyPageSchema Include="$(MSBuildThisFileDirectory)ProjectItemsSchema.xaml" />
  25. <!-- This capability is used to apply the Slice property page designer -->
  26. <ProjectCapability Include="SliceCompile" />
  27. <PropertyPageSchema Include="$(MSBuildThisFileDirectory)SliceCompile.CSharp.xaml">
  28. <Context>Project</Context>
  29. </PropertyPageSchema>
  30. <PropertyPageSchema Include="$(MSBuildThisFileDirectory)SliceCompile.CSharp.File.xaml">
  31. <Context>File;BrowseObject</Context>
  32. </PropertyPageSchema>
  33. <AvailableItemName Include="SliceCompile"/>
  34. </ItemGroup>
  35. <!--
  36. Settings that are only supported with MSBuild 15.0 and up. The item Update
  37. attribute is not supported with older MSBuild versions.
  38. -->
  39. <Import Project="$(MSBuildThisFileDirectory)\zeroc.icebuilder.msbuild.csharp.15.0.targets"
  40. Condition="'$(MSBuildAssemblyVersion)' != '' and '$(MSBuildAssemblyVersion)' &gt; '14.0'"/>
  41. <Target Name="SliceCompile" BeforeTargets="CoreCompile"
  42. Condition="@(SliceCompile) != ''">
  43. <Error Text="Ice Installation invalid or not detected. Invalid IceHome setting `$(IceHome)'"
  44. Condition="!Exists('$(IceHome)')" />
  45. <Error Text="Ice Installation invalid or not detected. Invalid IceToolsPath setting `$(IceToolsPath)'"
  46. Condition="!Exists('$(IceToolsPath)')" />
  47. <Error Text="The Ice Builder requires Ice Version 3.6 or later. Invalid IceHome setting `$(IceHome)'"
  48. Condition="'$(IceIntVersion)' == '' Or '$(IceIntVersion)' &lt; '30600'" />
  49. <MakeDir Directories="%(SliceCompile.OutputDir)"/>
  50. <!-- First we check dependencies and compute which Slice files need to be recompiled -->
  51. <Slice2CSharpDependTask
  52. WorkingDirectory = "$(MSBuildProjectDirectory)"
  53. IceHome = "$(IceHome)"
  54. IceToolsPath = "$(IceToolsPath)"
  55. Sources = "@(SliceCompile)">
  56. <Output
  57. ItemName = "_SliceCompile"
  58. TaskParameter = "ComputedSources"/>
  59. <Output
  60. PropertyName = "_SliceCompileGeneratedPaths"
  61. TaskParameter = "GeneratedCompiledPaths"/>
  62. </Slice2CSharpDependTask>
  63. <!-- Compile the Slice files -->
  64. <Slice2CSharpTask
  65. WorkingDirectory = "$(MSBuildProjectDirectory)"
  66. IceHome = "$(IceHome)"
  67. IceToolsPath = "$(IceToolsPath)"
  68. OutputDir = "%(_SliceCompile.OutputDir)"
  69. IncludeDirectories = "%(_SliceCompile.IncludeDirectories)"
  70. AdditionalOptions = "%(_SliceCompile.AdditionalOptions)"
  71. Sources = "@(_SliceCompile)"
  72. Condition = "'%(_SliceCompile.BuildRequired)' == 'True'"/>
  73. <!--
  74. Include all C# generated source items that have not been manually included. We want to delay this until we are
  75. running the SliceCompile target so that the Visual Studio extension has a chance to add these items to the project in
  76. a persistent way. If the extension is not enabled or we are building from the command line we just add the
  77. missing items in a transient way.
  78. The builder's depend task has an output property named GeneratedPaths that contains the paths of all generated items.
  79. -->
  80. <ItemGroup>
  81. <Compile Include="$(_SliceCompileGeneratedPaths)"
  82. Exclude="@(Compile->'%(FullPath)');@(Compile->'%(Identity)')" />
  83. </ItemGroup>
  84. </Target>
  85. <Target Name="SliceCompileClean" BeforeTargets="Clean">
  86. <Delete Files="@(SliceCompile->'%(OutputDir)\%(Filename).cs')"/>
  87. <Delete Files="@(SliceCompile->'%(OutputDir)\SliceCompile.%(Filename).d')"/>
  88. </Target>
  89. </Project>