Esempio n. 1
0
        private void Weave(IWeaver weaver, Dictionary <string, AssemblySetting> targets, string configurationFullPath, string currentDirectory)
        {
            var configurationDirectory = Path.GetDirectoryName(configurationFullPath);

            foreach (var target in targets)
            {
                Directory.SetCurrentDirectory(configurationDirectory);
                if (string.IsNullOrWhiteSpace(target.Key))
                {
                    throw new ApplicationException($"Input assembly must be specified, found empty in Targets section in {configurationFullPath}");
                }

                var inputAssembly = target.Key;
                var inputPath     = PathUtility.ProcessPath(inputAssembly);
                var settings      = target.Value;
                if (settings == null || string.IsNullOrWhiteSpace(settings.Output))
                {
                    throw new ApplicationException($"Output must be specified, found empty in Targets section in {configurationFullPath}");
                }

                var outputPath  = settings.Output;
                var snkFilePath = string.IsNullOrWhiteSpace(settings.StrongNameKeyFile) ? null : PathUtility.ProcessPath(settings.StrongNameKeyFile);
                Console.Out.WriteLine($"Starting to load {inputAssembly}, weaving into {outputPath}");
                outputPath = PathUtility.ProcessPath(outputPath);
                var statistics = weaver.Weave(inputPath, settings.IncludeSymbol, outputPath, snkFilePath);
                Directory.SetCurrentDirectory(currentDirectory);
                var assemblyName = ProcessAssemblyName(statistics.AssemblyName);
                var fileName     = $"{assemblyName}_{DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff")}.log";
                using (var output = new StreamWriter(fileName, true))
                {
                    statistics.Log(output);
                    output.Close();
                }

                processed.Add(inputPath);
                Console.Out.WriteLine($"Weaving of assembly {statistics.AssemblyName} in {inputAssembly} finished, output as {outputPath}");
            }

            Console.Out.WriteLine("Weaving finished");
        }