0

I want to build my solution file from other c# code using msbuid I have tried

var msbuild_path = @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe";
var solution_path = @"D:\Sumit\WorkingCopy\Final\Final.sln";            
Process.Start(msbuild_path + " " + solution_path);

but this one throws an error Please help me out!!

1
  • The system cannot find the file specified Commented Jul 7, 2015 at 8:03

1 Answer 1

1

According to https://msdn.microsoft.com/en-us/library/h6ak8zt5(v=vs.110).aspx , the Process.Start method takes two arguments:

public static Process Start(string fileName, string arguments)

So you should change your code to

Process.Start(msbuild_path, solution_path);

What you were doing before was actually trying to run a file named "C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe(space)D:\Sumit\WorkingCopy\Final\Final.sln", but no such file exists with that name. The msbuild.exe may exist, but "msbuild.exe D:\Sumit...\Final.sln" is not the filename you meant to pass as the command filename. Also, the argument string was empty, so the system assumed you did not want to pass any arguments to "msbuild.exe D:\Sumit...\Final.sln". But the error message was because the two filenames were mashed into one filename.

Windows allows filenames to contain embedded spaces, which frequently causes problems in dealing with command-line arguments.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.