public override bool Execute() { _log = new BuildLogger { BuildEngine = BuildEngine }; ValidateAssemblyPath(); var tools = new Tools( ilasmPath: Path.Combine(MSBuildFrameworkToolsPath, "ilasm.exe"), ildasmPath: new DirectoryInfo(FrameworkSDKRoot).GetFiles("ildasm.exe", SearchOption.AllDirectories).OrderByDescending(_ => _.DirectoryName).FirstOrDefault()?.FullName, _log ); var cacheDir = new DirectoryInfo(CacheDir); if (!cacheDir.Exists) { cacheDir.Create(); } var processor = new Processor(_log, tools) { AssemblyFile = new FileInfo(AssemblyFile), TcPluginBase = new FileInfo(TcPluginBase), IntermediateDirectory = new DirectoryInfo(IntermediateDirectory), CacheDir = cacheDir, ReferenceFiles = ReferenceCopyLocalFiles.Select(_ => new FileInfo(_.ItemSpec)).ToList(), IsRelease = Configuration == "Release", }; return(System.Threading.Tasks.Task.Run(async() => await processor.ExecuteAsync(_token.Token), _token.Token).Result); }
public override bool Execute() { // System.Diagnostics.Debugger.Launch(); var referenceCopyLocalPaths = ReferenceCopyLocalFiles.Select(x => x.ItemSpec).ToList(); var defineConstants = DefineConstants.GetConstants(); processor = new Processor { Logger = new BuildLogger { BuildEngine = BuildEngine, }, AssemblyFilePath = AssemblyFile, IntermediateDirectory = IntermediateDirectory, KeyFilePath = KeyOriginatorFile ?? AssemblyOriginatorKeyFile, SignAssembly = SignAssembly, ProjectDirectory = ProjectDirectory, DocumentationFilePath = DocumentationFile, References = References, SolutionDirectory = SolutionDirectoryFinder.Find(SolutionDirectory, NCrunchOriginalSolutionDirectory, ProjectDirectory), ReferenceCopyLocalPaths = referenceCopyLocalPaths, DefineConstants = defineConstants, NuGetPackageRoot = NuGetPackageRoot, MSBuildDirectory = MSBuildThisFileDirectory, WeaverFilesFromProps = GetWeaverFilesFromProps(), DebugSymbols = GetDebugSymbolsType() }; var success = processor.Execute(); if (success) { var weavers = processor.Weavers.Select(x => x.AssemblyName); ExecutedWeavers = string.Join(";", weavers) + ";"; File.WriteAllLines(IntermediateCopyLocalFilesCache, processor.ReferenceCopyLocalPaths); } else { if (File.Exists(IntermediateCopyLocalFilesCache)) { File.Delete(IntermediateCopyLocalFilesCache); } } return(success); }
void InnerExecute() { if (string.IsNullOrEmpty(IntermediateCopyLocalFilesCache) || !File.Exists(IntermediateCopyLocalFilesCache)) { return; } var updatedReferenceCopyLocalPaths = new HashSet <string>(File.ReadAllLines(IntermediateCopyLocalFilesCache), StringComparer.OrdinalIgnoreCase); var referenceCopyLocalPaths = new HashSet <string>(ReferenceCopyLocalFiles.Select(x => x.ItemSpec), StringComparer.OrdinalIgnoreCase); var existingReferenceCopyLocalFiles = ReferenceCopyLocalFiles .Where(item => updatedReferenceCopyLocalPaths.Contains(item.ItemSpec)); var newReferenceCopyLocalFiles = updatedReferenceCopyLocalPaths .Where(item => !referenceCopyLocalPaths.Contains(item)) .Select(item => new TaskItem(item)); UpdatedReferenceCopyLocalFiles = existingReferenceCopyLocalFiles.Concat(newReferenceCopyLocalFiles).ToArray(); }
public override bool Execute() { var referenceCopyLocalPaths = ReferenceCopyLocalFiles.Select(x => x.ItemSpec).ToList(); var defineConstants = DefineConstants.GetConstants(); var buildLogger = new BuildLogger { BuildEngine = BuildEngine, }; processor = new Processor { Logger = buildLogger, AssemblyFilePath = AssemblyFile, IntermediateDirectory = IntermediateDirectory, KeyFilePath = KeyOriginatorFile ?? AssemblyOriginatorKeyFile, SignAssembly = SignAssembly, ProjectDirectory = ProjectDirectory, DocumentationFilePath = DocumentationFile, References = References, SolutionDirectory = SolutionDirectoryFinder.Find(SolutionDirectory, NCrunchOriginalSolutionDirectory, ProjectDirectory), ReferenceCopyLocalPaths = referenceCopyLocalPaths, DefineConstants = defineConstants, NuGetPackageRoot = NuGetPackageRoot, MSBuildDirectory = MSBuildThisFileDirectory, WeaverFilesFromProps = GetWeaverFilesFromProps(), DebugSymbols = GetDebugSymbolsType(), GenerateXsd = GenerateXsd }; var success = processor.Execute(); if (success) { var weavers = processor.Weavers.Select(x => x.AssemblyName); ExecutedWeavers = string.Join(";", weavers) + ";"; try { File.WriteAllLines(IntermediateCopyLocalFilesCache, processor.ReferenceCopyLocalPaths); } catch (Exception ex) { buildLogger.LogInfo("ProjectDirectory: " + ProjectDirectory); buildLogger.LogInfo("IntermediateDirectory: " + IntermediateDirectory); buildLogger.LogInfo("CurrentDirectory: " + Directory.GetCurrentDirectory()); buildLogger.LogInfo("AssemblyFile: " + AssemblyFile); buildLogger.LogInfo("IntermediateCopyLocalFilesCache: " + IntermediateCopyLocalFilesCache); buildLogger.LogError("Error writing IntermediateCopyLocalFilesCache: " + ex.Message); return(false); } } else { if (File.Exists(IntermediateCopyLocalFilesCache)) { File.Delete(IntermediateCopyLocalFilesCache); } } return(success); }