我对ConfuserEx CLI工具有问题。我想从C#PROGRAMM这样启动CLI:ConfuserEx CLI没有指定输出目录
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:\实例.NET \ Diagramm \ TEST \奥普特-Projekt的\包\ ConfuserEx.Final.1.0.0 \工具\ Confuser.CLI.exe
strConfuserExProjectFilePath = d:\实例.NET \ Diagramm \ TEST \奥普特-Projekt的\ TEST \ BIN \ 86 \调试\ 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>
当我运行该代码的CommandBox消失得如此之快,我无法读取错误。所以我想我会通过CommandLine启动CLI来看看会发生什么。当我做到以下几点:
D:\Examples .Net\Diagramm\TEST\Haupt.Projekt\packages\ConfuserEx.Final.1.0.0\tools>Confuser.CLI.exe D:\Examples .Net\Diagramm\TEST\Haupt-Projekt\TEST\bin\x86\Debug\ConfuserEx.crproj
我得到的错误
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");
}
}
}