VS2010 Web Setup Project not replacing 'web.config' file - visual-studio-2010

I am using VS2010 web setup project for my MVC3 webapplication. It is working fine with installation. But if I update the version of MVC3 webapplication binary and Web setup project for upgrade (from existing installation of older version) it will not replacing the web.config file on destination directory. All other files and directories are replaced and updated but only 'web.config' file is not replaced by the Web setup.
I am changing the version of Web setup project and MVC3 application each time when I update anything in web application.
I also tried with changing the "ProductCode" and "UpgradeCode" but still web.config file is same (of first version)
I set following property of Web setup project
DetectNewerInstalledVersion - True
Removepreviousversions - True
RestartWWWService - true
If I remove/delete the existing web.config file manually and then install the new version than it will put the new updated web.config file. The problem is only occurs when there is existing web.config file is available in destination directory.
I also tried custom action's "OnBeforeInstall" to delete or rename the existing web.config file so that new we.config will copy in installation. But in that I found that all files are copied before the custom action method execute.
Please help me to resolve this or suggest an alternative way to provide web setup project to my clients.
Thanks in advance!
Edit:
I found that when I change the version of Web Setup project, It will automatically change the productcode but upgradecode is still same.

When installation, installer will check the version of each file that it will replace. So if a file is of same version or it is not changed between two installers, installer will not replace it. But if that file does not exist, installer will drop that file.
Solution:
Try deleting file before "costfinilize". So in your case call custom action to delete\remove file before "costfinilize".
You can use Orca to check execution sequence of all custom action of an msi.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa370557(v=vs.85).aspx

Related

auto exclude folders / files with a certain name from vs2017 solution

Not sure if this is the correct place to ask this but there have been a lot of visual studio questions in the past here.
I am currently creating a lot of npm packages in a solution and as part of the package, I have to create a package.json file.
Once I save the file, it creates a node_modules folder and downloads all the dependent npm packages to it. Now I have got azure dev ops to ignore these files so they aren't checked in by adding the node modules folder to the list of ignored folder names, but I also want to exclude them from my project so that it doesn't lock my computer every time it tries to write all the file names in to the .proj file.
Is there a way to automatically tell the project or solution to auto exclude this folder - like a solution ignore file I can add the name to?
Or is there an option somewhere that folders that aren't created through vs, aren't automatically added to the project - this is how my earlier versions of vs worked - new folders not created through vs would have to be manually included if you wanted them in the project / solution
Ok this is due to the project type that I used when creating the project - I created it as a .net core project and that seems to add files by default and only exclude them if you tell it to, if I change this back to a .net standard project, it works as I would expect - only includes files you drag into the project or tell it to include

Visual Studio Setup Project not updating Content File

I have a Visual Studio Setup project which includes a .SQL file from my project which should always overwrite the existing file if I run the installer on the same machine to update to a new version. The problem is that doesn't always seem to happen. Under File System > Application Folder > File Installation Properties, which property would tell the installer to always overwrite the existing .SQL file on an install?
The upgrade is an install of the new files on top of the older files, during which file overwrite rules are followed. The rule for data files is that they will not be overwritten if they've been updated since they were installed. If you've installed a database that's now full of customer data it's usually a bad idea to just replace it with a new empty database:
https://learn.microsoft.com/en-us/windows/desktop/msi/neither-file-has-a-version
Among the ways to solve your problem are:
Update the existing file with the new data using a custom action.
Avoid the problem in the first place by having the installed file copied to a location where it can be used, updated etc by the application. The original can then be overwritten by the upgrade, and the application detect that there is a new one to use, that it copies to replace the previous copy. It maybe too late for this.
Have the application make the creation date and modify date of the file have identical values so that the upgrade will think it's not been updated.
Install the new file to a different location (and use 1. from now on). The older file will be removed by the upgrade.
Edit the MSI file (with a tool like Orca) to move the location of RemovePreviousVersions (in the InstallExecuteSequence) so that it is immediately after InstallInitialize. This will completely remove all of the old files before installing the new ones, so it won't help if you have that database full of customer data mentioned in the opening paragraph.

TFS 2010 Build Automation for a Web Site: Delete a file in the publish folder after build

We are trying to adapt a build automation strategy for our ASP.NET web site (not a web project) in vs 2010 ultimate & tfs 2010.
Build definition makes the build and publishes the web site into folders like
<drop_folder>\<defn_name>\<defn_name>_<year><month><day>.<build no>\Release_PublishedWebsites
Now we try to delete particular files and folders from that folder. For instance the "images" or "files" folders, that we need to exclude before packaging. I know that if it were a web project, there exists a straightforward solution. We also tried to modify the build process template (xaml) file. There is a "DeleteDirectory" component but we couldn't figure out what to write to the Directory variable.
Thank you.
If you follow the XAML way, you would just have to feed the Directory argument of DeleteDirectory with the physical UNC path to the folder you 're trying to get rid of.Something along the lines of String.Format("{0}\\{1}\\{2}\\Release_PublishedWebsites", BuildDetail.DropLocation, BuildDetail.BuildNumber, Date.Now.Year)
should get you near to your target. Since the drop location of the build might be on a different machine, also ensure that the account conducting the build (by default = NetworkService) has the rights to delete folders on the target.

How to tell MSI not to ovewrite existing file in Setup & Deployment Project in VS2005?

I've got a Setup & Deployment Project in VS2005. One of the files that i'm installing is a SQLite data file.
I'm about to release a new version for the software, but i found that if i run the update on existing installation it overwrites the data file.
I've got an updated data file in the setup project so it's newer than already installed, but i don't want to overwrite it.
I've tries setting the Permanent property for that file to True, but to no avail.
Any suggestions?
Ok, here's a workaround that i've used:
In my setup project I've renamed my blank database file from Database.db to Database-blank.db.
In my app i'm checking if Database.db is missing and copying Database-blank.db to Database.db if it is.
then just load existing Database.db
This way i can ensure the local copy of the data file (Database.db) does not get replaced by newer versions of the software.
In MSI, the best way would be to make a record in the Upgrade table, determining whether this is an upgrade installation, and setting a property if it is. Then put the data file in a component, and place a condition on the component. Alternatively, make an entry in the AppSearch table, checking for the presence of the file (through the DrLocator table).
I don't know whether a Setup & Deployment project supports any of this. So as a fallback, install the file with a different name, and then create a custom action that copies over the file conditionally.
Because VS2005 setup when upgrading a program first it remove the original installed instance
and then install a new one, so for that the file will be removed every time.
to avoid replacing or overwriting the file I suggest the following:
1- mark the file as readonly in the setup project.
2- mark the file as permanent in the setup project.
now after upgrading the file it will not be overwriten, but your application can't deal with this file because it's readonly, so in the startup of your application check if the datafile is readonly uncheck it.

Visual Studio Web Setup Project - deploy outside of web root (wwwroot)

I am working with Visual Studio setup projects to install web application. I am looking for a way to change the default physical file installation path. The end result I would like is a Virtual Directory called "MySite" that points to a local path on the server like "C:\Apps\MySite"
Is there a built-in option to customize this?
edit the project file. search for keyword 'virtual' and change the value for virtual directory.
No, it will install at the physical file installation path of the Web Site where it is installed plus the name of the virtual directory.
You have to do it with a custom action, unfortunately it's not supported as a simple setting in the setup project (as others have mentioned).
Here is an example implementation using custom action:
Allow user to set physical directory path during Web Project deployment
(a bit old but can still be useful)

Resources