private string GenerateCrossgenResponseFile() { StringBuilder result = new StringBuilder(); result.AppendLine("/nologo"); if (IsPdbCompilation) { result.Append(GetAssemblyReferencesCommands()); if (!String.IsNullOrEmpty(DiaSymReader)) { result.AppendLine($"/DiasymreaderPath \"{DiaSymReader}\""); } result.AppendLine(_createPDBCommand); result.AppendLine($"\"{_outputR2RImage}\""); } else { result.AppendLine("/MissingDependenciesOK"); result.AppendLine($"/JITPath \"{CrossgenTool.GetMetadata("JitPath")}\""); result.Append(GetAssemblyReferencesCommands()); result.AppendLine($"/out \"{_outputR2RImage}\""); result.AppendLine($"\"{_inputAssembly}\""); } return(result.ToString()); }
protected override void ExecuteCore() { if (ReadyToRunUseCrossgen2) { string isVersion5 = Crossgen2Tool.GetMetadata(MetadataKeys.IsVersion5); _crossgen2IsVersion5 = !string.IsNullOrEmpty(isVersion5) && bool.Parse(isVersion5); string perfmapVersion = Crossgen2Tool.GetMetadata(MetadataKeys.PerfmapFormatVersion); _perfmapFormatVersion = !string.IsNullOrEmpty(perfmapVersion) ? int.Parse(perfmapVersion) : 0; if (Crossgen2Composite && EmitSymbols && _crossgen2IsVersion5) { Log.LogError(Strings.Crossgen5CannotEmitSymbolsInCompositeMode); return; } } string diaSymReaderPath = CrossgenTool?.GetMetadata(MetadataKeys.DiaSymReader); bool hasValidDiaSymReaderLib = ReadyToRunUseCrossgen2 && !_crossgen2IsVersion5 || !string.IsNullOrEmpty(diaSymReaderPath) && File.Exists(diaSymReaderPath); // Process input lists of files ProcessInputFileList(Assemblies, _compileList, _symbolsCompileList, _r2rFiles, _r2rReferences, _r2rCompositeReferences, _r2rCompositeInput, hasValidDiaSymReaderLib); }
protected override bool ValidateParameters() { _createPDBCommand = CompilationEntry.GetMetadata("CreatePDBCommand"); if (CrossgenTool == null && Crossgen2Tool == null) { return(false); } if (IsPdbCompilation && CrossgenTool == null) { // We need the crossgen tool for now to emit native symbols. Crossgen2 does not yet support this feature return(false); } if (CrossgenTool != null) { if (!File.Exists(CrossgenTool.ItemSpec) || !File.Exists(CrossgenTool.GetMetadata("JitPath"))) { return(false); } } if (Crossgen2Tool != null) { if (!File.Exists(Crossgen2Tool.ItemSpec) || !File.Exists(Crossgen2Tool.GetMetadata("JitPath"))) { return(false); } } if (IsPdbCompilation) { _outputR2RImage = CompilationEntry.ItemSpec; _outputPDBImage = CompilationEntry.GetMetadata("OutputPDBImage"); if (!String.IsNullOrEmpty(DiaSymReader) && !File.Exists(DiaSymReader)) { return(false); } // R2R image has to be created before emitting native symbols (crossgen needs this as an input argument) if (String.IsNullOrEmpty(_outputPDBImage) || !File.Exists(_outputR2RImage)) { return(false); } } else { _inputAssembly = CompilationEntry.ItemSpec; _outputR2RImage = CompilationEntry.GetMetadata("OutputR2RImage"); if (!File.Exists(_inputAssembly)) { return(false); } } return(true); }
protected override void ExecuteCore() { // Future: when crossgen2 supports generating PDBs, update this to check crossgen2 when we are using crossgen2. string diaSymReaderPath = CrossgenTool?.GetMetadata(MetadataKeys.DiaSymReader); bool hasValidDiaSymReaderLib = !string.IsNullOrEmpty(diaSymReaderPath) && File.Exists(diaSymReaderPath); // Process input lists of files ProcessInputFileList(Assemblies, _compileList, _symbolsCompileList, _r2rFiles, _r2rReferences, hasValidDiaSymReaderLib); }
protected override bool ValidateParameters() { _crossgenPath = CrossgenTool.ItemSpec; _clrjitPath = CrossgenTool.GetMetadata("JitPath"); _diasymreaderPath = CrossgenTool.GetMetadata("DiaSymReader"); if (!File.Exists(_crossgenPath) || !File.Exists(_clrjitPath)) { return(false); } _createPDBCommand = CompilationEntry.GetMetadata("CreatePDBCommand"); _platformAssembliesPaths = CompilationEntry.GetMetadata("PlatformAssembliesPaths"); if (IsPdbCompilation) { _outputR2RImage = CompilationEntry.ItemSpec; _outputPDBImage = CompilationEntry.GetMetadata("OutputPDBImage"); if (!String.IsNullOrEmpty(_diasymreaderPath) && !File.Exists(_diasymreaderPath)) { return(false); } // R2R image has to be created before emitting native symbols (crossgen needs this as an input argument) if (String.IsNullOrEmpty(_outputPDBImage) || !File.Exists(_outputR2RImage)) { return(false); } } else { _inputAssembly = CompilationEntry.ItemSpec; _outputR2RImage = CompilationEntry.GetMetadata("OutputR2RImage"); if (!File.Exists(_inputAssembly)) { return(false); } } return(true); }
protected override void ExecuteCore() { // Future: when crossgen2 supports generating PDBs, update this to check crossgen2 when we are using crossgen2. string diaSymReaderPath = CrossgenTool?.GetMetadata(MetadataKeys.DiaSymReader); bool hasValidDiaSymReaderLib = !string.IsNullOrEmpty(diaSymReaderPath) && File.Exists(diaSymReaderPath); if (ReadyToRunUseCrossgen2) { string isVersion5 = Crossgen2Tool.GetMetadata(MetadataKeys.IsVersion5); _crossgen2IsVersion5 = !string.IsNullOrEmpty(isVersion5) && bool.Parse(isVersion5); if (Crossgen2Composite && EmitSymbols && _crossgen2IsVersion5) { Log.LogError(Strings.Crossgen5CannotEmitSymbolsInCompositeMode); return; } } // Process input lists of files ProcessInputFileList(Assemblies, _compileList, _symbolsCompileList, _r2rFiles, _r2rReferences, hasValidDiaSymReaderLib); }
protected override bool ValidateParameters() { string emitSymbolsMetadata = CompilationEntry.GetMetadata(MetadataKeys.EmitSymbols); _emitSymbols = !string.IsNullOrEmpty(emitSymbolsMetadata) && bool.Parse(emitSymbolsMetadata); _createPDBCommand = CompilationEntry.GetMetadata(MetadataKeys.CreatePDBCommand); string createCompositeImageMetadata = CompilationEntry.GetMetadata(MetadataKeys.CreateCompositeImage); _createCompositeImage = !string.IsNullOrEmpty(createCompositeImageMetadata) && bool.Parse(createCompositeImageMetadata); if (IsPdbCompilation && CrossgenTool == null) { // PDB compilation is a step specific to Crossgen1 and 5.0 Crossgen2 // which didn't support PDB generation. 6.0 Crossgen2 produces symbols // directly during native compilation. Log.LogError(Strings.CrossgenToolMissingInPDBCompilationMode); return(false); } if (ActuallyUseCrossgen2) { if (Crossgen2Tool == null) { Log.LogError(Strings.Crossgen2ToolMissingWhenUseCrossgen2IsSet); return(false); } if (!File.Exists(Crossgen2Tool.ItemSpec)) { Log.LogError(Strings.Crossgen2ToolExecutableNotFound, Crossgen2Tool.ItemSpec); return(false); } string hostPath = DotNetHostPath; if (!string.IsNullOrEmpty(hostPath) && !File.Exists(hostPath)) { Log.LogError(Strings.DotNetHostExecutableNotFound, hostPath); return(false); } string jitPath = Crossgen2Tool.GetMetadata(MetadataKeys.JitPath); if (!string.IsNullOrEmpty(jitPath)) { if (!File.Exists(jitPath)) { Log.LogError(Strings.JitLibraryNotFound, jitPath); return(false); } } else if (Crossgen2IsVersion5) { // We expect JitPath to be set for .NET 5 and {TargetOS, TargetArch} to be set for .NET 6 and later Log.LogError(Strings.Crossgen2MissingRequiredMetadata, MetadataKeys.JitPath); return(false); } else { // For smooth switchover we accept both JitPath and TargetOS / TargetArch in .NET 6 Crossgen2 if (string.IsNullOrEmpty(Crossgen2Tool.GetMetadata(MetadataKeys.TargetOS))) { Log.LogError(Strings.Crossgen2MissingRequiredMetadata, MetadataKeys.TargetOS); return(false); } if (string.IsNullOrEmpty(Crossgen2Tool.GetMetadata(MetadataKeys.TargetArch))) { Log.LogError(Strings.Crossgen2MissingRequiredMetadata, MetadataKeys.TargetArch); return(false); } } } else { if (CrossgenTool == null) { Log.LogError(Strings.CrossgenToolMissingWhenUseCrossgen2IsNotSet); return(false); } if (!File.Exists(CrossgenTool.ItemSpec)) { Log.LogError(Strings.CrossgenToolExecutableNotFound, CrossgenTool.ItemSpec); return(false); } if (!File.Exists(CrossgenTool.GetMetadata(MetadataKeys.JitPath))) { Log.LogError(Strings.JitLibraryNotFound, MetadataKeys.JitPath); return(false); } } _outputPDBImage = CompilationEntry.GetMetadata(MetadataKeys.OutputPDBImage); if (IsPdbCompilation) { _outputR2RImage = CompilationEntry.ItemSpec; if (!string.IsNullOrEmpty(DiaSymReader) && !File.Exists(DiaSymReader)) { Log.LogError(Strings.DiaSymReaderLibraryNotFound, DiaSymReader); return(false); } // R2R image has to be created before emitting native symbols (crossgen needs this as an input argument) if (string.IsNullOrEmpty(_outputPDBImage)) { Log.LogError(Strings.MissingOutputPDBImagePath); } if (!File.Exists(_outputR2RImage)) { Log.LogError(Strings.PDBGeneratorInputExecutableNotFound, _outputR2RImage); return(false); } } else { _outputR2RImage = CompilationEntry.GetMetadata(MetadataKeys.OutputR2RImage); if (!_createCompositeImage) { _inputAssembly = CompilationEntry.ItemSpec; if (!File.Exists(_inputAssembly)) { Log.LogError(Strings.InputAssemblyNotFound, _inputAssembly); return(false); } } else { _inputAssembly = "CompositeImage"; } if (string.IsNullOrEmpty(_outputR2RImage)) { Log.LogError(Strings.MissingOutputR2RImageFileName); return(false); } if (_emitSymbols && string.IsNullOrEmpty(_outputPDBImage)) { Log.LogError(Strings.MissingOutputPDBImagePath); } } return(true); }