Command Line Arguments Batch

June 4, 2013 at 10:27:25
Specs: Windows 7
I'm trying to build a C# Project using Msbuild.exe
Small intro abt msbuild.exe:- Its an application which is used to build Visual studio projects even though visual studio is not installed in the system.

When a right click is made on the sln files (which is the project file) an new option "Build" was created (using regedit) and the option "build" was pointed to a script which is mentioned below:-

cls
echo off
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
msbuild.exe D:\Project\Computing.sln

So for every sln files when a right click is made and Build is selected the above script will be executed.
The issue is i need to use the corresponding file name in place of D:\Project\Computing.sln.
For eg:- if i build a sln file placed in "D:\New Project\New Computing.sln" , "D:\Project\Computing.sln" have to be replaced with the new file name.

I need to take the sln filename as an argument and pass it to the script. The batch has to read the file name which im doubting whether it is possible..
Please provide yours Ideas and Suggestions.


See More: Command Line Arguments Batch

Report •


#1
June 4, 2013 at 10:53:39
No offence intended but your description is pretty rough so I've re-written it:
When you right click on a sln file an option build is available through the use of regedit.
The build option refers to the script:
cls
echo off
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
msbuild.exe D:\Project\Computing.sln

So everytime the build option is clicked the above script is executed.
What i need is to replace D:\Project\Computing.sln with the file i've clicked build from.

As for an answer to your question, i don't really see if this is possible but you could make a script that would detect the newest created .sln file and replace "Computing.sln" with the newest modified/created .sln file. Would that work for you?


Report •

#2
June 4, 2013 at 12:10:03
1) Make sure Windows passes along the name of the .sln file. To do this, make sure your command ends with "%1". Regedit might be required, but using ftype would probably be easier.

2) Modify your script to use the passed argument:

msbuild.exe %1

How To Ask Questions The Smart Way


Report •

#3
June 4, 2013 at 12:21:14
@Razor2.3
Yeah that's a neat/obvious solution, but the problem is how to configure it to pass the correct location through modifications in the registry

Report •

Related Solutions

#4
June 4, 2013 at 12:30:29
It depends on how he went though the registry to add the .sln file association in the first place.

How To Ask Questions The Smart Way


Report •

Ask Question