Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Hi i have a problem using svn command in code behind :

C#
public void SvnDiff(int rev1, int rev2)
        {
            try
            {
                var p = new Process();
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.FileName = "svn";
                string arg = string.Format("diff -r {0}:{1} --summarize --xml > SvnDiff.xml", rev1, rev2);
                Console.WriteLine(arg);
                p.StartInfo.Arguments = arg;
                p.Start();
                p.WaitForExit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }


When i use this command in cmd, it's working fine.
svn diff -r 2882:2888 --summarize --xml > SvnDiff.xml

but when i run my method i got this message:
svn: E020024: Error resolving case of '>'

What can i do right now to solve this ?
Thanks for any advice
Posted
Comments
Sergey Alexandrovich Kryukov 28-Mar-13 18:53pm    
Pretty straightforward exception message, isn't it? You could easily find a solution just by looking at System.Diagnostic.Process documentation a bit more thoroughly...
—SA

1 solution

This is because of that pipe symbol, which is not valid for programmatic use of the shell's process start, which requires just the application or data file:
http://msdn.microsoft.com/en-us/library/53ezey2s.aspx[^].

Note that the pile is also not a part of command line arguments, that makes the problem.

Instead, remove the pipe and redirect the stream System.Diagnostics.Process.StandardInput (and, just in case, System.Diagnostics.Process.StandardError). You will find the code sample with redirection here:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[^].

By the way, it will free you from creation of temporary file you tried to use for piping, which is always an extra hassle. You redirect the stream and do with redirected data whatever you want, parse it immediately, etc.

This will solve your problem. However, if our really need a "real" programming interface to Subversion, please see this CodeProject article: Accessing the Subversion repository from .NET using DotSVN[^].

It uses .NET library DotSVN:
http://en.wikipedia.org/wiki/DotSVN[^],
http://www.dotsvn.net/[^].

—SA
 
Share this answer
 
v8

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900