Posts Tagged ‘adding path to vs command prompt’
In this blog I am going to explain how to generate web service proxy for silverlight and how to add a new Path to VS 2010 Command Prompt (it might be similar for other version of VS, you all can try it out).
In my Silverlight project I wanted to create a proxy of my wcf service, as usual I asked svcutil to create the proxy for me. To my surprise after adding the generated proxy, my silverlight app is not compiling and started throwing errors like IExtensibleDataObject is not exist in System.Runtime.Serialization……. I couldn’t proceed further and at last prayed to google (to developers google is like a god 🙂 ). Bingo got one post mentioning about a util called SLSvcUtil.exe, available from SL3 onwards, poor me I was not aware of this new guy. I got what I wanted. I could locate SLSvcUtil.exe in C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools. I used this new tool and every thing worked well. I am relaxed.
After some time another issue started annoying me was VS 2010 command prompt was not recognizing slsvcutil.exe as a command. I added the SL tools path to the windows environment variable and restarted the machine but no use. My new path is not accepting automatically, The only way to add my path is the dos approach. Type the below command in the VS Command prompt.
path=%path%;C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools
I know that it will be stored until my machine reboot. As a developer I need a solution to this, because I may use SLSvcUtil more frequently and adding the path all the time will not work out. As it’s a command prompt so guessed that it will be wrapper to dos command prompt and some one is setting him the paths while opening it. I checked the properties of my VS 2010 command prompt and saw that target is %comspec% /k “”C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat”” x86. I was happy that VS command prompt is getting called from a batch file, so that I can set my path their. I open vcvarsall.bat and figured out that It’s calling other batch files based on your processor. The file content is below
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
if not exist “%~dp0bin\vcvars32.bat” goto missing
if not exist “%~dp0bin\amd64\vcvars64.bat” goto missing
As mine is a x86 32 bit processor so I have to look for vcvars32.bat. With a calculated guess I open the Bin subfolder. I was right the file vcvars32.bat was their in the Bin folder. With a quick glance of vcvars32.bat I could make out that he is the guy I was searching. I edited vcvars32.bat and updated my path as shown below
@set PATH=C:\Program Files\Microsoft SDKs\Silverlight\v4.0\Tools;%PATH%
I reopened my Command prompt window and typle SLsvcUtil.exe…. it worked. Now I don’t want to worry about setting the path when ever I do a machine reboot.