如果打包后运行报错,请检测自己的ps源代码,里面是否有语法,或者字符错误。
function Convert-PS1ToExe
{
param(
[Parameter(Mandatory=$true)]
[ValidateScript({$true})]
[ValidateNotNullOrEmpty()]
[IO.FileInfo]$ScriptFile
)
if( -not $ScriptFile.Exists)
{
Write-Warning "$ScriptFile not exits."
return
}
[string]$csharpCode = @'
using System;
using System.IO;
using System.Reflection;
using System.Diagnostics;
namespace LoadXmlTestConsole
{
public class ConsoleWriter
{
private static void Proc_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
Process pro = sender as Process;
Console.Wri