public static string[] ToSetupArguments(this Microsoft.Deployment.WindowsInstaller.Session session) { if (session == null) { return new string[] { } } ; if (CachedSetupArguments != null) { return(CachedSetupArguments); } lock (_lock) { if (CachedSetupArguments != null) { return(CachedSetupArguments); } var allProperties = InstallationModelArgumentParser.AllArguments; var arguments = new List <string>(); foreach (var p in allProperties) { string v; if (session.TryGetValue(p, out v)) { arguments.Add($"{p}={v}"); } } CachedSetupArguments = arguments.ToArray(); } return(CachedSetupArguments); }