コード例 #1
0
ファイル: BuildWSP.cs プロジェクト: keutmann/wspbuilder
        private void RunWSPBuilder()
        {
//            List<object> lo = (List<object>)o;
//          Project proj = (Project)lo[0];
//        string deployfolder = (string)lo[1];

            try
            {
                Log.LogMessageFromText("Building Solution Package", MessageImportance.High);
                // display parameters
                Log.LogMessageFromText("OutputFolder = " + OutputFolder, MessageImportance.High);

                //    string projectfile = BuildEngine.ProjectFileOfTaskNode;
                //  string projectfolder = projectfile.Substring(0, projectfile.LastIndexOf("\\");

                Log.LogMessageFromText("ProjectFolder = " + ProjectFolder, MessageImportance.High);


                Log.LogMessageFromText("AssemblyName = " + AssemblyName, MessageImportance.High);


                Log.LogMessageFromText("DeployFolder = " + DeployFolder, MessageImportance.High);


                // prepare deploy folder

                Directory.CreateDirectory(DeployFolder);


                // put the project output in the GAC

                File.Copy(ProjectFolder + OutputFolder + AssemblyName + ".dll", ProjectFolder + "GAC\\" + AssemblyName + ".dll", true);

                // copy files to help with deployment
                CopyFromInstallToDeploy("wspdeploy.exe");
                CopyFromInstallToDeploy("wspdeploy.lib.dll");
                CopyFromInstallToDeploy("cablib.dll");
                CopyFromInstallToDeploy("setup.exe");

                // Copy deployment config files

                File.Copy(ProjectFolder + "deploy\\setup.exe.config", DeployFolder + "setup.exe.config", true);
                File.Copy(ProjectFolder + "deploy\\eula.rtf", DeployFolder + "eula.rtf", true);


                // run wspbuilder

                string wspbuilderexe = WSPBuilderInstallPath + "WSPBuilder.exe";
                string args          = "-SolutionPath \"" + ProjectFolder.Substring(0, ProjectFolder.Length - 1) + "\" -Outputpath \"" + DeployFolder.Substring(0, DeployFolder.Length - 1) + "\" ";


                string commandline = "\"" + wspbuilderexe + "\" " + args;
                Log.LogCommandLine(MessageImportance.High, commandline);


                System.Diagnostics.ProcessStartInfo psi = new ProcessStartInfo(wspbuilderexe);
                psi.Arguments              = args;
                psi.UseShellExecute        = false;
                psi.CreateNoWindow         = true;
                psi.WorkingDirectory       = ProjectFolder;
                psi.RedirectStandardOutput = true;
                System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi);
                //Log.LogMessagesFromStream(p.StandardOutput, MessageImportance.High);

                p.WaitForExit();
                string output = p.StandardOutput.ReadToEnd();

                Log.LogMessageFromText(output, MessageImportance.High);

                if (!output.Contains("Done!"))
                {
                    throw new Exception("WSP Build did not complete.");
                }
            }
            catch (Exception ex)
            {
                Log.LogErrorFromException(ex, true);
            }
        }