Skip to content

Commit

Permalink
Ibc merge failure logging (#5277)
Browse files Browse the repository at this point in the history
* Ibc merge failure logging (#4678)

* Remove obsolete properties

* Copy IbcMerge input files to log/ngen dir on failure

* Condition IBCMerge error handling on IBC run (#4714)

Currently an IBCMerge error is thrown even though the tool doesn't even
run. Adding a condition to only do error handling if IBC ran. As I
already was there, I also conditioned the Message task.

Co-authored-by: Viktor Hofer <[email protected]>
  • Loading branch information
tmat and ViktorHofer authored Apr 17, 2020
1 parent bebaa0c commit 0226543
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
36 changes: 23 additions & 13 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/OptimizationData.targets
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
EnableNgenOptimizationLogDetails Set to true to enable NGEN method logging output
ApplyNgenOptimization Set to 'partial' or 'full' in a project to embed partial/full NGEN optimization data to the built binary.
Obsolete (https://github.com/dotnet/arcade/issues/2092):
EnablePartialNgenOptimization Set to true to enable Partial NGEN optimization data embedding.
ApplyPartialNgenOptimization Set to true in a project to apply Partial NGEN optimization data to the built binary.
Items:
OptimizeAssembly Set of assemblies to apply Partial NGEN optimization data to.
-->
Expand All @@ -24,12 +20,9 @@
<PropertyGroup>
<PostCompileBinaryModificationSentinelFile>$(IntermediateOutputPath)$(TargetFileName).pcbm</PostCompileBinaryModificationSentinelFile>

<!-- TODO: remove (https://github.com/dotnet/arcade/issues/2092) -->
<EnablePartialNgenOptimization Condition="'$(EnablePartialNgenOptimization)' == '' and '$(Configuration)' == 'Release' and '$(OfficialBuild)' == 'true'">true</EnablePartialNgenOptimization>

<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == ''">$(EnablePartialNgenOptimization)</EnableNgenOptimization>
<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == '' and '$(Configuration)' == 'Release' and '$(OfficialBuild)' == 'true'">true</EnableNgenOptimization>
<EnableNgenOptimizationLogDetails Condition="'$(EnableNgenOptimizationLogDetails)' == ''">$(UsingToolVisualStudioIbcTraining)</EnableNgenOptimizationLogDetails>
<ApplyNgenOptimization Condition="'$(ApplyPartialNgenOptimization)' == 'true'">partial</ApplyNgenOptimization>

<_IbcMergeXmlOutputDir>$(ArtifactsTmpDir)ibcxml</_IbcMergeXmlOutputDir>
</PropertyGroup>

Expand Down Expand Up @@ -107,10 +100,11 @@
<_IbcFileByAssemblyName Include="@(_IbcFile->'%(AssemblyFileName)')"
IbcFiles="%(_IbcFile.Identity)"
PreviousAssemblyPath="%(_IbcFile.PreviousAssemblyDir)\%(_IbcFile.AssemblyFileName)"
PreviousAssemblyCopyPath="$(ArtifactsTmpDir)OptimizedAssemblies\$([System.Guid]::NewGuid())"
UniqueId="$([System.Guid]::NewGuid())"
PreviousAssemblyCopyPath="$(ArtifactsTmpDir)OptimizedAssemblies\%(_IbcFileByAssemblyName.UniqueId)"
OptimizeAssemblyPath="%(_IbcFile.OptimizeAssemblyPath)"
TargetFramework="%(_IbcFile.TargetFramework)"
XmlOutputPath="$(_IbcMergeXmlOutputDir)\%(_IbcFile.AssemblyFileName).$([System.Guid]::NewGuid()).temp.ibc.xml" />
XmlOutputPath="$(_IbcMergeXmlOutputDir)\%(_IbcFile.AssemblyFileName).%(_IbcFileByAssemblyName.UniqueId).temp.ibc.xml" />
</ItemGroup>

<Error Text="No optimization data found for assemblies: @(_AssemblyWithoutRawIbcData, ', ')"
Expand Down Expand Up @@ -145,6 +139,10 @@
<UnsignFile>%(_AssemblyWithRawIbcData.OptimizeAssemblyPath)</UnsignFile>
<XmlOutputPath Condition="'$(EnableNgenOptimizationLogDetails)' == 'true'">%(_AssemblyWithRawIbcData.XmlOutputPath)</XmlOutputPath>
<TargetFramework>%(_AssemblyWithRawIbcData.TargetFramework)</TargetFramework>

<!-- Files to copy to log dir if IbcMerge fails -->
<LogFilesOnFailure>%(_AssemblyWithRawIbcData.OptimizeAssemblyPath);%(_AssemblyWithRawIbcData.PreviousAssemblyCopyPath)</LogFilesOnFailure>
<LogFilesOnFailureDir>$(ArtifactsLogNgenDir)%(_AssemblyWithRawIbcData.UniqueId)\</LogFilesOnFailureDir>
</_IbcMergeInvocation>

<_IbcMergeInvocation>
Expand Down Expand Up @@ -173,14 +171,26 @@
DestinationFiles="%(_IbcMergeInvocation.CopyFilesDestination)"
Condition="'%(_IbcMergeInvocation.CopyFilesSource)' != ''" />

<Exec Command='"$(DotNetTool)" exec "$(_IbcMergePath)" %(_IbcMergeInvocation.IbcMergeArgs)' ConsoleToMSBuild="true" Condition="'$(_RunIbcMerge)' == 'true'">
<Exec Command='"$(DotNetTool)" exec "$(_IbcMergePath)" %(_IbcMergeInvocation.IbcMergeArgs)' ConsoleToMSBuild="true" Condition="'$(_RunIbcMerge)' == 'true'" IgnoreExitCode="true">
<Output TaskParameter="ConsoleOutput" PropertyName="_IbcMergeOutput" />
<Output TaskParameter="ExitCode" PropertyName="_IbcMergeErrorCode" />
</Exec>

<Message Text="$(_IbcMergeOutput)" Importance="low" />
<Message Text="$(_IbcMergeOutput)"
Importance="low"
Condition="'$(_RunIbcMerge)' == 'true'" />

<!-- Copy IBCMerge input assembly to logs if the tool fails, to allow investigation -->
<Copy SourceFiles="%(_IbcMergeInvocation.LogFilesOnFailure)"
DestinationFolder="%(_IbcMergeInvocation.LogFilesOnFailureDir)"
Condition="'$(_RunIbcMerge)' == 'true' and '$(_IbcMergeErrorCode)' != '0' and '%(_IbcMergeInvocation.LogFilesOnFailure)' != ''" />

<Error Text="IBCMerge failed with exit code $(_IbcMergeErrorCode)."
Condition="'$(_RunIbcMerge)' == 'true' and '$(_IbcMergeErrorCode)' != '0'" />

<!-- Remove Authenticode signing record if present. -->
<Microsoft.DotNet.Arcade.Sdk.Unsign FilePath="%(_IbcMergeInvocation.UnsignFile)" Condition="'%(_IbcMergeInvocation.UnsignFile)' != ''" />

<Microsoft.DotNet.Arcade.Sdk.ExtractNgenMethodList
IbcXmlFilePath="%(_IbcMergeInvocation.XmlOutputPath)"
AssemblyFilePath="%(_IbcMergeInvocation.UnsignFile)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
<UsingTask AssemblyFile="$(_VisualStudioBuildTasksAssembly)" TaskName="Microsoft.DotNet.Build.Tasks.VisualStudio.FindLatestDrop"/>

<PropertyGroup>
<!-- TODO: remove (https://github.com/dotnet/arcade/issues/2092) -->
<EnablePartialNgenOptimization Condition="'$(EnablePartialNgenOptimization)' == '' and '$(Configuration)' == 'Release' and '$(OfficialBuild)' == 'true'">true</EnablePartialNgenOptimization>

<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == ''">$(EnablePartialNgenOptimization)</EnableNgenOptimization>
<EnableNgenOptimization Condition="'$(EnableNgenOptimization)' == '' and '$(Configuration)' == 'Release' and '$(OfficialBuild)' == 'true'">true</EnableNgenOptimization>
</PropertyGroup>

<!--
Expand Down

0 comments on commit 0226543

Please sign in to comment.