sound_tools.props 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  3. <ImportGroup Label="PropertySheets">
  4. <Import Project="basedir.props" Condition=" '$(BaseDirImported)' == ''"/>
  5. </ImportGroup>
  6. <PropertyGroup>
  7. <sounds_dirImported>true</sounds_dirImported>
  8. </PropertyGroup>
  9. <UsingTask TaskName="GetSoundsDirTask"
  10. TaskFactory="CodeTaskFactory"
  11. AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
  12. <ParameterGroup>
  13. <SoundsDir ParameterType="System.String" Output="True"/>
  14. </ParameterGroup>
  15. <Task>
  16. <Reference Include="Microsoft.Build" />
  17. <Reference Include="Microsoft.Build.Framework" />
  18. <Code Type="Class" Language="cs">
  19. <![CDATA[
  20. using System;
  21. using System.IO;
  22. using Microsoft.Build.Framework;
  23. public class GetSoundsDirTask : Microsoft.Build.Utilities.Task
  24. {
  25. [Output]
  26. public string SoundsDir { get; set; }
  27. public override bool Execute()
  28. {
  29. /*SoundsDir = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
  30. SoundsDir += "\\FreeSWITCH\\sounds"; */
  31. string platform = (@"$(Platform)" == "x86") ? "Win32" : @"$(Platform)";
  32. SoundsDir = @"$(SolutionDir)" + platform + @"\$(Configuration)\sounds";
  33. Directory.CreateDirectory(SoundsDir);
  34. return true;
  35. }
  36. }
  37. ]]>
  38. </Code>
  39. </Task>
  40. </UsingTask>
  41. <Target Name="GetSoundsDirTarget" BeforeTargets="CustomBuild;Build">
  42. <GetSoundsDirTask>
  43. <Output PropertyName="SoundsDir" TaskParameter="SoundsDir" />
  44. </GetSoundsDirTask>
  45. <Message Importance="High" Text="SoundsDir is set to: $(SoundsDir)"/>
  46. </Target>
  47. <UsingTask TaskName="GetSoundFileNameTask"
  48. TaskFactory="CodeTaskFactory"
  49. AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
  50. <ParameterGroup>
  51. <SoundPrimaryName Required="true" />
  52. <SoundQuality Required="true" />
  53. <SoundFileName ParameterType="System.String" Output="True"/>
  54. </ParameterGroup>
  55. <Task>
  56. <Reference Include="Microsoft.Build" />
  57. <Reference Include="Microsoft.Build.Framework" />
  58. <Code Type="Class" Language="cs">
  59. <![CDATA[
  60. using System;
  61. using System.IO;
  62. using Microsoft.Build.Framework;
  63. public class GetSoundFileNameTask : Microsoft.Build.Utilities.Task
  64. {
  65. [Required]
  66. public string SoundPrimaryName { get; set; }
  67. public string SoundQuality { get; set; }
  68. [Output]
  69. public string SoundFileName { get; set; }
  70. public override bool Execute()
  71. {
  72. string SoundVersion = "";
  73. string SoundVersionFile = "";
  74. if (SoundPrimaryName == "music") {
  75. SoundVersion = File.ReadAllText(@"$(BaseDir)build/moh_version.txt").Trim();
  76. } else {
  77. foreach (string line in File.ReadLines(@"$(BaseDir)build/sounds_version.txt")) {
  78. var items = line.Split(' ');
  79. if ( items[0] == SoundPrimaryName ) {
  80. SoundVersion = items[1].Trim();
  81. break;
  82. }
  83. }
  84. }
  85. SoundFileName = "freeswitch-sounds-" + SoundPrimaryName + "-" + SoundQuality + "-" + SoundVersion + ".tar.gz";
  86. return true;
  87. }
  88. }
  89. ]]>
  90. </Code>
  91. </Task>
  92. </UsingTask>
  93. </Project>