private bool ValidateCrossgen2Support() { ITaskItem crossgen2Pack = Crossgen2Packs?.FirstOrDefault(); _crossgen2Tool.PackagePath = crossgen2Pack?.GetMetadata(MetadataKeys.PackageDirectory); if (string.IsNullOrEmpty(_crossgen2Tool.PackagePath) || !NuGetVersion.TryParse(crossgen2Pack.GetMetadata(MetadataKeys.NuGetPackageVersion), out NuGetVersion crossgen2PackVersion)) { Log.LogError(Strings.ReadyToRunNoValidRuntimePackageError); return(false); } bool version5 = crossgen2PackVersion.Major < 6; bool isSupportedTarget = ExtractTargetPlatformAndArchitecture(_targetRuntimeIdentifier, out _targetPlatform, out _targetArchitecture); string targetOS = _targetPlatform switch { "linux" => "linux", "linux-musl" => "linux", "osx" => "osx", "win" => "windows", _ => null }; // In .NET 5 Crossgen2 supported only the following host->target compilation scenarios: // win-x64 -> win-x64 // linux-x64 -> linux-x64 // linux-musl-x64 -> linux-musl-x64 isSupportedTarget = isSupportedTarget && targetOS != null && (!version5 || _targetRuntimeIdentifier == _hostRuntimeIdentifier) && GetCrossgen2ComponentsPaths(version5); if (!isSupportedTarget) { Log.LogError(Strings.ReadyToRunTargetNotSupportedError); return(false); } // Create tool task item Crossgen2Tool = new TaskItem(_crossgen2Tool.ToolPath); Crossgen2Tool.SetMetadata(MetadataKeys.IsVersion5, version5.ToString()); if (version5) { Crossgen2Tool.SetMetadata(MetadataKeys.JitPath, _crossgen2Tool.ClrJitPath); } else { Crossgen2Tool.SetMetadata(MetadataKeys.TargetOS, targetOS); Crossgen2Tool.SetMetadata(MetadataKeys.TargetArch, ArchitectureToString(_targetArchitecture)); if (!string.IsNullOrEmpty(PerfmapFormatVersion)) { Crossgen2Tool.SetMetadata(MetadataKeys.PerfmapFormatVersion, PerfmapFormatVersion); } } _crossgen2IsVersion5 = version5; return(true); }
protected override void ExecuteCore() { _runtimePack = GetNETCoreAppRuntimePack(); _crossgen2Pack = Crossgen2Packs?.FirstOrDefault(); _targetRuntimeIdentifier = _runtimePack?.GetMetadata(MetadataKeys.RuntimeIdentifier); // Get the list of runtime identifiers that we support and can target ITaskItem targetingPack = GetNETCoreAppTargetingPack(); string supportedRuntimeIdentifiers = targetingPack?.GetMetadata(MetadataKeys.RuntimePackRuntimeIdentifiers); var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath); var supportedRIDsList = supportedRuntimeIdentifiers == null?Array.Empty <string>() : supportedRuntimeIdentifiers.Split(';'); // Get the best RID for the host machine, which will be used to validate that we can run crossgen for the target platform and architecture _hostRuntimeIdentifier = NuGetUtils.GetBestMatchingRid( runtimeGraph, NETCoreSdkRuntimeIdentifier, supportedRIDsList, out bool wasInGraph); if (_hostRuntimeIdentifier == null || _targetRuntimeIdentifier == null) { Log.LogError(Strings.ReadyToRunNoValidRuntimePackageError); return; } if (ReadyToRunUseCrossgen2) { if (!ValidateCrossgen2Support()) { return; } // NOTE: Crossgen2 does not yet currently support emitting native symbols, and until this feature // is implemented, we will use crossgen for it. This should go away in the future when crossgen2 supports the feature. if (EmitSymbols && !ValidateCrossgenSupport()) { return; } } else { if (!ValidateCrossgenSupport()) { return; } } // Future: check DiaSymReaderPath in the _crossgen2Tool info when crossgen2 starts supporting emitting native symbols bool hasValidDiaSymReaderLib = String.IsNullOrEmpty(_crossgenTool.DiaSymReaderPath) ? false : File.Exists(_crossgenTool.DiaSymReaderPath); // Process input lists of files ProcessInputFileList(Assemblies, _compileList, _symbolsCompileList, _r2rFiles, _r2rReferences, hasValidDiaSymReaderLib); }
protected override void ExecuteCore() { _runtimePack = GetNETCoreAppRuntimePack(); _crossgen2Pack = Crossgen2Packs?.FirstOrDefault(); _targetRuntimeIdentifier = _runtimePack?.GetMetadata(MetadataKeys.RuntimeIdentifier); // Get the list of runtime identifiers that we support and can target ITaskItem targetingPack = GetNETCoreAppTargetingPack(); string supportedRuntimeIdentifiers = targetingPack?.GetMetadata(MetadataKeys.RuntimePackRuntimeIdentifiers); var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath); var supportedRIDsList = supportedRuntimeIdentifiers == null?Array.Empty <string>() : supportedRuntimeIdentifiers.Split(';'); // Get the best RID for the host machine, which will be used to validate that we can run crossgen for the target platform and architecture _hostRuntimeIdentifier = NuGetUtils.GetBestMatchingRid( runtimeGraph, NETCoreSdkRuntimeIdentifier, supportedRIDsList, out _); if (_hostRuntimeIdentifier == null || _targetRuntimeIdentifier == null) { Log.LogError(Strings.ReadyToRunNoValidRuntimePackageError); return; } if (ReadyToRunUseCrossgen2) { if (!ValidateCrossgen2Support()) { return; } // NOTE: Crossgen2 does not yet currently support emitting native symbols, and until this feature // is implemented, we will use crossgen for it. This should go away in the future when crossgen2 supports the feature. if (EmitSymbols && !ValidateCrossgenSupport()) { return; } } else { if (!ValidateCrossgenSupport()) { return; } } }
protected override void ExecuteCore() { _runtimePack = GetNETCoreAppRuntimePack(); _crossgen2Pack = Crossgen2Packs?.FirstOrDefault(); _targetRuntimeIdentifier = _runtimePack?.GetMetadata(MetadataKeys.RuntimeIdentifier); // Get the list of runtime identifiers that we support and can target ITaskItem targetingPack = GetNETCoreAppTargetingPack(); string supportedRuntimeIdentifiers = targetingPack?.GetMetadata(MetadataKeys.RuntimePackRuntimeIdentifiers); var runtimeGraph = new RuntimeGraphCache(this).GetRuntimeGraph(RuntimeGraphPath); var supportedRIDsList = supportedRuntimeIdentifiers == null?Array.Empty <string>() : supportedRuntimeIdentifiers.Split(';'); // Get the best RID for the host machine, which will be used to validate that we can run crossgen for the target platform and architecture _hostRuntimeIdentifier = NuGetUtils.GetBestMatchingRid( runtimeGraph, NETCoreSdkRuntimeIdentifier, supportedRIDsList, out _); if (_hostRuntimeIdentifier == null || _targetRuntimeIdentifier == null) { Log.LogError(Strings.ReadyToRunNoValidRuntimePackageError); return; } if (ReadyToRunUseCrossgen2) { if (!ValidateCrossgen2Support()) { return; } // In .NET 5 Crossgen2 did not support emitting native symbols, so we use Crossgen to emit them if (_crossgen2IsVersion5 && EmitSymbols && !ValidateCrossgenSupport()) { return; } } else { if (!ValidateCrossgenSupport()) { return; } } }