44 <Link >roslyn\%(RecursiveDir)%(Filename)%(Extension)</Link >
55 </RoslyCompilerFiles >
66 </ItemGroup >
7- <Target Name =" IncludeRoslynCompilerFilesToItemGroup " AfterTargets = " ResolveAssemblyReferences " >
7+ <Target Name =" RoslynCompilerFilesToPublish " >
88 <ItemGroup >
9- <None Include =" @(RoslyCompilerFiles)" Condition = " " >
10- < Link >%(RoslyCompilerFiles.Link)</ Link >
11- <CopyToOutputDirectory >PreserveNewest</ CopyToOutputDirectory >
12- </None >
9+ <_RoslynFiles Include =" @(RoslyCompilerFiles)" / >
10+ < FilesForPackagingFromProject Include = " %(_RoslynFiles.Identity) " >
11+ <DestinationRelativePath >bin\roslyn\%(RecursiveDir)%(Filename)%(Extension)</ DestinationRelativePath >
12+ </FilesForPackagingFromProject >
1313 </ItemGroup >
1414 </Target >
15+ <PropertyGroup >
16+ <CopyAllFilesToSingleFolderForPackageDependsOn >
17+ RoslynCompilerFilesToPublish;
18+ $(CopyAllFilesToSingleFolderForPackageDependsOn);
19+ </CopyAllFilesToSingleFolderForPackageDependsOn >
20+ </PropertyGroup >
1521 <Target Name =" CopyRoslynCompilerFilesToOutputDirectory" AfterTargets =" CopyFilesToOutputDirectory" >
16- <Copy SourceFiles =" @(RoslyCompilerFiles)" DestinationFolder =" $(OutDir) roslyn" ContinueOnError =" true" SkipUnchangedFiles =" true" />
22+ <Copy SourceFiles =" @(RoslyCompilerFiles)" DestinationFolder =" $(WebProjectOutputDir)\bin\ roslyn" ContinueOnError =" true" SkipUnchangedFiles =" true" Retries = " 0 " />
1723 </Target >
24+ <Target Name = " KillVBCSCompilerAndRetryCopy" AfterTargets =" CopyRoslynCompilerFilesToOutputDirectory" Condition =" '$(MSBuildLastTaskResult)' == 'False'" >
25+ <KillProcess ProcessName =" VBCSCompiler" ImagePath =" $(WebProjectOutputDir)" />
26+ <Copy SourceFiles =" @(RoslyCompilerFiles)" DestinationFolder =" $(WebProjectOutputDir)\bin\roslyn" ContinueOnError =" true" SkipUnchangedFiles =" true" />
27+ </Target >
28+ <UsingTask TaskName =" KillProcess" TaskFactory =" CodeTaskFactory" AssemblyFile =" $(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
29+ <ParameterGroup >
30+ <ProcessName ParameterType =" System.String" Required =" true" />
31+ <ImagePath ParameterType =" System.String" Required =" true" />
32+ </ParameterGroup >
33+ <Task >
34+ <Reference Include =" System" />
35+ <Reference Include =" System.Management" />
36+ <Using Namespace =" System" />
37+ <Using Namespace =" System.Linq" />
38+ <Using Namespace =" System.Diagnostics" />
39+ <Using Namespace =" System.Management" />
40+ <Code Type =" Fragment" Language =" cs" >
41+ <![CDATA[
42+ try
43+ {
44+ foreach(var p in Process.GetProcessesByName(ProcessName))
45+ {
46+ var wmiQuery = "SELECT ProcessId, ExecutablePath FROM Win32_Process WHERE ProcessId = " + p.Id;
47+ using(var searcher = new ManagementObjectSearcher(wmiQuery))
48+ {
49+ using(var results = searcher.Get())
50+ {
51+ var mo = results.Cast<ManagementObject>().FirstOrDefault();
52+ Log.LogMessage("ExecutablePath is {0}", (string)mo["ExecutablePath"]);
53+ if(mo != null && string.Compare((string)mo["ExecutablePath"], ImagePath, StringComparison.OrdinalIgnoreCase) > 0)
54+ {
55+ p.Kill();
56+ Log.LogMessage("{0} is killed", (string)mo["ExecutablePath"]);
57+ break;
58+ }
59+ }
60+ }
61+ }
62+ }
63+ catch (Exception ex)
64+ {
65+ Log.LogErrorFromException(ex);
66+ }
67+ return true;
68+ ]]>
69+ </Code >
70+ </Task >
71+ </UsingTask >
1872</Project >
0 commit comments