FxCopCmd argument encoding problem

605 views Asked by At

Problem:

I need to use FxCopCmd.exe (FxCop 10.0) from my code, and my problem is, that FxCopCmd gets my arguments (see below p.StartInfo.Arguments) with some encoding problem, I believe. (I have no experience in encoding, or localization.)

Example:

Arguments I build:

/o:"C:\Users\Ákos\Documents\Tanulás\diplomamunka\softwareprojectqualityanalyser\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 error message:

Could not open output file: Could not find a part of the path 'C:\Users\µkos\Documents\Tanul s\diplomamunka\softwareprojectqualityanalyser\implement ci˘\Analizer\Analizer\bin\Debug\temp\probaAnalisisReport.xml'..

Note:

If I use FxCopCmd.exe from cmd.exe using the arguments built by me using Edit/Paste, it works fine.

Development environment:

Windows 7 Prof EN, Default input language: Hungarian, .NET 4.0, C# 4.0, VS2010 Ultimate

Code:

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);
            }
        }

Thanks for any help!

1

There are 1 answers

0
Dustin Davis On BEST ANSWER

Try breaking right after you set the arguments. Take a look at what it is generating and then copy and paste into a cmd window and see whats going on. Also, does the 'temp' folder exist? If not, are you sure FxCop creates the folder?