-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for --Installer-Type
argument for commands
#3516
Conversation
|
||
bool ContainsInstallerType(const std::vector<InstallerTypeEnum>& selection, InstallerTypeEnum installerType) | ||
{ | ||
return std::find(selection.begin(), selection.end(), installerType) != selection.end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, thinking more about this, I wonder if it would make sense to have a templated utility function for checking if an object is contained within a container.
Although, considering that this PR is required for 1.6, it might make sense not to create a utility function.
I'm thinking something like this might work, but I'm not certain
template <template<typename, typename> typename Container, typename Allocator, typename Value>
bool ContainsObject(Container<Value, Allocator> container, Value value) {
return std::find(container.begin(), container.end(), value) != container.end();
}
"portable" | ||
], | ||
"minItems": 1, | ||
"maxItems": 9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I don't see much point in having maxItems
set to n-1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the other settings arrays declare a maxItems so I followed it just to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird but ok, Anyway this settings schema is not used in code for enforcement, it's just informational only for now.
"inno", | ||
"wix", | ||
"msi", | ||
"nullsoft", | ||
"zip", | ||
"msix", | ||
"exe", | ||
"burn", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a user really care about whether something is an msi or an msi made with some-tool?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this essentially mean that we would need an "InstallerTechnologyType" for each Installer? Effectively reducing it to portable, exe, msi, msix, and msstore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's what I'm suggesting. But I don't know if it would be a good idea. I don't think most people would care about the difference between a wix and an msi installer, but for people who do care I think it would be confusing if the set of types here is different than in the manifest.
@@ -140,6 +140,18 @@ The `architectures` behavior affects what architectures will be selected when in | |||
}, | |||
``` | |||
|
|||
### Installer Types | |||
|
|||
The `installerTypes` behavior affects what installer types will be selected when installing a package. The matching parameter is `--installer-type`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this work for scenarios like "zip containing exe" or "exe that installs an msi"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zip uses the EffectiveInstallerType, but that brings up a good point - if someone has {zip, exe}
as their preferences, because the check is against both base and effective type, a zip->msi could still be chosen even if a zip->exe exists
And another great point about the exe that installs an msi or msix; AppsAndFeaturesEntries->InstallerType might need to be considered
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For zip containing exe, I check both the baseInstallerType (for zip) and effective installer type to determine if an installer satisfies the preference/requirement so I believe that scenario is covered. I didn't do anything different for "exe that installs an msi" as I only consider what is shown in the manifest
"wix", | ||
"msi", | ||
"nullsoft", | ||
"zip", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is zip an installer type users would care about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it will be a common scenario, but it should still be supported if people prefer that installer type.
Manifest::InstallerTypeEnum installerType = Manifest::ConvertToInstallerTypeEnum(i); | ||
if (installerType == Manifest::InstallerTypeEnum::Unknown) | ||
{ | ||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to just skip the ones that are not valid instead of dropping everything? That way, if in future versions we add new installer types, people could use those same settings files on this version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I basically followed how we validate the other settings (like Architecture preference that drop if there is an invalid value) so I left it as is because I don't think installer type should behave any differently.
@@ -196,5 +202,24 @@ public static void InitializeAllFeatures(bool status) | |||
ConfigureFeature("windowsFeature", status); | |||
ConfigureFeature("download", status); | |||
} | |||
|
|||
private static JObject GetJsonSettingsObject(string objectName, string propertyName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this function do?
It seems like it parses the settings file, then adds an object with a single empty property?
That is weird to me, and the method name doesn't help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about something like
private static JObject GetJsonSettingsObjectAndCreateEmptyProperty(string[] propertyPath...)
{
JObject settingsJson = JObject.Parse(File.ReadAllText(TestSetup.Parameters.SettingsJsonFilePath));
var currentNode = settings.Json;
foreach (var key in propertyPath)
{
if (!currentNode.ContainsKey(key))
{
currentNode[key] = new JObject();
}
currentNode = currentNode[key];
}
return settingsJson;
}
(Not sure if this even compiles...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the helper method to be a little more generic so that it only returns the json settings object that you specify and doesn't do anything with creating a single empty property (which I also agree is kind of weird).
"portable" | ||
], | ||
"minItems": 1, | ||
"maxItems": 9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird but ok, Anyway this settings schema is not used in code for enforcement, it's just informational only for now.
} | ||
|
||
bool ContainsInstallerType(const std::vector<InstallerTypeEnum>& selection, InstallerTypeEnum installerType) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move to private
ContainsInstallerType(m_preference, second.EffectiveInstallerType()) || | ||
ContainsInstallerType(m_preference, second.BaseInstallerType); | ||
|
||
if (isFirstInstallerTypePreferred == isSecondInstallerTypePreferred) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit torn about whether making the preference ordered vs unordered. Making it unordered will limit the user's ability to prefer a specific installer type over another and all other preferences are ordered. Making it ordered seems too strong for installer type though. maybe a middle ground will be making it ordered and put this comparator in the last on line 765 so it's not that significant in the end (btw, putting the comparator to last should be done regardless of whether we decide it ordered or unordered)
Resolves #1166
Changes:
--installer-type
argument to the Install, Upgrade, and Show command.Tests:
Microsoft Reviewers: codeflow:open?pullrequest=#3516