1

问题:

我需要从我的代码中使用 FxCopCmd.exe (FxCop 10.0),我的问题是,我相信 FxCopCmd 得到我的参数(见下文 p.StartInfo.Arguments)有一些编码问题。(我没有编码或本地化经验。)

例子:

我建立的论点:

/o:"C:\Users\Ákos\Documents\Tanulás\diplomamunka\softwareprojectqualityanalysisr\implementáció\Analizer\Analizer\bin\Debug\temp\probaAnalisisReport.xml" /fo /f:"C:\Users\Ákos\Documents\ Visual Studio 2010\Projects\TeaBoiler\TeaBoiler\bin\Release\TeaBoiler.exe"

FxCopCmd 错误消息:

无法打开输出文件:找不到路径“C:\Users\µkos\Documents\Tanul s\diplomamunka\softwareprojectqualityanalysisr\implement ci˘\Analizer\Analizer\bin\Debug\temp\probaAnalisisReport.xml”的一部分。 .

笔记:

如果我使用我使用编辑/粘贴构建的参数从 cmd.exe 使用 FxCopCmd.exe,它可以正常工作。

开发环境:

Windows 7 Prof EN,默认输入语言:匈牙利语、.NET 4.0、C# 4.0、VS2010 Ultimate

代码:

using (Process p = new Process())
        {
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.RedirectStandardInput = true;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError = true;
            p.StartInfo.CreateNoWindow = true;
            p.StartInfo.FileName = this.FxCop10Path.LocalPath;

            string fullpath = Assembly.GetExecutingAssembly().Location;
            string dir = Path.GetDirectoryName(fullpath);

            p.StartInfo.Arguments = "/o:\"" + dir + "\\temp\\" +
                (this.ProjectName.Equals("") == true || this.ProjectName == null
                ? "noNameProjectAnalysisReport.xml" : this.ProjectName + "AnalisisReport.xml\"")
                + " /fo";
            foreach (var item in this.Files)
            {
                p.StartInfo.Arguments += " /f:\"" + item.FilePath + "\"";
            }
            try
            {
                p.Start();
            }
            catch (Win32Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

谢谢你的帮助!

4

1 回答 1

1

设置参数后立即尝试中断。看看它正在生成什么,然后复制并粘贴到一个 cmd 窗口中,看看发生了什么。另外,“临时”文件夹是否存在?如果不是,您确定 FxCop 创建了该文件夹吗?

于 2011-02-22T20:58:24.410 回答