ChocolateyPackages
ChocolateyPackages copied to clipboard
Add/modify functions to use the --config paramter of vs_installer
Currently there seems no option to e.g. call vs_installer.exe modify --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional" --config "MyConfig.vsconfig".
This would be a nice addition to use the logging and error handling infrastructure of the module for applying own configurations.
How would you use this functionality in the context of Chocolatey packages? Would you install any of the existing product or workload packages (e.g. visualstudio2022enterprise or visualstudio2022-workload-manageddesktop) with the additional parameter or would you create your own package for applying your customized config?
We use chocolatey in combination with puppet to build developer machines. There is a base installation module for studio, and depending on the type of machine needed, we use additional modules to enrich the installation.
I think you should be able to achieve your goal by crafting a package which would call Add-VisualStudioComponent with a component id which could be applied on all of your machines, such as Microsoft.Component.MSBuild. Then you could install that package passing --installPath and --config via package parameters and they would be forwarded to the VS Installer. Or your package could overwrite the environment variable which normally holds the package parameters passed from Chocolatey ($Env:chocolateyPackageParameters) so that the package would be self-sufficient and not rely on a specific way of installing it. You could even embed the config file in the package.
A rough sketch of the install script of the hypothetical package:
if ($Env:chocolateyPackageParameters -notlike '*--config*')
{
$configPath = Join-Path -Path $Env:ChocolateyPackageFolder -ChildPath MyConfig.vsconfig
$Env:chocolateyPackageParameters = $Env:chocolateyPackageParameters + " --config $configPath"
}
Add-VisualStudioComponent `
-PackageName 'mycompany-vsconfig-flavor1' `
-Component 'Microsoft.Component.MSBuild' `
-VisualStudioYear '2022' `
-Preview $false `
-ApplicableProducts @('Community', 'Professional', 'Enterprise')
Thank you for the ideas. I will try to go this way.
Since version 1.11.0, functions in chocolatey-visualstudio.extension support a new parameter: -DefaultParameterValues <hashtable> (example), which should provide an easier way of achieving this.