diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolveRuntimePackAssets.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolveRuntimePackAssets.cs index 32ab2738095d..0390095cf427 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolveRuntimePackAssets.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolveRuntimePackAssets.cs @@ -118,6 +118,10 @@ private void AddRuntimePackAssetsFromManifest(List runtimePackAssets, { assetType = "native"; } + else if (typeAttributeValue.Equals("PgoData", StringComparison.OrdinalIgnoreCase)) + { + assetType = "pgodata"; + } else if (typeAttributeValue.Equals("Resources", StringComparison.OrdinalIgnoreCase)) { assetType = "resources"; @@ -166,7 +170,9 @@ private static TaskItem CreateAssetItem(string assetPath, string assetType, ITas var assetItem = new TaskItem(assetPath); - assetItem.SetMetadata(MetadataKeys.CopyLocal, "true"); + if (assetType != "pgodata") + assetItem.SetMetadata(MetadataKeys.CopyLocal, "true"); + if (string.IsNullOrEmpty(culture)) { assetItem.SetMetadata(MetadataKeys.DestinationSubPath, Path.GetFileName(assetPath)); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvedFile.cs b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvedFile.cs index 55b1e9fb6d99..7fffcbcc1771 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/ResolvedFile.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/ResolvedFile.cs @@ -13,7 +13,8 @@ internal enum AssetType None, Runtime, Native, - Resources + Resources, + PgoData } internal class ResolvedFile diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs b/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs index 153e70076a11..187365821d54 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/RunReadyToRunCompiler.cs @@ -25,6 +25,7 @@ public class RunReadyToRunCompiler : ToolTask public bool ShowCompilerWarnings { get; set; } public bool UseCrossgen2 { get; set; } public string Crossgen2ExtraCommandLineArgs { get; set; } + public ITaskItem[] Crossgen2PgoFiles { get; set; } [Output] public bool WarningsDetected { get; set; } @@ -329,6 +330,14 @@ private string GenerateCrossgen2ResponseFile() } } + if (Crossgen2PgoFiles != null) + { + foreach (var mibc in Crossgen2PgoFiles) + { + result.AppendLine($"-m:\"{mibc.ItemSpec}\""); + } + } + if (!string.IsNullOrEmpty(Crossgen2ExtraCommandLineArgs)) { foreach (string extraArg in Crossgen2ExtraCommandLineArgs.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries)) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/RuntimePackAssetInfo.cs b/src/Tasks/Microsoft.NET.Build.Tasks/RuntimePackAssetInfo.cs index d2781db24490..d63709427b3c 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/RuntimePackAssetInfo.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/RuntimePackAssetInfo.cs @@ -39,6 +39,10 @@ public static RuntimePackAssetInfo FromItem(ITaskItem item) { assetInfo.AssetType = AssetType.Resources; } + else if (assetTypeString.Equals("pgodata", StringComparison.OrdinalIgnoreCase)) + { + assetInfo.AssetType = AssetType.PgoData; + } else { throw new InvalidOperationException("Unexpected asset type: " + item.GetMetadata(MetadataKeys.AssetType)); diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets index 1a133ed839bb..14717f9381f7 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.CrossGen.targets @@ -17,6 +17,7 @@ Copyright (c) .NET Foundation. All rights reserved. false true false + true - + @@ -397,6 +398,12 @@ Copyright (c) .NET Foundation. All rights reserved. <_ReadyToRunImplementationAssemblies Include="@(_ReadyToRunImplementationAssembliesWithoutConflicts)" /> + + <_ReadyToRunPgoFiles Include="@(PublishReadyToRunPgoFiles)" /> + <_ReadyToRunPgoFiles Include="@(RuntimePackAsset)" + Condition="'%(RuntimePackAsset.AssetType)' == 'pgodata' and '%(RuntimePackAsset.Extension)' == '.mibc' and '$(PublishReadyToRunUseRuntimePackOptimizationData)' == 'true'" /> + + <_ResolvedCopyLocalPublishAssets Include="@(RuntimePackAsset)" - Condition="'$(SelfContained)' == 'true' Or '%(RuntimePackAsset.RuntimePackAlwaysCopyLocal)' == 'true'" /> + Condition="('$(SelfContained)' == 'true' Or '%(RuntimePackAsset.RuntimePackAlwaysCopyLocal)' == 'true') and '%(RuntimePackAsset.AssetType)' != 'pgodata'" /> diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets index e654a53d222a..0ade634ff93a 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets @@ -398,7 +398,7 @@ Copyright (c) .NET Foundation. All rights reserved. + Condition="'$(CopyLocalLockFileAssemblies)' == 'true' and ('$(SelfContained)' == 'true' or '%(RuntimePackAsset.RuntimePackAlwaysCopyLocal)' == 'true') and '%(RuntimePackAsset.AssetType)' != 'pgodata'" />