Custom action condition to run for a new or upgraded product.

I have a custom action condition (in Visual Studio Web Setup Project) that I want  to run for installation of a new or upgraded product. I do not want to run it on repair (and also during uninstall).

First of all I tried “Not Installed” condition. But it doesn't work for version upgrade. I've tried

Not Remove=”ALL” but it also doesn't work for version upgrade( it seems that deleting previous version set the property Remove=”ALL”)

I've tried UPGRADINGPRODUCTCODE , but it is set for the previous version, not for the version being installed.

The article http://www.rsdn.ru/article/install/wininstaller2.xml (sorry, in Russian only) suggests to use IS_MAJOR_UPGRADE ,but the property is applicable for InstalledShield only.

Finally I found combination that is working:

(Not Installed) OR PREVIOUSVERSIONSINSTALLED
Note that brackets are important to evaluate NOT first and condition is case-sensitive).

PREVIOUSVERSIONSINSTALLED is not documented property, I found it when reading msi log and in a few posts(e.g. here: “If the search at the start of the install detects
an older version, it creates the PREVIOUSVERSIONSINSTALLED property,
case-sensitive.“ ).

NOTE: I found that custom action with condition
(Not Installed) OR PREVIOUSVERSIONSINSTALLED works on my development machine, but it was not invoked on my deployment machine until I changed target virtual directory. Mistery ???

Intermittent WebException "The remote name could not be resolved" -try a few times.

I've noticed that one of web services, that I am using sometimes(usually at the first attempt) returns WebException "The remote name could not be resolved".
I've desided to include re-try code in my call and it made my application more reliable:

                // I beleive that it's a good idea to re-try in case of "The remote name could not be resolved"

                for (int i = 0; i < 3; i++)

                {

                    try

                    {   //call web service

                        ds = ReadRssUrlAsDataSet(timeStart, url);

                        break;

                    }

                    catch (WebException exc)

                    {

                        if (exc.Message.Contains("The remote name could not be resolved"))

                        {  DebugHelper.TracedLine("Attempt " + i.ToString() + " failed." +exc.Message);

                            continue;//try 3 times

                        }

                        throw;

                    }

                }

How to open web.config file from custom action installer class, located in DLL.

One of the readers of the my post "Using VS 2005 Web Setup Project with custom actions" asked how to pick web.config file. that is actually part of the web project, from custom action installer class located in a separate DLL.

 With an assumption that DLL with installer class located in the BIN folder of the web project , you can do the following:

Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim sConfigFileName As String FSHelperLib.AppSettingsHelper.GetConfigFileName(asm)

where  

        public static string GetConfigFileName(Assembly ExecutingAssembly)

        {

            string sPath = "";

            { //root folder one level up from bin

                sPath = SystemHelper.GetWebRootFolder(ExecutingAssembly);

                sPath = sPath + @"\web.config";

}

            if (!File.Exists(sPath))

            {

                throw new FileNotFoundException("Missing config file " + sPath);

            }

            return sPath;

        }

 See also My SystemHelper class for GetWebRootFolder definition.

 

«August»
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789