-
Notifications
You must be signed in to change notification settings - Fork 5
/
LogFileCopy.targets
71 lines (63 loc) · 2.59 KB
/
LogFileCopy.targets
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="Copy" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<SourceFiles Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<DestinationFolder ParameterType="Microsoft.Build.Framework.ITaskItem" />
<Retries ParameterType="System.Int32" />
<RetryDelayMilliseconds ParameterType="System.Int32" />
<UseHardlinksIfPossible ParameterType="System.Boolean" />
<SkipUnchangedFiles ParameterType="System.Boolean" />
<DestinationFiles Output="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<CopiedFiles Output="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
<OverwriteReadOnlyFiles ParameterType="System.Boolean" />
</ParameterGroup>
<Task>
<Reference Include="mscorlib" />
<Reference Include="Microsoft.Build" />
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Tasks.Core" />
<Using Namespace="System" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Text" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Shared" />
<Using Namespace="Microsoft.Build.Tasks" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Func<Microsoft.Build.Tasks.Copy, string> PrintItems = c =>
{
var sb = new StringBuilder();
for (int i = 0; i < c.SourceFiles.Length; i++)
{
var sourcePath = c.SourceFiles[i].GetMetadata("FullPath");
var destinationPath = c.DestinationFiles[i].GetMetadata("FullPath");
if (sourcePath != destinationPath)
{
sb.AppendLine(sourcePath);
sb.AppendLine(destinationPath);
}
}
return sb.ToString();
};
var copy = new Microsoft.Build.Tasks.Copy();
copy.BuildEngine = BuildEngine;
copy.SourceFiles = SourceFiles;
copy.DestinationFolder = DestinationFolder;
copy.DestinationFiles = DestinationFiles;
copy.Retries = Retries;
copy.RetryDelayMilliseconds = RetryDelayMilliseconds;
copy.UseHardlinksIfPossible = UseHardlinksIfPossible;
copy.SkipUnchangedFiles = SkipUnchangedFiles;
copy.OverwriteReadOnlyFiles = OverwriteReadOnlyFiles;
var result = copy.Execute();
lock(this.GetType())
{
File.AppendAllText("copylog.txt", PrintItems(copy));
}
return result;
]]>
</Code>
</Task>
</UsingTask>
</Project>