暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  2. <ItemGroup>
  3. <RoslyCompilerFiles Include="$(CscToolPath)\*">
  4. <Link>roslyn\%(RecursiveDir)%(Filename)%(Extension)</Link>
  5. </RoslyCompilerFiles>
  6. </ItemGroup>
  7. <Target Name="IncludeRoslynCompilerFilesToFilesForPackagingFromProject" BeforeTargets="PipelineCollectFilesPhase" >
  8. <ItemGroup>
  9. <FilesForPackagingFromProject Include="@(RoslyCompilerFiles)">
  10. <DestinationRelativePath>bin\roslyn\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
  11. <FromTarget>IncludeRoslynCompilerFilesToFilesForPackagingFromProject</FromTarget>
  12. <Category>Run</Category>
  13. </FilesForPackagingFromProject>
  14. </ItemGroup>
  15. </Target>
  16. <Target Name="CopyRoslynCompilerFilesToOutputDirectory" AfterTargets="CopyFilesToOutputDirectory">
  17. <Copy SourceFiles="@(RoslyCompilerFiles)" DestinationFolder="$(WebProjectOutputDir)\bin\roslyn" ContinueOnError="true" SkipUnchangedFiles="true" Retries="0" />
  18. <ItemGroup Condition="'$(MSBuildLastTaskResult)' == 'True'" >
  19. <FileWrites Include="$(WebProjectOutputDir)\bin\roslyn\*" />
  20. </ItemGroup>
  21. </Target>
  22. <Target Name = "KillVBCSCompilerAndRetryCopy" AfterTargets="CopyRoslynCompilerFilesToOutputDirectory" Condition="'$(MSBuildLastTaskResult)' == 'False'" >
  23. <KillProcess ProcessName="VBCSCompiler" ImagePath="$(WebProjectOutputDir)" />
  24. <Copy SourceFiles="@(RoslyCompilerFiles)" DestinationFolder="$(WebProjectOutputDir)\bin\roslyn" ContinueOnError="true" SkipUnchangedFiles="true" />
  25. <ItemGroup>
  26. <FileWrites Include="$(WebProjectOutputDir)\bin\roslyn\*" />
  27. </ItemGroup>
  28. </Target>
  29. <UsingTask TaskName="KillProcess" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
  30. <ParameterGroup>
  31. <ProcessName ParameterType="System.String" Required="true" />
  32. <ImagePath ParameterType="System.String" Required="true" />
  33. </ParameterGroup>
  34. <Task>
  35. <Reference Include="System" />
  36. <Reference Include="System.Management" />
  37. <Using Namespace="System" />
  38. <Using Namespace="System.Linq" />
  39. <Using Namespace="System.Diagnostics" />
  40. <Using Namespace="System.Management" />
  41. <Code Type="Fragment" Language="cs">
  42. <![CDATA[
  43. try
  44. {
  45. foreach(var p in Process.GetProcessesByName(ProcessName))
  46. {
  47. var wmiQuery = "SELECT ProcessId, ExecutablePath FROM Win32_Process WHERE ProcessId = " + p.Id;
  48. using(var searcher = new ManagementObjectSearcher(wmiQuery))
  49. {
  50. using(var results = searcher.Get())
  51. {
  52. var mo = results.Cast<ManagementObject>().FirstOrDefault();
  53. Log.LogMessage("ExecutablePath is {0}", (string)mo["ExecutablePath"]);
  54. if(mo != null && string.Compare((string)mo["ExecutablePath"], ImagePath, StringComparison.OrdinalIgnoreCase) > 0)
  55. {
  56. p.Kill();
  57. Log.LogMessage("{0} is killed", (string)mo["ExecutablePath"]);
  58. break;
  59. }
  60. }
  61. }
  62. }
  63. }
  64. catch (Exception ex)
  65. {
  66. Log.LogErrorFromException(ex);
  67. }
  68. return true;
  69. ]]>
  70. </Code>
  71. </Task>
  72. </UsingTask>
  73. </Project>