Last active
February 15, 2021 12:44
-
-
Save cjaSource/fdc34444ab1ae6036604f0d750f59041 to your computer and use it in GitHub Desktop.
Directory.Build.targets NETFramework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project> | |
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" /> | |
<UsingTask TaskName="LaunchTelemetry" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v12.0.dll"> | |
<ParameterGroup> | |
<BuildTimeToRegister ParameterType="System.String" Required="true" /> | |
</ParameterGroup> | |
<Task> | |
<Using Namespace="System.Diagnostics" /> | |
<Using Namespace="System.Runtime " /> | |
<Code Type="Fragment" Language="cs"> | |
<![CDATA[ | |
try { | |
ProcessStartInfo sinfo = new ProcessStartInfo(); | |
sinfo.CreateNoWindow = true; | |
sinfo.UseShellExecute = false; | |
sinfo.FileName = @"]]>$(SolutionDir)BuildScripts\tools\Cake\Cake.exe<![CDATA["; | |
string cakeFile = @"]]>$(SolutionDir)BuildScripts\vstelemetry.cake<![CDATA["; | |
string queryParams = " --buildtime=" + BuildTimeToRegister + " --project=]]>'$(ProjectName)'<![CDATA["; | |
sinfo.Arguments = " " + cakeFile + queryParams; | |
Process.Start(sinfo); | |
} catch(Exception) { | |
// Do not interfere with devs | |
} | |
]]> | |
</Code> | |
</Task> | |
</UsingTask> | |
<Target Name="beforebuild" BeforeTargets="build" Condition="'$(BuildingSS_fcbat)' != 'true'"> | |
<PropertyGroup> | |
<Time>$([System.DateTime]::Now)</Time> | |
</PropertyGroup> | |
</Target> | |
<Target Name="afterbuild" AfterTargets="build" Condition="'$(BuildingSS_fcbat)' != 'true'"> | |
<PropertyGroup> | |
<BuildTime>$([System.DateTime]::Now.Subtract($([System.DateTime]::Parse($(Time)))).ToString())</BuildTime> | |
</PropertyGroup> | |
<LaunchTelemetry BuildTimeToRegister="'$(BuildTime)'" /> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment