-
Notifications
You must be signed in to change notification settings - Fork 0
/
Directory.Build.targets
42 lines (42 loc) · 2.16 KB
/
Directory.Build.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
<?xml version="1.0" encoding="utf-8" ?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target BeforeTargets="BeforeBuild" Name="Diagnostic BeforeBuild">
<PropertyGroup>
<StartTicks>$([System.DateTime]::UtcNow.Ticks)</StartTicks>
</PropertyGroup>
</Target>
<Target AfterTargets="AfterBuild" Name="Diagnostic AfterBuild">
<PropertyGroup>
<FinishTicks>$([System.DateTime]::UtcNow.Ticks)</FinishTicks>
<ElapsedTicks>$([MSBuild]::Subtract($(FinishTicks), $(StartTicks)))</ElapsedTicks>
<Elapsed>$([System.TimeSpan]::FromTicks($(ElapsedTicks)))</Elapsed>
</PropertyGroup>
<GetFileSize Files="@(Compile)">
<Output TaskParameter="FileSizes" PropertyName="CompileFileSizes"/>
</GetFileSize>
<Message Text="-------- Diagnostic --------------------------------" Importance="High"/>
<Message Text="Project name : $(ProjectName)" Importance="High"/>
<Message Text="Build time : $(Elapsed)" Importance="High"/>
<Message Text="Compile items count : @(Compile->Count())" Importance="High"/>
<Message Text="Compile items size : $(CompileFileSizes) bytes" Importance="High"/>
<Message Text="Referenced assemblies : @(ReferencePath->Count())" Importance="High"/>
<Message Text="NuGet packages : @(PackageReference->Count())" Importance="High"/>
<Message Text="----------------------------------------------------" Importance="High"/>
</Target>
<UsingTask TaskName="GetFileSize" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<FileSizes ParameterType="System.Int64" Output="true"/>
</ParameterGroup>
<Task>
<Using Namespace="System.IO"/>
<Code Type="Fragment" Language="cs"><![CDATA[
foreach(var file in Files)
{
var fi = new FileInfo(file.ItemSpec);
FileSizes += fi.Length;
}
]]></Code>
</Task>
</UsingTask>
</Project>