![](/img/trans.png)
[英]Invalid use of DeploymentItem - the specified output directory is not relative
[英]ConfuserEx CLI no output directory specified
我的 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();
strConfuserExFilePath = D:\\Examples .Net\\Diagramm\\TEST\\Haupt-Projekt\\packages\\ConfuserEx.Final.1.0.0\\tools\\Confuser.CLI.exe
strConfuserExProjectFilePath = D:\\Examples .Net\\Diagramm\\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>
當我運行該代碼時,命令框消失得如此之快,以至於我無法讀取錯誤。 所以我想我會通過命令行啟動 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");
}
}
}
所以我找到了我的問題,這很簡單。 我忘記了 .crproj 文件周圍的“。
這里是正確的方法:第 1 個通過過程:
p.StartInfo.Arguments = "-nopause \\"" + strConfuserExProjectFilePath + "\\"";
2 通過 PowerShell:
PowerShellInstance.AddScript("& \\"" + strConfuserExFilePath + "\\" -nopause \\"" + strConfuserExProjectFilePath + "\\"");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.