Package installed executable doesn't load ConfigurationManager.AppSettings from .config file - c#

I have an App.config XML file in my application project that I use to provide customizable options to the user.
I have an install project that installs the application project output and the configuration file to the program files folder.
If I launch the application from within Visual Studio, the configuration is loaded from file correctly.
The config settings don't get loaded when I launch the installed executable, but if I copy the executable from the application project binary output directory over the installed executable, it works.
What am I missing?

I was building a DEBUG target and installer, whereas when I changed it to RELEASE, the installed application loaded the configuration correctly. Apparently it is an issue with installing a debug version of an executable. I have a fix/workaround (do not install a debug version of my application), but it would be interesting to know why it didn't work.

Related

pack msi into setup.exe

I am creating an installer for a WPF .NET 5.0 project using the 'Visual Studio Installer Projects' extension.
My output after building is an appName.msi file and a setup.exe file that installs prerequisites followed by the msi file.
Having two separate files is not an acceptable solution since the user will not be able to choose the correct file to click on.
How can I make a setup.exe file that includes the msi file (msi packed into the exe) with Visual Studio Installer Projects?
Or if there is any other solution that ends up with a single file for installation that would also be fine.

Windows Service Installation Path C#

I have a Windows service I created and have the Setup project for it as well. Within that setup project I do have the installation path configured in the properties.
[ProgramFilesFolder]Company123\ServicesMonitor
When I install the service through Visual Studio it works as intended, it installs to the correct place (C:\Program Files (x86)\Company123\ServicesMonitor). But when I install it using the Setup project's actual .exe or .msi found in the Setup project's release folder, it just installs the service to my root E:\ drive.
Does anyone know why this is? Thanks.
Don't go to projects release folder, go to Setup project release/debug folder and search for .exe or .msi file.

Visual Studio 2017 and a missing EXE file

(I am using Visual Studio 2017.)
I started a small console application. A Discord C# bot. So I always launched this program with Visual Studio. After finishing it, I wanted to put the .exe file on a server, to keep this bot stay online all day long.
In the directory, there isn't any .exe file.
So I started the application again and saw this console is opened from a different path:
"C:\Program Files\dotnet" and this .exe is called "dotnet.exe"
When I want to start this .exe file manually, it closes instantly (maybe because of the missing line of code Console.ReadLine(); I don't know).
What should I change in Visual Studios settings to have an .exe file in my correct directory for my console application?
The attached picture shows my bin directory, where the .exe file should normally be. There is a .dll file, but I need the .exe file...
Updated answer:
When this answer was written, back in 2017, .NET Core only output dll files, this has since changed. This can now be achieved with this property in the application's csproj:
<OutputType>Exe</OutputType>
There are also additional deployment methods like the single-file deployment.
Original answer:
There is no exe file because you created a .NET Core application.
You have two options:
If you want an EXE, you need to target the .NET Framework.
If you don't want to change your code, then you need to install .NET Core on the server and run dotnet pathToDll on a command line

Visual Studio Publish gives different binaries to build

I usually deploy my web application by right clicking on the app and selecting the publish option. VS copies everything to a local file system folder then I zip it up and copy it to the web server.
For some reason when I publish my branch the binary in the publish folder is different from the binary in the local build folder. It's as if it's building different code.
Both the local build and the publish are using Debug (Any CPU) configuration.
Here's a screenshot of the decompiled assemblies.
This first one is the one from the project bin folder and runs perfectly.
This one is from the publish folder and as you can see it contains some lines which aren't in the other build.
This particular class doesn't have any #IF DEBUG pragmas in it.
I've tried clearing out the bin and obj folders with no success.
Does Visual Studio have a cached copy of all the code somewhere that it uses to do the publish build that I can clear out?
Are you sure you have Debug configuration enabled in Publish settings? Publish settings override current Visual Studio project configuration.
Having Debug publish configuration enabled, publishing applies the Web.Debug.config transformations over Web.config, while local build ignores Web.Debug.config. As I see, you miss the NewJobRegisteredObject in published assembly, you may have xdt:Replace section in Web.Debug.config removing object registration.

add mobile software exe in my msi file and need to run before my msi file run on client system

I have made msi file of my project using setup and deployment option from visual studio.I want to add one exe file of mobile software in my setup folder and i want ,that mobile software exe should be run before my msi file from my setup folder.I don't know that how i give the path of that software exe and run from my setup folder.
I have used prerequisites option and also add file in my application folder while making setup,but i don't get any solution of my problem.
Please help me.
A prerequisite is the correct solution. Visual Studio setup projects do not support custom prerequisite creation. However, it can be done by manually generating the required manifests.
You can find the manifests structure here: http://msdn.microsoft.com/en-us/library/ms229223(VS.80).aspx
These manifests can be generated automatically with the Bootstrapper Manifest Generator tool.
After generating the package manifests, you can add all these files (including the package) in a separate folder in the Visual Studio prerequisites folder, for example:
C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages
You can then select the prerequisite in your setup project property pages.

Categories