2

I have an old project at work built in Visual Studio 2015 which I'm updating. There are eight text fields in the setup project. They all have names like FOOBAR and QWERTY which are available in ProjectInstaller.cs. If I change the default value for FOOBAR such as bazqux (hard coded default) or [FOOBAR] (passing from the arguments), that gets reflected in ProjectInstaller.cs.

However, if I add a new field, that doesn't get reflected in ProjectInstaller.cs. Also, renaming a field is not reflected.

This is how the setup project is set up:

enter image description here

How do I register a new field name or a name change to a field so I can use the new name in ProjectInstaller.cs?

CJ Dennis
  • 4,226
  • 2
  • 40
  • 69

1 Answers1

1

I found an article here that gave me the clues to find the settings in VS2015: https://www.codeproject.com/articles/12780/a-setup-and-deployment-project-that-passes-paramet

  1. In Solution Explorer, select the <My_Project>_Setup project

  2. In the top right corner of Solution Explorer, press the icon for "Custom Actions Editor"

    Custom Actions Editor

  3. In Custom Actions (<My_Project>_Setup) immediately below "Commit", select "Primary output from <My_Project> (Active)"

    enter image description here

  4. In Properties, edit the value for "CustomDataAction", matching the field names to the command arguments. The format is /ARGUMENT="[FIELDNAME]", so the arguments and fields do not have to have the same names. Each pair of argument and field names are separated from the next pair with a single space.

    enter image description here

Some gotchas:

  • The field values are not escaped before being inserted, so a trailing backslash \ in a field value will most likely cause the installer to fail due to not being able to parse the arguments correctly.
  • Argument insertion is made possible by knowing the format of the arguments. E.g. inputting foobar" /QWERTY="This is bad! (no starting or trailing double quote) in a field during the installation process will insert a new argument called QWERTY with the value This is bad!.
  • Arguments to the installer can also be injected in this manner.
  • Arguments to the .msi file are passed through the installer fields (and possibly edited by the user) before being passed to the installer. E.g. My_Project_Setup.msi FOO=42 [Edit1Property: BAR, Edit1Value: [FOO]], [CustomDataAction: /BAZ="[BAR]"] will pass 42 (assuming the user didn't change it) in the argument BAZ which would then be used in Context.Parameters["BAZ"] in ProjectInstaller.cs.
CJ Dennis
  • 4,226
  • 2
  • 40
  • 69