private void CopyFileSet(FileSet fileSet, String toDir)
        {
            CopyTask task = new CopyTask();

            task.Project = this.Project;
            task.InitializeTaskConfiguration();
            task.ToDirectory = new DirectoryInfo(toDir);
            task.CopyFileSet = fileSet;
            task.Execute();
        }
        private void CopyFile(FileInfo fileInfo, String toDir)
        {
            CopyTask task = new CopyTask();

            task.Project = this.Project;
            task.InitializeTaskConfiguration();
            task.ToDirectory = new DirectoryInfo(toDir);
            task.SourceFile  = fileInfo;
            task.Execute();
        }
Example #3
0
        /// <summary>
        /// Copies the specified file if the destination file does not exist, or
        /// the source file has been modified since it was previously copied.
        /// </summary>
        /// <param name="srcFile">The file to copy.</param>
        /// <param name="destFile">The destination file.</param>
        /// <param name="parent">The <see cref="Task" /> in which context the operation will be performed.</param>
        protected void CopyFile(FileInfo srcFile, FileInfo destFile, Task parent)
        {
            // create instance of Copy task
            CopyTask ct = new CopyTask();

            // parent is solution task
            ct.Parent = parent;

            // inherit project from parent task
            ct.Project   = parent.Project;
            ct.CallStack = parent.CallStack;

            // inherit namespace manager from parent task
            ct.NamespaceManager = parent.NamespaceManager;

            // inherit verbose setting from parent task
            ct.Verbose = parent.Verbose;

            // only output warning messages or higher, unless
            // we're running in verbose mode
            if (!ct.Verbose)
            {
                ct.Threshold = Level.Warning;
            }

            // make sure framework specific information is set
            ct.InitializeTaskConfiguration();

            // set parent of child elements
            ct.CopyFileSet.Parent = ct;

            // inherit project for child elements from containing task
            ct.CopyFileSet.Project   = ct.Project;
            ct.CopyFileSet.CallStack = ct.CallStack;

            // inherit namespace manager from containing task
            ct.CopyFileSet.NamespaceManager = ct.NamespaceManager;

            // set file to copy
            ct.SourceFile = srcFile;

            // set file
            ct.ToFile = destFile;

            // increment indentation level
            ct.Project.Indent();

            try {
                // execute task
                ct.Execute();
            } finally {
                // restore indentation level
                ct.Project.Unindent();
            }
        }
Example #4
0
        /// <summary>
        /// Updates the <see cref="ProcessStartInfo" /> of the specified
        /// <see cref="Process"/>.
        /// </summary>
        /// <param name="process">The <see cref="Process" /> of which the <see cref="ProcessStartInfo" /> should be updated.</param>
        protected override void PrepareProcess(Process process)
        {
            if (!SupportsAssemblyReferences)
            {
                // create instance of Copy task
                CopyTask ct = new CopyTask();

                // inherit project from current task
                ct.Project = Project;

                // inherit namespace manager from current task
                ct.NamespaceManager = NamespaceManager;

                // parent is current task
                ct.Parent = this;

                // inherit verbose setting from license task
                ct.Verbose = Verbose;

                // only output warning messages or higher, unless we're running
                // in verbose mode
                if (!ct.Verbose)
                {
                    ct.Threshold = Level.Warning;
                }

                // make sure framework specific information is set
                ct.InitializeTaskConfiguration();

                // set parent of child elements
                ct.CopyFileSet.Parent = ct;

                // inherit project from solution task for child elements
                ct.CopyFileSet.Project = ct.Project;

                // inherit namespace manager from solution task
                ct.CopyFileSet.NamespaceManager = ct.NamespaceManager;

                // set base directory of fileset
                ct.CopyFileSet.BaseDirectory = Assemblies.BaseDirectory;

                // copy all files to base directory itself
                ct.Flatten = true;

                // copy referenced assemblies
                foreach (string file in Assemblies.FileNames)
                {
                    ct.CopyFileSet.Includes.Add(file);
                }

                // copy command line tool to working directory
                ct.CopyFileSet.Includes.Add(base.ProgramFileName);

                // set destination directory
                ct.ToDirectory = BaseDirectory;

                // increment indentation level
                ct.Project.Indent();
                try {
                    // execute task
                    ct.Execute();
                } finally {
                    // restore indentation level
                    ct.Project.Unindent();
                }

                // change program to execute the tool in working directory as
                // that will allow this tool to resolve assembly references
                // using assemblies stored in the same directory
                _programFileName = Path.Combine(BaseDirectory.FullName,
                                                Path.GetFileName(base.ProgramFileName));

                // determine target directory
                string targetDir = Path.GetDirectoryName(Path.Combine(
                                                             BaseDirectory.FullName, Target));
                // ensure target directory exists
                if (!String.IsNullOrEmpty(targetDir) && !Directory.Exists(targetDir))
                {
                    Directory.CreateDirectory(targetDir);
                }
            }
            else
            {
                foreach (string assembly in Assemblies.FileNames)
                {
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/i:\"{0}\"", assembly)));
                }
            }

            // further delegate preparation to base class
            base.PrepareProcess(process);
        }
Example #5
0
        /// <summary>
        /// Updates the <see cref="ProcessStartInfo" /> of the specified
        /// <see cref="Process"/>.
        /// </summary>
        /// <param name="process">The <see cref="Process" /> of which the <see cref="ProcessStartInfo" /> should be updated.</param>
        protected override void PrepareProcess(Process process)
        {
            if (!SupportsAssemblyReferences)
            {
                // use a newly created temporary directory as working directory
                BaseDirectory = FileUtils.GetTempDirectory().FullName;

                // avoid copying the assembly references (and resgen) to a
                // temporary directory if not necessary
                if (Assemblies.FileNames.Count == 0 || !RequiresAssemblyReferences)
                {
                    // further delegate preparation to base class
                    base.PrepareProcess(process);

                    // no further processing required
                    return;
                }

                // create instance of Copy task
                CopyTask ct = new CopyTask();

                // inherit project from current task
                ct.Project = Project;

                // inherit namespace manager from current task
                ct.NamespaceManager = NamespaceManager;

                // parent is current task
                ct.Parent = this;

                // inherit verbose setting from resgen task
                ct.Verbose = Verbose;

                // only output warning messages or higher, unless we're running
                // in verbose mode
                if (!ct.Verbose)
                {
                    ct.Threshold = Level.Warning;
                }

                // make sure framework specific information is set
                ct.InitializeTaskConfiguration();

                // set parent of child elements
                ct.CopyFileSet.Parent = ct;

                // inherit project from solution task for child elements
                ct.CopyFileSet.Project = ct.Project;

                // inherit namespace manager from solution task
                ct.CopyFileSet.NamespaceManager = ct.NamespaceManager;

                // set base directory of fileset
                ct.CopyFileSet.BaseDirectory = Assemblies.BaseDirectory;

                // copy all files to base directory itself
                ct.Flatten = true;

                // copy referenced assemblies
                foreach (string file in Assemblies.FileNames)
                {
                    ct.CopyFileSet.Includes.Add(file);
                }

                // copy command line tool to working directory
                ct.CopyFileSet.Includes.Add(base.ProgramFileName);

                // set destination directory
                ct.ToDirectory = new DirectoryInfo(BaseDirectory);

                // increment indentation level
                ct.Project.Indent();
                try {
                    // execute task
                    ct.Execute();
                } finally {
                    // restore indentation level
                    ct.Project.Unindent();
                }

                // change program to execute the tool in working directory as
                // that will allow this tool to resolve assembly references
                // using assemblies stored in the same directory
                _programFileName = Path.Combine(BaseDirectory,
                                                Path.GetFileName(base.ProgramFileName));
            }
            else
            {
                foreach (string assembly in Assemblies.FileNames)
                {
                    AppendArgument(string.Format(CultureInfo.InvariantCulture,
                                                 " /r:\"{0}\"", assembly));
                }
            }

            // further delegate preparation to base class
            base.PrepareProcess(process);
        }