views:

246

answers:

2

Hi.I created two applications.(Console Appliaction: MyConApp.exe and Windows Application: MyWinApp.exe) Purpose, Attach MyConApp.exe to MyWinApp.exe and transfer the MyConApp.exe args with the MyWinApp's Pre-build event.

[update]

MyConApp.exe is a small tool to parse a XSD file and generate a FromXSD.cs file. It worked very vell if i double click it.And myConAppArgs is the XSD file path.

Now the FromXSD.cs file used by the MyWinApp.exe project. I hope to build MyWinApp.sln with the FromXSD.cs file at the building time.

If the XSD file changed someday. I need handle the new XSD file automatically if i take use the pre-build event command line method. That's why i procedured the three steps.

My Procedure

Step1.

I copied the MyConApp.exe to the same path of MyWinApp.exe.

That is say: there are two .exe file located in the path *D:\learning\cs\MyWinApp\MyWinApp\bin\Debug*

Step2.

Open the MyWinApp project properties -> build events -> and the Pre-build event command line:

input:

myConApp.exe myConAppArgs

Step3.

Save MyWinApp project, build and run it.

Is there any better method to do this or any stand procedure to follow? Thanks for reading and replies.

+1  A: 

Due to the fact, that you want to do this in your pre-build event, you can merge step one and two. Just try the following in your WinApp pre-build event:

copy /y $(SolutionDir)conApp\$(OutDir)ConApp.exe $(TargetDir)
ConApp.exe -i -k -whatever

So your ConApp will always be fresh copied within the pre-build event. Also you should set in the Project Dependencies of WinApp, that it will depend on ConApp. So ConApp will always be built before WinApp.

To access the Project Dependencies just right click in your Solution Explorer on the WinApp project and search that entry within the context menu.

Oliver
+1  A: 

This sounds pretty bizarre, does the MyConApp.exe do anything that affects the build process of MyWinApp.exe? If it does, it certainly doesn't belong in the bin\Debug directory, it would have to have the same affect when you build the Release version. It belongs in the project directory.

If it doesn't affect the build then using a pre-build event is entirely inappropriate. You'll then need to explain why this is at all necessary.

Hans Passant
Hi Nobugz, I updated my post. thank you.
Nano HE