Consider these two software: MyGame.exe and SocketTest.exe.

MyGame.exe doesn't depend on any files to run but SocketTest.exe is an actual software. It can only run if one or more of four other files are in the same folder as itself. These files are: metouia.jar, SocketTest.bat, SocketTest.jar, SocketTest.sh

I want to create a software using Windows Form in Microsoft Visual Studio using C#. It will have two buttons: "Launch MyGame" and "Launch SocketTest."

I go to the Solution Explorer tab and right-click my .csproj file to click Add Existing Item... so I can add MyGame.exe, SocketTest.exe and the other four files into the Solution Explorer.

For the File Properties of the 6 files, under "Copy to Output Directory" I choose "Copy Always."

For Build Action, I'm not sure. I use "None". My buttons can still launch the two .exe files.

However, I'm not sure which settings to use if I want other computers to be able to launch those .exe files with my software, especially for the .exe file that depends on other files. I've read the Build Action descriptions (online too) but still can't decide on the proper one for my situation.

2

There are 2 best solutions below

5
Pancake On

The way your're doing it is fine. A few notes:

  • Instead of "Copy Always", you can use "Copy only if newer"
  • For "Add Existing Item...", instead of adding the items directly, you can pull down the "Add" button and select "Add link" - this will keep the files in sync with the source items, in case they are updated
  • Build action "none" is correct. You are not building these items, just copying them to your output folder.

Whatever you do with your project -- publish, deploy, etc -- the added items will stay with your project output.

Good luck!

0
AudioBubble On

Rather than adding artefacts into your launcher which just produce noise as far as the .csproj is concerned, consider using build events.

Right click your launcher's project, choose Properties then Build Events. In the Post-build event command line enter appropriate copy commands to copy your binaries and artefacts from your other project folders to your launcher's OutDir folder.

Anything more and you should probably look into making an installer.