Launching command line compiler

  • Thread starter Thread starter Michael Moreno
  • Start date Start date
M

Michael Moreno

Hello,

I am trying to automatically compile all my projects but I am stuck on
something silly: launching csc with the right arguments.

Here is my code

private void CompileProject(string RSPFile)
{
System.Text.StringBuilder sbArgs = new
System.Text.StringBuilder(100);
System.Diagnostics.Process procManager = new
System.Diagnostics.Process();

procManager.StartInfo.FileName = @"csc";

sbArgs.Append(@"@" + RSPFile);
procManager.StartInfo.Arguments = sbArgs.ToString();

procManager.Start();
}

Which I call using
CompileProject(@"C:\Dev\C#\Libraries\SD_StdClasses\SD_StdClasses.rsp");

If I compile myself using hard command line (cmd) it works fine.

Can you help please?

Thanks
 
sbArgs.Append(@"@" + RSPFile);
" " ( space ) is parameter separator.

Take a look at System.CodeDom.Compiler

Also, please, tell us what is the error returned?
Maybe you have to specify full path to csc?
 
Thanks the file name had no space.
I have tried adding double quote and all sorts of things but it still
fails.

I have given up and I am currently writing a .bat file that does the
job but it is very painful.

For some reasons most of the time the .rsp file does not compile but
copying and pasting its content into a cmd windows works. It is mad!

I have to type in the .bat file things such as

csc /r:"C:\Dev\Compiled\SWS\Dlls\dotNet\ADODB.dll"
/r:"C:\Dev\Compiled\SWS\Dlls\dotNet\Interop.SD_MSMQ_VB.dll"
/r:"C:\Dev\Compiled\SWS\Dlls\dotNet\Interop.SD_ServerIntf.dll"
/r:"C:\Dev\Compiled\SWS\Dlls\dotNet\MSMQ.dll"
/r:"C:\dev\compiled\sws\dlls\dotnet\SDNet_SerializableObjects.dll"
/r:"C:\dev\compiled\sws\dlls\dotnet\SDNet_SerializableObjects.dll"
/r:"C:\Dev\Compiled\SWS\Dlls\dotNet\SDNet_StdClasses.dll"
/r:"C:\Dev\Compiled\SWS\Dlls\dotNet\SDNet_SWSRemotingAsm.dll"
/r:"C:\Dev\Compiled\SWS\Dlls\dotNet\SWSConfig.dll" /t:exe
/out:"C:\Dev\Compiled\SWS\SWS Event Server.exe"
/recurse:"C:\Dev\C#\Server Apps\SWS Event Server\*.cs"


which is close to my worst nightmares.

I cannot work out how to use the /lib: tag either.
So running this command
csc /lib:"C:\Dev\Compiled\SWS\Dlls\DevExpress\"
/lib:"C:\Dev\Compiled\SWS\Dlls\Infragistics\"
/lib:"C:\Dev\Compiled\SWS\Dlls\dotNet" /r:"ADODB.dll"
/r:"DevExpress.Data3.dll" /r:"DevExpress.Utils3.dll"
/r:"DevExpress.ExtraEditor3.dll" /r:"DevExpress.xtragrid3.dll"
/r:"Infragistics.Excel.v3.2.dll" /r:"Infragistics.Shared.v3.2.dll"
/r:"Infragistics.Win.UltraWinGrid.ExcelExport.v3.2.dll"
/r:"Infragistics.Win.UltraWinGrid.v3.2.dll"
/r:"Infragistics.Win.v3.2.dll" /r:"Microsoft.VisualBasic.dll"
/r:"MSDATASRC.dll" /r:"SDNet_StdClasses.dll" /r:"StdFormat.dll"
/r:"stdole.dll" /r:"SWSConfig.dll" /t:exe /out:"C:\Dev\Compiled\SWS\SWS
Event Viewer.exe" /recurse:"C:\Dev\C#\Client Apps\SWS Event
Viewer\*.cs"

tells me that dlls cannot be found when it should... aaargh!!!

thanks
 
Back
Top