Exemple #1
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);
        }
        /// <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)
        {
            // avoid copying the assembly references (and regasm) to a
            // temporary directory if not necessary
            if (References.FileNames.Count == 0)
            {
                // 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;
            ct.CallStack = this.CallStack;

            // 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;
            ct.CopyFileSet.CallStack = ct.CallStack;

            // 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 References.FileNames)
            {
                ct.CopyFileSet.Includes.Add(file);
            }

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

            if (AssemblyFile != null)
            {
                ct.CopyFileSet.Includes.Add(AssemblyFile.FullName);
            }

            // 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));

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