我对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 = strConfuserExFilePath;
p.StartInfo.Arguments = strConfuserExProjectFilePath;
p.Start();.Net\Diagramm\TEST\Haupt-Projekt\packages\ConfuserEx.Final.1.0.0\tools\Confuser.CLI.exe =D:\ strConfuserExFilePath示例 .Net\Diagramm\TEST\Haupt-Projekt\TEST\bin\x86\Debug\ConfuserEx.crproj =D:\ strConfuserExProjectFilePath示例
我的.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个非滞后性参数。
编辑我尝试过从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");
}
}
}发布于 2017-10-20 08:00:03
所以我发现了我的问题,很简单。我忘了“在.crproj文件周围”。
在这里,正确的方式:数字1通过过程:
p.StartInfo.Arguments = "-nopause \“+ strConfuserExProjectFilePath +”\“;
2号通过PowerShell:
PowerShellInstance.AddScript("& \\“+ strConfuserExFilePath + "\”-nopause \“+ strConfuserExProjectFilePath +”);
https://stackoverflow.com/questions/46824316
复制相似问题