/// <summary> /// Executes the task. /// </summary> protected override void ExecuteTask() { // Transform fileset into dir list if (this.SearchDirectories.Any(f => f.BaseDirectory == null)) { throw new BuildException("Missing 'basedir' attribute on <search-in/> sub-task"); } // Check included assemblies if (this.IncludedAssemblies.Any(f => f.File == null)) { throw new BuildException("Missing 'file' attribute on <include-assembly/> sub-task"); } // Check excluded assemblies if (this.ExcludedAssemblies.Any(f => f.File == null)) { throw new BuildException("Missing 'file' attribute on <exclude-assembly/> sub-task"); } // Check additionnal libraries if (this.IncludedLibraries.Any(f => f.File == null)) { throw new BuildException("Missing 'file' attribute on <include-library/> sub-task"); } // Set the output directory for the build String directory = this.ToDirectory.ToString(); Directory.CreateDirectory(directory); // Collect all the assemblies List <string> assemblies = this.GetAssemblies(); // Generate the embedded executable NativeCodeGenerator codeGenerator = new NativeCodeGenerator(); codeGenerator.Logger = new ExecutionLogger(this); codeGenerator.Assemblies = assemblies; codeGenerator.MachineConfiguration = this.MachineConfiguration; codeGenerator.TargetOSVersion = this.TargetOSVersion; codeGenerator.TargetArchitecture = this.TargetArchitecture; String executableFile = codeGenerator.Generate(directory); String libraryFile = Path.Combine(directory, "libmonobjc.dylib"); // Relocate the libraries NativeCodeRelocator relocator = new NativeCodeRelocator(); relocator.Logger = new ExecutionLogger(this); relocator.DependencyPattern = new List <string> { "Mono.framework" }; relocator.Relocate(executableFile, directory); relocator.Relocate(libraryFile, directory); }
/// <summary> /// Executes the task. /// </summary> public override bool Execute() { if (this.SearchDirectories == null) { this.SearchDirectories = new ITaskItem[0]; } if (this.IncludedAssemblies == null) { this.IncludedAssemblies = new ITaskItem[0]; } if (this.ExcludedAssemblies == null) { this.ExcludedAssemblies = new ITaskItem[0]; } if (this.IncludedLibraries == null) { this.IncludedLibraries = new ITaskItem[0]; } if (this.MachineConfiguration == null) { this.MachineConfiguration = new TaskItem("/Library/Frameworks/Mono.framework/Home/etc/mono/4.0/machine.config"); } // HACK: We need to put a search directory in order to properly lookup assemblies with no explicit version List <ITaskItem> directories = this.SearchDirectories.ToList(); directories.Insert(0, new TaskItem(FileProvider.GetPath(this.targetOSVersion))); this.SearchDirectories = directories.ToArray(); // Set the working directory for the build String workingDir; if (this.WorkingDirectory == null) { workingDir = Path.Combine(Path.GetTempPath(), Path.GetTempFileName()); File.Delete(workingDir); this.WorkingDirectory = new TaskItem(workingDir); } workingDir = this.WorkingDirectory.ItemSpec; Directory.CreateDirectory(workingDir); // Set the output directory for the build String outputDir = this.ToDirectory.ItemSpec; Directory.CreateDirectory(outputDir); // Collect all the assemblies List <string> assemblies = this.GetAssemblies(); // Generate the embedded executable NativeCodeGenerator codeGenerator = new NativeCodeGenerator(); codeGenerator.Logger = new ExecutionLogger(this); codeGenerator.Assemblies = assemblies; codeGenerator.MachineConfiguration = this.MachineConfiguration.ItemSpec; codeGenerator.TargetOSVersion = this.targetOSVersion; codeGenerator.TargetArchitecture = this.targetArchitecture; codeGenerator.Compress = this.Compress; codeGenerator.UseSGEN = this.UseSGEN; codeGenerator.UseReceigen = this.UseReceigen; codeGenerator.NativeCompiler = this.NativeCompiler; codeGenerator.NativeCFLAGS = this.NativeCFLAGS; codeGenerator.NativeLDFLAGS = this.NativeLDFLAGS; String executableFile = codeGenerator.Generate(workingDir); // TODO: Use sgen if specified String libraryFile = Path.Combine(workingDir, "libmonobjc.dylib"); // Relocate the libraries NativeCodeRelocator relocator = new NativeCodeRelocator(); relocator.Logger = new ExecutionLogger(this); relocator.DependencyPattern = new List <string> { "Mono.framework" }; relocator.Relocate(executableFile, outputDir); relocator.Relocate(libraryFile, outputDir); // Copy the result files File.Copy(executableFile, Path.Combine(outputDir, Path.GetFileName(executableFile)), true); File.Copy(libraryFile, Path.Combine(outputDir, Path.GetFileName(libraryFile)), true); return(true); }