Ejemplo n.º 1
0
 public static void Dotfuscator(this ICakeContext context, string assembly, DotfuscatorSettings settings)
 {
     if (assembly == null)
     {
         throw new ArgumentNullException("assembly");
     }
     Dotfuscator(context, new string[] { assembly }, settings);
 }
Ejemplo n.º 2
0
        public static void Dotfuscator(this ICakeContext context, IEnumerable <string> assemblies, DotfuscatorSettings settings)
        {
            if (assemblies == null)
            {
                throw new ArgumentNullException("assemblies");
            }
            if (assemblies.Count() == 0)
            {
                throw new ArgumentNullException("assemblies");
            }

            if (settings.WorkingDirectory == null || !context.FileSystem.Exist(settings.WorkingDirectory))
            {
                throw new CakeException("Dotfuscator : WorkingDirectory is required but not specified.");
            }

            if (settings.OutputDir == null || !context.FileSystem.Exist(settings.OutputDir))
            {
                throw new CakeException("Dotfuscator : OutputDir is required but not specified.");
            }


            if (settings.OutputDir.IsRelative)
            {
                settings.OutputDir = settings.OutputDir.MakeAbsolute(context.Environment);
            }

            var runner = new DotfuscatorRunner(context.FileSystem, context.Environment, context.ProcessRunner, context.Tools, context.Log);

            foreach (var assembly in assemblies)
            {
                var path = settings.WorkingDirectory.CombineWithFilePath(new FilePath(assembly));
                if (!context.FileSystem.Exist(path))
                {
                    const string format  = "{0}: The assembly '{1}' do not exist.";
                    var          message = string.Format(CultureInfo.InvariantCulture, format, "dotfuscator", path);
                    throw new CakeException(message);
                }
            }

            runner.Run(assemblies, settings);
        }