C# ConfuserEx CLI未指定输出目录
我对ConfuserEx CLI工具有问题。我想从C#程序启动CLI,如下所示:C# ConfuserEx CLI未指定输出目录,c#,.net,powershell,confuserex,C#,.net,Powershell,Confuserex,我对ConfuserEx CLI工具有问题。我想从C#程序启动CLI,如下所示: System.Diagnostics.Process p = new System.Diagnostics.Process(); //p.StartInfo.RedirectStandardOutput = true; //p.StartInfo.UseShellExecute = false; //p.StartInfo.CreateNoWindow = true; p.StartInfo.FileName
System.Diagnostics.Process p = new System.Diagnostics.Process();
//p.StartInfo.RedirectStandardOutput = true;
//p.StartInfo.UseShellExecute = false;
//p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = strConfuserExFilePath;
p.StartInfo.Arguments = strConfuserExProjectFilePath;
p.Start();
strConfuserExFilePath=D:\Examples.Net\diagram\TEST\Haupt Projekt\packages\ConfuserEx.Final.1.0.0\tools\Confuser.CLI.exe
strConfuserExProjectFilePath=D:\Examples.Net\diagram\TEST\Haupt Projekt\TEST\bin\x86\Debug\ConfuserEx.crproj
我的.crproj文件如下所示:
<project outputDir="D:\Examples .Net\Diagramm\TEST\Haupt-Projekt\TEST\bin\x86\Debug\Confused" baseDir="D:\Examples .Net\Diagramm\TEST\Haupt-Projekt\TEST\bin\x86\Debug" debug="false" xmlns="http://confuser.codeplex.com">
<rule pattern="true" preset="normal" inherit="false">
<protection id="anti ildasm" action="add" />
<protection id="anti tamper" action="add" />
<protection id="constants" action="add" />
<protection id="ctrl flow" action="add" />
<protection id="anti dump" action="add" />
<protection id="anti debug" action="add" />
<protection id="invalid metadata" action="remove" />
<protection id="ref proxy" action="remove" />
<protection id="resources" action="remove" />
<protection id="rename" />
</rule>
<module path="h01_SonstVerwaltung.dll" />
</project>
我得到了错误
Confuser.Ex.CLI:未指定输出目录
奇怪的是,如果我运行相同的代码,但在PowerShell中它可以工作:
function ObfuscateProjectAssembly
{
[CmdletBinding()]
param()
Utility_AssertValid_FilePath $ConfuserExFilePath
Utility_AssertValid_FilePath $ConfuserExProjectFilePath
if( Test-Path -Path $ObfuscatedAssemblyFilePath ) {
Remove-Item -Path $ObfuscatedAssemblyFilePath
}
& $ConfuserExFilePath -nopause $ConfuserExProjectFilePath
Utility_AssertValid_FilePath $ObfuscatedAssemblyFilePath
}
为什么它可以与PowerShell一起工作,而不能与C#一起工作。我已经尝试在我的C代码中添加-n |-noPause参数
编辑
我已尝试从我的C#代码执行PowerShell,但仍然显示相同的错误消息
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddScript("& (\"" + strConfuserExFilePath + "\") -nopause " + strConfuserExFilePath);
Collection<PSObject> PSOutput = PowerShellInstance.Invoke();
if (PowerShellInstance.Streams.Error.Count > 0)
{
foreach(ErrorRecord er in PowerShellInstance.Streams.Error)
{
}
}
foreach (PSObject outputItem in PSOutput)
{
if (outputItem != null)
{
//System.Diagnostics.Debug.WriteLine(outputItem.BaseObject.GetType().FullName);
System.Diagnostics.Debug.Write(outputItem.BaseObject.ToString() + "\n");
}
}
}
使用(PowerShell PowerShellInstance=PowerShell.Create())
{
AddScript(&(\“”+strConfuserExFilePath+“\”)-nopuse“+strConfuserExFilePath);
集合PSOutput=PowerShellInstance.Invoke();
如果(PowerShellInstance.Streams.Error.Count>0)
{
foreach(PowerShellInstance.Streams.Error中的ErrorRecord er)
{
}
}
foreach(PSOutput中的PSObject输出项)
{
if(outputItem!=null)
{
//System.Diagnostics.Debug.WriteLine(outputiItem.BaseObject.GetType().FullName);
System.Diagnostics.Debug.Write(outputItem.BaseObject.ToString()+“\n”);
}
}
}
所以我发现了我的问题,其实很简单。我忘记了.crproj文件中的“循环”
以下是正确的方法:
1号通过过程:
p、 StartInfo.Arguments=“-nopuse\”+strConfuserExProjectFilePath+“\”
第2条通过PowerShell:
PowerShellInstance.AddScript(&\'+strConfuserExFilePath+“\'-nopuse\'+strConfuserExProjectFilePath+”)
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddScript("& (\"" + strConfuserExFilePath + "\") -nopause " + strConfuserExFilePath);
Collection<PSObject> PSOutput = PowerShellInstance.Invoke();
if (PowerShellInstance.Streams.Error.Count > 0)
{
foreach(ErrorRecord er in PowerShellInstance.Streams.Error)
{
}
}
foreach (PSObject outputItem in PSOutput)
{
if (outputItem != null)
{
//System.Diagnostics.Debug.WriteLine(outputItem.BaseObject.GetType().FullName);
System.Diagnostics.Debug.Write(outputItem.BaseObject.ToString() + "\n");
}
}
}