2017-10-19 147 views
0

我對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"); 
     } 
    } 
} 

回答

0

所以我發現我的問題,它很簡單。 「:通過理線 數1:圍繞.crproj文件

這裏的正確途徑。

p.StartInfo.Arguments = 」我忘了-nopause \「」 + strConfuserExProjectFilePath + 「\」」 ;

經由PowerShell的數量2:

PowerShellInstance.AddScript(」 & \ 「」 + strConfuserExFilePath + 「\」 -nopause \ 「」 + strConf userExProjectFilePath +「\」「);

相關問題