How to update the assemblies and file using setup project? - c#

I've created a windows application in C#. The application has check for update feature. Whenever an update to the application is available, it downloads the setup file.
When we run the new setup it is successfully installed and we can see the new version in control panel. But the problem is that the assembly files and other files in installation directory are not updated. They are still the previous version of files.
I have set the following properties of the installer project:
- DetectNewInstalledVersion : true
- RemovePreviousVersion: true
Am I missing any property of setup project or is there any other approach to do that. I don't want to use any third party tool for setup creation.

You must increment the file versions of those files that need replacing. That's because of the Windows Installer file replacement rules.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa367835(v=vs.85).aspx

Related

How to version control multiple forms in one application

I have a single solution which contains 3 forms so far(will be more in the future).
The first form(main one) is a simple drop down list which shows available applications and opens selected form.
Now, I need to notify a user(on start up of the application) that there is a newer version of specific form available and therefore they should download an updated exe from the LAN.
I could check a folder where all exe files are kept and use exe name but this would only be applicable to the main form.
Any ideas?
You could:
Maintain each form in a separate class library meaning you can check
for updated .dll files rather than the exe.
Publish a text/xml/whatever file with information on the latest
published versions.
Just have an assumption that if either of the forms are updated, a
new exe is required anyway.
I would use an external XML file or SQL tables to store the applications that can be opened from the main form and their latest (assembly) version number
You could then use a local (user) settings file in the application to pair each application with the last known version and check this against your external file to determine if an update is required.
Then you just need to make sure you change your assembly version number and update your external file whenever you make changes.

Include config file after publish with WiX

Scenario:
I have two applications, a Windows Forms App and a Windows Service App. The two applications work together, use same libralies (dll) and share the same configuration file (this file is not the app.config but a custom file).
Complications:
I have a website (webforms) where the user will enter information about configuring the software, this information will be saved in the database and from this information will be generated the configuration file. The site should generate build the project with the new configuration file and the page responds to the client's request with a link to download the .msi.
Problem:
How to generate an installer from a command line to be called by the web application after generating the configuration file. I researched and found the Windows Installer XML (Wix), but it seems to be necessary to compile the entire project every time someone downloads. It's possible leave the program compiled and only add the configuration file after?
Apretiate any helps
Light (the linker in the WiX Toolset) has a feature called "cab cache" which will re-use the cabinet files which are embedded in the resultant MSI. You would use the arguments -reusecab and -cc to enable this.
You'll still have to re-build the MSI when the user submits your form, but the build will be faster (cabinet generation is usually the longest part of the build process).

Unable to install or run the application....in Desktop Application

I had developed a Desktop Application in .Net. I had published and deployed it in my Client's System. But while my client running that setup, an error message is displayed :
Unable to install or run the application. The application requires that assembly Microsoft.SqlServer.Diagnastics.STrace Version 10.0.0.0 be installed in the Global Assembly Cache (GAC) first
What should I do for this ?
Open project Properties form Solution explorer in visual studio
Properties->Publish -> Application Files
In Applications Files window check Show all files at the right bottom. change publish Status of "Microsoft.SqlServer.Types.dll" "Prerequisite(Auto)" to Include click ok and publish Application.
Probably, this dll is not present in Global Assembly Cache.
you can add an assembly to GAC by following command:
GACUTIL –i <Path to Microsoft.SqlServer.Diagnostics.STrace.dll>
to find if STrace.dll file is present on your client computer, you can search it with this command line:
dir Microsoft.SqlServer.Diagnostics.STrace.dll /s
if the file is found, use the previous anwser command line to add the dll to the global asembly cache
If not, you have to add this file as prerequisit in your deployment project
if you have a setup project (lik installshield / MS setup project / Clickonce project, the prerequisit can be added on your setup project properties.
when you add a prerequisit, you should be able to choose if the prerequisit has to be packaged with your application or downloaded from the publisher site.
What solved my problem was I had to do what #ShahidRaees did except include all of the assemblies. I selected all of them except for the file ending in .pdb.
Selecting all of them should automatically update the GAC when you install the program, but I'm not 100% sure.

how to deploy my application?

I want to deploy my application. i followed this step but i can't get the .exe file. steps:
Step I:
Create one Windows based application in VS.Net using any of the Languages i.e. C# or VB.Net.
Step II:
After your program is running and you are ready for the setup. To add setup to your existing application go to Go to File > Add Project > New Project.
After your program is running and you are ready for the setup. To add setup to your existing application go to Go to File > Add Project > New Project.
The window appears like below and you select the Project as Setup Project and give a Name and its Location.
Step III:
After creating setup project right click on project and than select view, it will show different possible operations, which you can perform with this setup project.
The options available are
File System
Registry
File Types
User interfaces
Custom Actions
Launch conditions
Step IV:
Click on File system, it is used to create file system on the target machine. Through this you can specify what details you want to provide at the target machine.
Step V:
Now in the new window, its time to add the files & folder’s used by the application.
First we add the Project Output file. Click on Project Output and a new popup appears. Select the appropriate choice. For a normal project we select as Primary Output File & Content Files.
it is used to create file system on the target machine. Through this you can specify what details you want to provide at the target machine.
To add Icons/Any specific folders, click on Add > Folder and Folder is added. Rename the folder as per your project requirements
After the Folder is create then add the files to the setup. These will be installed in the same fashion on the target machine
Step VI:
Now we are about to create the setup before that we will setup the program icon. To do it we will do this process :
When you click on Browse, a window gets popup. Now as the icons are already added into the application setup, just click on Browse to pint to that icon and click on ok.
Step VII:
Now final step is compile the setup project. After compilation you will notice that it has generated Setup.msi in the same location which you provided when you initially created the setup project.
You can supply this msi the target machine, when you run this msi at target machine it will create a virtual directory as well as create same folder structure, which you have specified in File System. This installer will also install the specified those libraries in the registry which are specified in the Registry.
Now you can browse that application at the target machine in same way as you have done at your own machine.
What I could understand is, you have got some problem with deploying the EXE file.
This is the best tutorial I have ever seen for creating EXE or MSI files:
http://balanagaraj.wordpress.com/2007/05/29/create-exe-or-setup-file-in-net-windows-application/

Settings file of a console app is not being created

I have a solution which has 3 projects. One is a console app and other 2 are windows applications. Both windows applications uses console application so I added the reference of console application in both windows app projects. Now when I build windows projects, console application is being copied in output directory but the problem is that its config file "consoleapp.exe.config" is not being copied!
If I would have used a library (assembly) instead of console application, it would created the config file of that assembly in output folder.
How to solve this problem?
Try this:
Select consoleapp.exe.config in solution tree.
Select "Content" for Build Action option in property grid.
Select Copy always for Copy to Output Directory option.
Hope this helps you :)
Quickly creating a console project in VS2008 and adding an "App.config", it has settings:
Build Action: None
Copy to Ouput Directory: Do not copy
Custom Tool: <blank>
Custom Tool Namespace: <blank>
However I'm not sure what effect adding a reference to the console project will have, as a console project is an application rather than class library.
If you want the console application to start up with the Windows applications for debugging, then a better approach than project references would be to set the solution to start multiple applications. Right click on the solution, select properties and on the Start Project node, select multiple projects. (And remove the references to the console application.)
Your applications are using the default values for your settings from the compiled code of the referenced project.
You should copy your app.config from the other projects (or at least copy the settings that you want to be able to change) to the calling project, and then when the application compiles you will have an [YourAppName].exe.config that you can modify.
All this happens because an app domain in C# can have only one assembly level app.config file. Here's more information on MSDN.

Categories

Resources