Skip to content

Commit

Permalink
Copy IbcMerge input files to log/ngen dir on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
tmat committed Jan 24, 2020
1 parent 76489d6 commit 98ceaa4
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/Microsoft.DotNet.Arcade.Sdk/tools/OptimizationData.targets
Original file line number Diff line number Diff line change
Expand Up @@ -100,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 @@ -138,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 @@ -166,14 +171,24 @@
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" />

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

<Error Text="IBCMerge failed with exit code $(_IbcMergeErrorCode). Input files copied to '%(_IbcMergeInvocation.LogFilesOnFailureDir)'."
Condition="'$(_IbcMergeErrorCode)' != '0' and '%(_IbcMergeInvocation.LogFilesOnFailure)' != ''" />

<!-- 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

0 comments on commit 98ceaa4

Please sign in to comment.