First of all open run window and type cmd and then press 'enter' or click 'ok' button. Then go to the folder or make a folder where you want to create and compile .cs file (C-Sharp source code).
For example:-
c:\Users\Administrator>d:
d:\>md C#Folder
d:\>cd C#Folder
d:\C#Folder>
Now create a batch file with the name CSCompiler.bat by writing the any one of the following commands
d:\C#Folder>copy con CSCompiler.bat
or
d:\C#Folder>edit CSCompiler.bat
and write the following code in it ----------------------
@echo off
if "%1" == "" goto x86
if not "%2" == "" goto usage
if /i %1 == x86 goto x86
if /i %1 == amd64 goto amd64
if /i %1 == x64 goto amd64
if /i %1 == ia64 goto ia64
if /i %1 == x86_amd64 goto x86_amd64
if /i %1 == x86_ia64 goto x86_ia64
goto usage
:x86
if not exist "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat" goto missing
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
cls
goto :eof
:amd64
if not exist "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat" goto missing
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
cls
goto :eof
:ia64
if not exist "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\ia64\vcvars64.bat" goto missing
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\ia64\vcvars64.bat"
cls
goto :eof
:x86_amd64
if not exist "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat" goto missing
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
cls
goto :eof
:x86_ia64
if not exist "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\x86_ia64\vcvarsx86_ia64.bat" goto missing
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\x86_ia64\vcvarsx86_ia64.bat"
cls
goto :eof
:usage
echo Error in script usage. The correct usage is:
echo %0 [option]
echo where [option] is: x86 ^| ia64 ^| amd64 ^| x86_amd64 ^| x86_ia64
echo:
echo For example:
echo %0 x86_ia64
goto :eof
:missing
echo The specified configuration type is missing. The tools for the
echo configuration might not be installed.
goto :eof
------------------------ and save it.
Now run that bat file
d:\C#Folder>CSCompiler
And then you can create and compile your .cs file any where.
No comments:
Post a Comment