Visual Studio Express 2012 not building exe in Release folder - c#

I have compiled a simple 'Hello World' program. The program is successfully compiled without any errors. I can see a working executable in bin folder. But the Release folder of the project is totally empty.
I don't know if there is any settings problem or any problem in building. Apparently, I don't see any error.

You can change your build mode in top of your Visual Studio:
Dependently on which mode you build your solution, Visual Studio will generate .exe in either bin\Debug folder or bin\Release folder.

Make sure you're building the release version, not the debug version. By default, VS will build a Debug build, which will go into the bin\Debug folders.
For details, see How to: Set Debug and Release Configurations.

More expanded explanation:
Your output directory of executable file is specified by default to [your_project_directory]\bin\Debug for Debug build mode or to [your_project_directory]\bin\Release for Release build mode
your_project_directory - place where is created your project (there is located *.csproj file)
To switch between default directories Debug/Release use solution proposed here.
But if you want specify your own output directory, follow these steps:
Go to Project -> [MyProjectName] Properties... (or type Alt+F7) and in properties window switch to Build tab (from left panel)
From Configuration combobox select proper build mode (in your case Release) or select: "All Configurations" - the same options for both build modes
At the end in output path textbox choose folder where you want store executable file (and other created during buil of application)
Screenshot from properties window:
This solution can be useful at least in two cases:
When are you learning and you want not waste space on your disc, then you can specyfy outbut file for all your project to one tmp directory and clean it in some period of time from not necessary files
When your start work with real "huge project" that include many e.g. .csproj projects your can create Runtime directory to storage all your executable files and files created during build of application
I hope that this description will be helpful.

Related

Remove unnecessary files from release directory

I use NSIS to create an installer for my project. Wishing to have as small a filesize as I can, I began looking into my project's dlls, included files and prerequesites and noticed the following are all different:
the minimal files required to run, as determined by educated guess + trial and error. I made sure the application works properly with this minmal set of files.
the files exported by the "Publish" fonction for click once deployment (excluding click once specific files)
the files in the release directory (excluding the pdb and vshost files)
It seems VS2015 generates an xml file for every dll. Some dlls I don't use and don't reference are copied as well.
My question is why is there so many unnecessary files and how can I configure VS2015 to not have them in /release?
If you set VS build log level to verbose you will see exactly what happends during build and why a file goes to release folder. Once you determine the reason, you may either change your project file to adjust predefined behavior or add post-build event to remove unwanted files produced by build process.
MSBuild file, located at "C:\Program Files (x86)\MSBuild\12.0\Bin\Microsoft.Common.targets" is very useful to dig into build process details as well.
However, if you indend to distribute the content of release folder to other machines I'd suggest you look at some installation software, like Wix, for example. Once you create a setup project which includes files you do want, there will be no need to fight for release folder content.

multiple exe in bin folder after build solution

Is it possible to produce more than one exe in debug/release folder after we build Windows form solution?
For example I want to produce 2 exes in debug/release folder everytime I build a solution, 1. MyApp.exe 2. MyApp_setup.exe
Thanks
The \bin\Debug and \bin\Release folders are only defaults and can be changed in your project settings.
(Click for larger view)
All you need to do is change it to a relative path to be something both projects can see.
For example, if your folder structure was like
C:\
Code\
MyAppSolution\
MyApp\
MyApp_Setup\
changing both projects to use ..\CommonBin\Debug\ as their output path would put both exe's in C:\Code\MyAppSolution\CommonBin\Debug\.
However there is a second option also, if you add a reference to the MyApp project to MyApp_Setup when you go to build MyApp_Setup it will put MyApp.exe in the output directory because it considered it a dependency. Just be sure you have Copy Local set to true when you build.

Program Debug Database files in a Release output folder

I've switched over my solution's Build configuration to Release mode and now have an output in the "Release" folder instead of in the "Debug" one.
But still the Release output contains Program Debug Database files. Why is that? When should I keep them, when and how should I get rid of them?
The debug database files (.pdb or "symbol files") contain debug information, such as line numbers, to enable easier debugging.
When present, exception stack traces will contain the actual source file full path and line number.
It is up to you whether to distribute these along with your application.
In order to not create pdb files in Release configuration:
Go to your project's Properties.
Under "Build" tab, select "Advanced" (on the buttom).
For "Debug Info", select "None".
Note that this will not affect any references assemblies (their .pdb files will be copied to your project's output folder.
Read more about Symbols here: Program Database Files (C#, F#, and Visual Basic)
I guess it would be no difference if you deploy your application without these program debug databases as these files could be of great size.

Loading app.config file in Release

In my Visual studio 2008 project, I've added app.config file where I store some app-data in xml format.
I read this data in code like this:
string somedata = ConfigurationSettings.AppSettings["somedatakey"].ToString();
when I start application in Visual studio, it works. But if I try to run the exe file (release or debug) I get error (if i debuf it it breaks on the line above):
Object reference not set to an
instance of an object.
The file app.config is not inside folder.
Is the app.config file in the same folder as your exe? If not, copy it there.
Starting debugging in visual studio builds everything, and copies the output (including app.config) to the output folder, starting it from there.
#Jullin: When you run project from visual studio editor by pressing F5 then CLR pick app.config file to read data but when you want to run project from .exe (bin/debug or bin/release) then clr read applicationName.exe.config, which you must have within your debug or release or any folder from where you access you applicationName.exe.
Like i have a window application named "WindowsFormApplication", when i build it successfully in release folder i have WindowsFormApplication.exe and WindowsFormApplication.exe.config and some other files. so make sure you release project successfully and your release folder must contain files.
While Running in from the Exe make sure that u have added app.config should be in the same directory

Is it possible to "collapse" content file paths in build output in visual studio?

I'm using an open source library (log4net) that comes with LICENSE, NOTICE, and README files that are supposed to be included when you distribute it. So I want to make visual studio put them in the output directory along with my binaries.
I have log4net and its three files in a "lib\log4net" dir. The problem is if I add the files as content files, they get copied to bin\release\lib\log4net, not bin\release. Is there any way to make visual studio collapse the paths when building?
I originally used a post-build step to copy them, but then visual studio isn't aware of them and it won't put them in any other dependent project's output folder (which it will do if you call them content).
You could use a post-build step on your project and just move them to the directory you want them in. I frequently use pre-build steps to bring in the latest versions of dependencies and post-build steps to arrange my project the way I want to deploy it.
If you are using an install project to package everything, what about adding the extra files directly to that instead?
All you have to do is right click the file, README, for example, and go to properties. One of the properties is "Copy to output directory". Set it to true.

Categories

Resources