Hi I have a c# project in visual studio 2010 and Im wondering how to do the following
I have deployed this project already to a tester.
It uses a SQL database in the backend.
When I published a new version and sent him the new installer he had to remove the old version first which in turn removed his database.
What I'm looking for is a way to publish the project such that it overwrites the old stuff that has changed while leaving his database in tact.
(This would also need to but probably would circumvent the message that you can't install because its already installed in another location)
Thanks in advance for your help
The absolute simplest solution is to not use an MSI or an installer to update the program. Since this is a .NET app, it just needs to be copied to the file system. (XCOPY deployment)
The next simplest solution is to use a true database - have the database be something that is set up separate from your application.
This might also work, but I have no time to test it personally: If this is a .dbf file or another file included with the project, you might be able to change the option on that file by selecting "Copy if newer" on the Copy to Output Directory Property in the properties pane for that DB file.
Could you use ClickOnce? It is super simple.
Here is a good tutorial - http://www.youtube.com/watch?v=t4BTLdIMYEY
Related
This question is a complement for the post How to change the output name of an executable built by Visual Studio.
After reading this post I did the following:
Firstly, I followed the answer for this post and I could define the executable file name successfully.
Now, I would like to know if instead of only define the name as "Demo.exe" as mentioned in the example post above, it would be possible to embed the version defined in AssemblyInformationalVersionAttribute or in AssemblyVersionAttribute in the built file, resulting in something like "Demo_v1.0.0.0.exe"?
I'm developing my application in C# WinForms, using Visual Studio Express 2017.
Why would you want to change the name of the executable? Whenever you try building a Setup for your application, you need to change the Setup to include the new file. And when you install an update, your Setup needs to know all versions of your executable in order to delete the old version. That's just not what you want to do.
If you want to keep all versions of the software for yourself, come up with a different solution, e.g. moving the executable into a folder which has the version number.
That said, I have done this for Setups, so customers can download different versions of the Setup. I did that using a commercial tool called Visual Build, but there are other build automation tools available. So, my answer is: set up a continuous integration / continuous delivery pipeline (CI/CD) and automate the step there, not in Visual Studio.
From the project properties, you can add Post build event command line to rename your exe
pseudo
Maybe you can create another console renamer.exe which reads version defined in AssemblyInformationalVersionAttribute or in AssemblyVersionAttribute of your app and renames it and then call that renamer.exe from Post build event command line
write a powershell script to rename the newly built exe and call that script from Post build event command line
My project was accidentally deleted and all I have now is those three files:
project.resx, project.designer.cs, project.cs.
is there any way I can restore my project?
If you're on windows you can try using Recuva( recovery tool )
if another OS( linux or macos) you can try using testdisk
First of all you shouldn't write anything in the drive where the project was located. Secondly, use a recovery tool such as Recover My Files. finally, like llya said, it always better to use source control.
I'm trying to figure out how to publish an application I wrote. We didn't get to publishing in class, and my programming teacher is having some health issues and isn't available right now.
I found the "Publish" option, and can get it to create a folder with an install program... but I open it, and it just opens the program, and spams me infinitely, complaining that my Access database (located in the bin > debug in the build stage) can't be accessed (from some weird path I don't recognize). I tried using WiX, but it gave me an error when I tried to install, saying it doesn't have access to the install folder (running as admin). I've been googling for a few hours, poking at it, exploring, and I'm not getting too far. Can anyone ELI5?
When you use the "publish" option for desktop apps, VS creates a click-once installer that will place all the files it knows about in the appropriate locations.
Unfortunately, it can't guess which other files your application needs so you need to tell it explicitly.
If you right-click the Project->Properties, go to the Publish tab and click the "Application Files" button, you'll see all files that will be added to the installer.
Next, click "Show all files" at the bottom. Find your database, and change the Publish Status to "Data File".
Note that I've only ever used the Click Once installer to install static files (like images/documentation) that are never modified, only replaced in later releases. I'm not sure whether your (modified) db will be preserved during an update but I suspect not.
If the Click Once install process is too simple for your needs, VS2010 has "Setup Projects" which create more complex installers that support logic/code. For VS2012, the commonly suggested option is Wix. Unfortunately, it's got a steep learning curve but it can do pretty much anything you need.
I believe VS2013 and later have setup projects again through an extension but I haven't tried it myself.
Edit:
The easiest way around this is likely to set the connection string programatically based on where the application is executing from.
Note that as per this answer clickonce apps are usually executed from deep inside the user profile directory (also read the answer below about data directories). It's a side-effect of how ClickOnce works (it wants to install somewhere the user is guaranteed to have write access).
Check if there really is an .mdb in that folder. If not, you need to tweak the installer or the properties for the .mdb. Assuming it's in the same location as the executable, you can tell your application where to find it...
string dbPath = IO.Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"access.mdb");
string connectionString = String.Format(
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}",
dbPath);
I'm not sure why you think the database file added by the installer is in a directory directly under C:\. It's possible you're not looking at the file created by the installer.
To avoid confusion, try changing the name from access.mdb to something else (temp.mdb?), build the installer, rename back to access.mdb. Now, when you've installed the application, make sure the file you're looking at is now called temp.mdb. If not, you're looking at the wrong file.
This Link Has Full demonstration of Database Connectivity And Publish a C# application with database. The application is also running on another machines.
How to Publish C# Application with access database
I am creating a C# application using Visual Studio that uses an SQLExpress database. When I hit f5 to debug the application and make changes to the database I believe what is happening is there is a copy of the database in the bin/debug folder that changes are being made to.
However, when I stop the debugging and then hit f5 the next time a new copy of the database is being put in the bin/debug folder so that all the changes made the last time are gone.
My question is:
Is there a way that when I am debugging the application I can have it make changes to the actual database and those changes are actually saved or will it only make changes to the copy in the bin/debug folder (if that is what is actually happening)?
I've seen similar questions, but I couldn't find an answer that said if it's possible to make those changes persistent in the actual .mdf file.
The reason I ask is because as I build this application I am continuously adding pieces and testing to make sure they all work together. When I put in test data I am using actual data that I would like to stay in the database. This would just help me not have to reenter the data later.
Thanks in advance for any help or information that could help me better understand the process.
Select the databases in Solution Explorer and change the "Copy to Output Directory" to "Copy if newer". Later, when you finally get the final version, copy paste the databases in debug folder to your source folders
The problem with 'Copy if newer' is that when you make changes to any part of the structure of the database, that change is to the version in your Project directory and not to the version you are building on in the Debug directory.
Also, when you try a non-debug run you are not using the copy you have been chaging in the debug location.
I normally use a Postgresql, but as this is a new computer and I discovered MS do this Lite version, decided to give it a try. I have a lot of data which is historic that I want in the table, then some manual manipulation with a bit of SQL, Then I can carry on creating the actual functionality of the database.
You can not just copy the altered version into the project directory, because there is a log file and no one seems to know what is in there but Microsoft desperately need that to match your database file in some way. (I am guessing you already tried that too).
I didn't want to have to start from scratch every time I ran it, and just like you I found no solutions. So in a desperate move I copied the version in Debug to a tmp directory. Then deleted the version in the project solution explorer.
Then I dragged and dropped the version in tmp into solution explorer. (Everything in it is structurally the same as the original, except as stated below)
That did it, it recreated that Log file. Now my debug sessions start with a ready loaded data.
Words of warning.
1) Changing the database structure.
In your solution explorer, the the Linq to SQL DBML file, if you have changed some structural part of the database in code (which is where I tend to do it), right click on the DBML file and go into design view. Then drag into the design any new tables or views that you have added.
2) Because having to delete and drag in the database feels a bit dodgy, write yourself a function that runs on Form_Open when in debug mode that copies your database file such as
\MyDatabaseBackup\myDatabase_date_time.mdb
Remembering that if you do go back to a previous version at any time you need to rename it myDatabase.mdb
Copy database to some proper location and change the connection string in config file to point to that only, it is only a suggestion as not sure what type of app. it is.
I have made an application, which keeps getting updated frequently. So every time a change occurs, i've to include it's fresh builds to the setup and deployment program again and again. Is there any way to simplify the procedure? The files to be added are static in number and exist in a folder. I've heard we can write installer classes in c#, does my requirement has any thing to do with it?
I think ClickOnce doesn't suit my requirement because, for the first time i want it to run like a setup package, since it has some packages and some settings needed to be implemented on the user's machine at the time of install. Can click once help me with that? Also i want to run my application as an administrator and it references to many external dll files. So will it help my purpose?
I finally did it using clickonce deployment. I used content files to mark all the files i wanted to copy to the target computer and used clickonce deployment. Then i modified the way my program starts, so that i can lauch the installer script i wanted to run only when the app runs for the first time. Further i hosted it on IIS and had to change lot of MIME types and add new ones for the download to work over internet
Look into something called "ClickOnce" deployment. It automates a lot of what you're talking about.
EDIT: You can add custom installer actions to a ClickOnce project just like any other, to set up additional components and whatnot. As for permissions, ClickOnce will let you run as administrator if you so choose, but that sort of thing isn't recommended, and it might whine about it.
You can use ClickOnce (http://msdn.microsoft.com/en-us/library/t71a733d(VS.80).aspx) which simplify the deployment process.
Maybe you can also automate the build process using NANT (http://nant.sourceforge.net/).
HTH
Yes, you can do that.
I assume you want the client to update itself when ever there is a new version.
This needs a few changes in the client code. Essentially how it works is check for availablilty of new version at a predefined location. Update you new versions to this location. On the client side, show a message to the user if he/she wants to upgrade to the new version.
You can find a link to sample project out here and here.
You can add a Setup project in your solution inside Visual Studio and then add your other project(s) outputs, or static files to the Setup project as references. The Setup project will then detect your dependencies automatically and each time you do a Rebuild All (or you rebuild/build your Setup project) it will automatically include all the necessary files.
What type of project is it? In many cases, ClickOnce can do the job for you, at nominal effort.
Beyond that - you can usually hook your installer build into your build process; some tools will do this for you.
Installer classes run at the client - so I don't think they relate to your build process...
I would flag the files as Content in their respective properties and then in the deployment project right click the project, go to File System and then right click the folder, click Add and select Content Files from the dialog box. This should copy the newest files over every time you build the deployment project.