Hi
I do this in Windows quite often, but look it as defining the version i want, so I don't check the version in the repository. If the version of installer is not available then there's an in issue so Chef run fails.
I don't think the package_resource is idempotent for version though, so once downloaded - say v 2.0 - if v1.0 is installed you will need to remove it first.
The way we do this is to define 'version' attribute, e.g.
myapp_version = '1.0'
Then during for install recipe, get current version:
current_version = powershell_out("(Get-Childitem -Path `
'HKLM:\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall') | `
Get-ItemProperty | `
where-object {$_.DisplayName -eq 'MyApp'} | `
Select -ExpandProperty DisplayVersion").stdout.chomp
Next, if it is installed and current version is different from desired version, uninstall it:
if is_package_installed?('MyApp') &&
current_version != myapp_version
windows_package 'MyApp' do
options "/L*V \"C:\\Program Files\\MyApp\\MyApp_#{current_version}_uninstall.log\""
installer_type :msi
action :remove
end
end
Finally, use the windows_package again to install the version you do want.
Hope it helps.