0

I'm using visual studio 2012 - c#

I made a program to view videos (and the program will be placed on the CD to work spontaneously, such as educational CD)

How I can publish my project to exe (like portable) so that any one can run my program without having to run a setup?

nvoigt
  • 75,013
  • 26
  • 93
  • 142
waleed-gfx
  • 23
  • 1
  • 5

2 Answers2

3

It takes a lot of preparation, but the simplest solution is the following:

  • Compile against most common framework - .NET 2.0
  • Copy the executable from the bin/Release folder
  • Place executable in the root folder of the CD-ROM
  • Create an autorun.inf file

If you want to compiled aganist the latest version of the .NET framework, not all computers might have it install. In that case, you would need a bootstraper program that check if the framework is installed before running your application.

Here is another bootstrap solution that I found on Bootstrapping The .NET Framework Without An MSI Installer by Derick Bailey. He uses a WSH/VBScript to create the boostrap.

Dim WshShell, value
Set WshShell = WScript.CreateObject("WScript.Shell")

ON ERROR RESUME NEXT

Sub Run(ByVal sFile)  
  Dim shell  
  Set shell = CreateObject("WScript.Shell")
  shell.Run sFile, 1, true
  Set shell = Nothing
End Sub

value = wshShell.RegRead("HKLMSoftwareMicrosoftNET Framework SetupNDPv4Install")
if (Err.Number <> 0) Or (value is nothing) then
  Run("dotnetdotNetFx40_Full_x86_x64.exe /passive /showfinalerror /promptrestart")
end if

run("My.Actual.App.exe")
Black Frog
  • 11,595
  • 1
  • 35
  • 66
  • Can you explain that step by step cause i'm beginner in visual studio, and this is my first time publish project – waleed-gfx Apr 05 '14 at 22:46
1

You said:

"thanks JoJo but i want my program run in any Computer whithout setup"

What Black Frog posted is correct, you will have to have the .net framework installed in order to ensure your application runs, which means that this may not be an option for any computer, unless you use an option like that outlined below and in the linked question. You might be better simply distributing an existing portable version of one of the free video players on the cd and then creating an autorun.inf file which launches the video to be played using that player.

I believe I have done similar with mplayer before with some success.

Obviously if your application does something other than just play the video then this may not be an option.

Another option if you have to use the application you have written is to use a .NET linker to include all of the code your app needs, including the bits of the framework that it wants, without having to have it installed. Some of the answers to this question might help if you want to go down that route.

Community
  • 1
  • 1
Sam Holder
  • 32,535
  • 13
  • 101
  • 181