Skip to content
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

Visual Studio 2017 and network installs #11

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
169837f
If resource source is set to nil then assume that we are doing a netw…
taliesins Apr 25, 2017
508333f
Only throw an exception when src is nil if we have not specified an i…
Apr 25, 2017
3ab9f46
Chef windows_package uses returns instead of success_code
Apr 25, 2017
cd15ecd
Comparing values. Not setting them.
Apr 25, 2017
8946cbf
If a value is nil or empty we should consider it to be overridden and…
Apr 25, 2017
f01608a
Use empty? rather
Apr 25, 2017
be9be71
source attribute is now optional
Apr 25, 2017
959d08d
replace empty with blank
Apr 25, 2017
acff8a4
remove blank
Apr 25, 2017
291c331
Make it a function
Apr 25, 2017
d8fe130
Add Visual Studio 2017
Apr 26, 2017
623e5c7
Better to use casecmp instead of downcase ==
Apr 27, 2017
a96ccea
Source is a required parameter, so only evaluate when we know its not…
Apr 27, 2017
5e74354
Use preferred ruby style for checking if nil
Apr 27, 2017
0dcb25d
Property does not exist (copied over from seven_zip extract)
Apr 27, 2017
ac05ea9
Use empty instead of blank
Apr 27, 2017
f0589bf
Display whats going on for debug purposes
Apr 27, 2017
a9af16a
Deal with the following installation options:
Apr 28, 2017
6905bdd
Takes a long time, lets see what the progress is
Apr 28, 2017
e0c2a03
At the moment Visual Studio is waiting on user input if its run from …
Apr 28, 2017
aaeb2d9
Just enumerate attributes directly.
May 2, 2017
a595002
Added missing square bracket
May 2, 2017
19bd9d7
Update documentation for Visual Studio 2017 and network installs
May 2, 2017
93ac50d
Rubocop suggestions
May 2, 2017
bd0ee84
More rubocop suggestions
May 2, 2017
4533909
Ignores rubocop BlockLength cop for all spec and attributes files
ryangribble Jul 14, 2017
45f0a1b
Ignores rubocop BlockLength cop for action and converge_by methods
ryangribble Jul 14, 2017
16e5207
Fixes LineLength violation
ryangribble Jul 14, 2017
cee77c9
Fixes LineLength violation
ryangribble Jul 14, 2017
84eb80b
Fixes cyclomatic complexity violation by splitting prepare_vs2017_opt…
ryangribble Jul 14, 2017
be4bb97
Fixes Gemfile ordering violation
ryangribble Jul 14, 2017
3d93400
Merge pull request #1 from TattsGroup/NetworkInstall
taliesins Aug 9, 2017
757149c
Fix lint suggestions
Aug 10, 2017
ecbaeae
Add support for updates via network share
Aug 10, 2017
60baa38
if we are specifying a blackslash or forward slash we are point to a …
Aug 11, 2017
e98dbd0
These references are not used
Aug 11, 2017
92e52a5
Handle empty string and nil strings
Aug 14, 2017
155b178
Fixed RuboCop errors.
bemehiser Aug 15, 2017
0b3eb7c
Merge pull request #2 from bemehiser/NetworkInstall
taliesins Aug 16, 2017
e9ac772
array literals should use round brackets
taliesins Aug 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,11 @@ Metrics/LineLength:

Metrics/AbcSize:
Max: 25

Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
- 'attributes/**/*.rb'
ExcludedMethods:
- action
- converge_by
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

source 'http://rubygems.org'

gem 'berkshelf'
gem 'chef'
gem 'chefspec'
gem 'foodcritic'
gem 'rake'
gem 'rspec'
gem 'rspec-core'
gem 'rspec-expectations'
gem 'rspec-mocks'
gem 'chef'
gem 'foodcritic'
gem 'rubocop'
gem 'rake'
gem 'berkshelf'
gem 'stove'
47 changes: 41 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
[![Build status](https://ci.appveyor.com/api/projects/status/ttumjhmmxjo5j7gv/branch/master?svg=true)](https://ci.appveyor.com/project/ChefWindowsCookbooks65871/visualstudio/branch/master)

# VisualStudio Cookbook
This Chef cookbook installs Visual Studio 2010, 2012, 2013, 2015 from an ISO.
This Chef cookbook installs Visual Studio 2010, 2012, 2013, 2015, 2017 from an ISO or folder/network location.

# Requirements

This cookbook assumes the appropriate version of the .NET framework has already been installed before running the VisualStudio cookbook. To install .NET you can use the [dotnetframework cookbook](https://supermarket.chef.io/cookbooks/dotnetframework). You must reboot the system after the .NET installation and before the VisualStudio installation.

- VisualStudio 2010, 2012, and 2013 require .NET 4.5.x.
- VisualStudio 2015 requires .NET 4.6.
- VisualStudio 2015, 2017 requires .NET 4.6.

This cookbook requires 7-zip to be installed so it can extract the ISO. To ensure this happens this cookbook includes the [seven_zip](https://supermarket.chef.io/cookbooks/seven_zip) default recipe.

Expand All @@ -30,6 +30,10 @@ NOTE - This cookbook cannot be installed over naked WinRM, i.e. knife-winrm with
- 2015 Professional
- 2015 Test Professional
- 2015 Community
- 2017 Enterprise
- 2017 Professional
- 2017 Test Professional
- 2017 Community

## Supported OSs
- Windows 7
Expand Down Expand Up @@ -87,7 +91,7 @@ If you _really_ want to install VS 2015 on Windows Server 2012R2 over naked WinR
<tr>
<td><code>['visualstudio']['version']</code></td>
<td>Integer</td>
<td>The VisualStudio version to install, i.e. 2010, 2012, 2013, 2015.</td>
<td>The VisualStudio version to install, i.e. 2010, 2012, 2013, 2015, 2017.</td>
<td><code>2015</code></td>
</tr>
<tr>
Expand Down Expand Up @@ -118,7 +122,7 @@ If you _really_ want to install VS 2015 on Windows Server 2012R2 over naked WinR

# Usage

Add `'visualstudio::default'` to your runlist. This will install VS 2015 Community Edition from the publicly available ISO. If you'd like to install another edition set the 'edition' attribute to: 'community', 'professional', 'premium', or 'testprofessional'. If you'd like to install a different version set the 'version' attribute to: '2010', '2012', '2013', '2015'.
Add `'visualstudio::default'` to your runlist. This will install VS 2015 Community Edition from the publicly available ISO. If you'd like to install another edition set the 'edition' attribute to: 'community', 'professional', 'premium', or 'testprofessional'. If you'd like to install a different version set the 'version' attribute to: '2010', '2012', '2013', '2015', '2017'.

If you need to install multiple different versions/editions of VisualStudio on the same node you must instead set the 'installs' attribute. If the installs attribute is set then the version and edition attributes are ignored.

Expand All @@ -142,10 +146,41 @@ node.override['visualstudio']['2013']['professional']['source'] = 'https://myart

VisualStudio 2013 and newer have default public download links for all their ISOs. If you're using an older version (2010, 2012) you must first set a download source. Either set the global `node['visualstudio']['source']` download URL or the version/edition specific download source, e.g. `node['visualstudio']['2012']['professional']['source']`. You can also use these same attributes to override the ISO location for newer VS versions.

VisualStudio 2017 does not have an ISO installer. You have to use web installer. For faster installs you can cache the Visual Studio installation files on a network share using the offline install cache.

To run an installation from a network share, set the following:

```ruby
node.override['visualstudio']['version'] = '2017'
node.override['visualstudio']['edition'] = 'professional'
node.override['visualstudio']['source'] = ''
node.override['visualstudio']['2017']['professional']['default_source'] = ''
node.override['visualstudio']['2017']['professional']['source'] = ''
node.override['visualstudio']['2017']['professional']['filename'] = ''
node.override['visualstudio']['2017']['professional']['checksum'] = nil
node.override['visualstudio']['2017']['professional']['installer_file'] = '//myartifactrepo/visualstudio/vs_professional.exe'
```

## Customizing Installed Features
### VS 2012 and Newer
### VS 2017 or newer

To customize the command line install options for adding workloads for an unattended install in Visual Studio 2017 or newer edit the node attribute `node['visualstudio']['2017']['professional']['default_install_items']`
adding the 'id' of the workload you want to install. The attribute 'Selected' can be set to a boolean value.

For example:
`node['visualstudio']['2017']['professional']['default_install_items']['Microsoft.VisualStudio.Workload.CoreEditor']['selected']= true`

There are also 4 additional command line arguments that can be set:
```ruby
node.override['visualstudio']['2017']['all'] = true
node.override['visualstudio']['2017']['allWorkloads'] = true
node.override['visualstudio']['2017']['includeRecommended'] = true
node.override['visualstudio']['2017']['includeOptional'] = true
```

### VS 2012 to VS 2015

To customize the AdminDeployment.xml file for adding features to an unattended install in VisualStudio 2012 and newer edit the node attribute `node['visualstudio']['install_items']`
To customize the AdminDeployment.xml file for adding features to an unattended install in VisualStudio 2012 to Visual Studio 2015 edit the node attribute `node['visualstudio']['install_items']`
adding the 'id' of the `<SelectableItemCustomization>` you want to install, it's 'Selected', 'Hidden', and 'FriendlyName' can then be set assuming the item has the attribute(s).

For example:
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require 'foodcritic'
require 'rspec/core/rake_task'
require 'stove/rake_task'

task default: [:rubocop, :foodcritic, :spec]
task default: %i(rubocop foodcritic spec)

FoodCritic::Rake::LintTask.new do |t|
t.options = {
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ clone_depth: 1
install:
- ps: net user /add $env:winrm_user $env:winrm_pass
- ps: net localgroup administrators $env:winrm_user /add
- ps: Invoke-WebRequest -Uri https://packages.chef.io/stable/windows/2008r2/chefdk-0.17.17-1-x86.msi -OutFile c:\projects\chefdk.msi
- ps: Invoke-WebRequest -Uri https://packages.chef.io/files/stable/chefdk/2.0.28/windows/2016/chefdk-2.0.28-1-x86.msi -OutFile c:\projects\chefdk.msi
- ps: Start-Process C:\Windows\System32\msiexec.exe -ArgumentList "/qb /i c:\projects\chefdk.msi" -wait
- ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
- bundle config --local path c:\projects\bundle
Expand Down
1 change: 1 addition & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@
include_attribute 'visualstudio::vs2012'
include_attribute 'visualstudio::vs2013'
include_attribute 'visualstudio::vs2015'
include_attribute 'visualstudio::vs2017'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant, the chef-client run merges all files in the attributes folder anyway.

1 change: 1 addition & 0 deletions attributes/vs2010.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@
'Microsoft Visual Studio 2010 Service Pack 1'
default['visualstudio']['2010']['update']['default_source'] =
'http://download.microsoft.com/download/E/B/A/EBA0A152-F426-47E6-9E3F-EFB686E3CA20'
default['visualstudio']['2010']['update']['installer_file'] = nil
1 change: 1 addition & 0 deletions attributes/vs2012.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
'Visual Studio 2012 Update 5 (KB2707250)'
default['visualstudio']['2012']['update']['default_source'] =
'https://download.microsoft.com/download/1/7/A/17A8493D-BB25-4811-8242-CCCB74EF982E'
default['visualstudio']['2012']['update']['installer_file'] = nil

# VS 2012 Office developer tools
default['visualstudio']['2012']['vsto']['installer_file'] = 'officetools_bundle.exe'
Expand Down
1 change: 1 addition & 0 deletions attributes/vs2013.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,4 @@
'Visual Studio 2013 Update 5 (KB3021976)'
default['visualstudio']['2013']['update']['default_source'] =
'http://download.microsoft.com/download/A/F/9/AF95E6F8-2E6E-49D0-A48A-8E918D7FD768'
default['visualstudio']['2013']['update']['installer_file'] = nil
153 changes: 153 additions & 0 deletions attributes/vs2017.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@

#
# Author:: Shawn Neal (<[email protected]>)
# Cookbook Name:: visualstudio
# Attribute:: vs2017
#
# Copyright 2015, Shawn Neal
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Currently you cannot change this, doing so will break the cookbook
default['visualstudio']['2017']['install_dir'] =
(ENV['ProgramFiles(x86)'] || 'C:\Program Files (x86)') + '\Microsoft Visual Studio 16.0'
default['visualstudio']['2017']['all'] = false
default['visualstudio']['2017']['allWorkloads'] = false
default['visualstudio']['2017']['includeRecommended'] = true
default['visualstudio']['2017']['includeOptional'] = false

# Test Professional w/Update1 https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-test-professional
default['visualstudio']['2017']['testprofessional']['installer_file'] = 'vs_testprofessional.exe'
default['visualstudio']['2017']['testprofessional']['filename'] = 'vs_testprofessional.exe'
default['visualstudio']['2017']['testprofessional']['package_name'] = 'Microsoft Visual Studio Test Professional 2017'
default['visualstudio']['2017']['testprofessional']['checksum'] = ''
default['visualstudio']['2017']['testprofessional']['default_source'] = 'https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=TestProfessional&rel=15'

# Professional w/Update1
default['visualstudio']['2017']['professional']['installer_file'] = 'vs_professional.exe'
default['visualstudio']['2017']['professional']['filename'] = 'vs_professional.exe'
default['visualstudio']['2017']['professional']['package_name'] = 'Microsoft Visual Studio Professional 2017'
default['visualstudio']['2017']['professional']['checksum'] = ''
default['visualstudio']['2017']['professional']['default_source'] = 'https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Professional&rel=15'

# Defaults for https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-professional
default['visualstudio']['2017']['professional']['default_install_items'].tap do |h|
h['Microsoft.VisualStudio.Workload.CoreEditor']['selected'] = true
h['Microsoft.VisualStudio.Workload.Azure']['selected'] = true
h['Microsoft.VisualStudio.Workload.Data']['selected'] = true
h['Microsoft.VisualStudio.Workload.ManagedDesktop']['selected'] = true
h['Microsoft.VisualStudio.Workload.ManagedGame']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeCrossPlat']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeDesktop']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeGame']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeMobile']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetCoreTools']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetCrossPlat']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetWeb']['selected'] = true
h['Microsoft.VisualStudio.Workload.Node']['selected'] = true
h['Microsoft.VisualStudio.Workload.Office']['selected'] = true
h['Microsoft.VisualStudio.Workload.Universal']['selected'] = true
h['Microsoft.VisualStudio.Workload.VisualStudioExtension']['selected'] = true
h['Microsoft.VisualStudio.Workload.WebCrossPlat']['selected'] = true
h['Component.Android.Emulator']['selected'] = true
h['Component.GitHub.VisualStudio']['selected'] = true
h['Microsoft.Component.Blend.SDK.WPF']['selected'] = true
h['Microsoft.Component.HelpViewer']['selected'] = true
h['Microsoft.Net.Component.3.5.DeveloperTools']['selected'] = true
h['Microsoft.VisualStudio.Component.DependencyValidation.Community']['selected'] = true
h['Microsoft.VisualStudio.Component.LinqToSql']['selected'] = true
h['Microsoft.VisualStudio.Component.Phone.Emulator']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.Core']['selected'] = true
h['Microsoft.VisualStudio.Component.TypeScript.2.0']['selected'] = true
end

# Community w/Update 3
default['visualstudio']['2017']['community']['installer_file'] = 'vs_community.exe'
default['visualstudio']['2017']['community']['filename'] = 'vs_community.exe'
default['visualstudio']['2017']['community']['package_name'] = 'Microsoft Visual Studio Community 2017'
default['visualstudio']['2017']['community']['checksum'] = ''
default['visualstudio']['2017']['community']['default_source'] = 'https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Community&rel=15'

# Defaults for https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community
default['visualstudio']['2017']['community']['default_install_items'].tap do |h|
h['Microsoft.VisualStudio.Workload.CoreEditor']['selected'] = true
h['Microsoft.VisualStudio.Workload.Azure']['selected'] = true
h['Microsoft.VisualStudio.Workload.Data']['selected'] = true
h['Microsoft.VisualStudio.Workload.ManagedDesktop']['selected'] = true
h['Microsoft.VisualStudio.Workload.ManagedGame']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeCrossPlat']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeDesktop']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeGame']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeMobile']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetCoreTools']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetCrossPlat']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetWeb']['selected'] = true
h['Microsoft.VisualStudio.Workload.Node']['selected'] = true
h['Microsoft.VisualStudio.Workload.Office']['selected'] = true
h['Microsoft.VisualStudio.Workload.Universal']['selected'] = true
h['Microsoft.VisualStudio.Workload.VisualStudioExtension']['selected'] = true
h['Microsoft.VisualStudio.Workload.WebCrossPlat']['selected'] = true
h['Component.Android.Emulator']['selected'] = true
h['Component.GitHub.VisualStudio']['selected'] = true
h['Microsoft.Component.Blend.SDK.WPF']['selected'] = true
h['Microsoft.Component.HelpViewer']['selected'] = true
h['Microsoft.Net.Component.3.5.DeveloperTools']['selected'] = true
h['Microsoft.VisualStudio.Component.DependencyValidation.Community']['selected'] = true
h['Microsoft.VisualStudio.Component.LinqToSql']['selected'] = true
h['Microsoft.VisualStudio.Component.Phone.Emulator']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.Core']['selected'] = true
h['Microsoft.VisualStudio.Component.TypeScript.2.0']['selected'] = true
end

# Enterprise w/Update1
default['visualstudio']['2017']['enterprise']['installer_file'] = 'vs_enterprise.exe'
default['visualstudio']['2017']['enterprise']['filename'] = 'vs_enterprise.exe'
default['visualstudio']['2017']['enterprise']['package_name'] = 'Microsoft Visual Studio Enterprise 2017'
default['visualstudio']['2017']['enterprise']['checksum'] = ''
default['visualstudio']['2017']['enterprise']['default_source'] = 'https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=Enterprise&rel=15'

# Defaults for the https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-enterprise
default['visualstudio']['2017']['enterprise']['default_install_items'].tap do |h|
h['Microsoft.VisualStudio.Workload.CoreEditor']['selected'] = true
h['Microsoft.VisualStudio.Workload.Azure']['selected'] = true
h['Microsoft.VisualStudio.Workload.Data']['selected'] = true
h['Microsoft.VisualStudio.Workload.ManagedDesktop']['selected'] = true
h['Microsoft.VisualStudio.Workload.ManagedGame']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeCrossPlat']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeDesktop']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeGame']['selected'] = true
h['Microsoft.VisualStudio.Workload.NativeMobile']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetCoreTools']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetCrossPlat']['selected'] = true
h['Microsoft.VisualStudio.Workload.NetWeb']['selected'] = true
h['Microsoft.VisualStudio.Workload.Node']['selected'] = true
h['Microsoft.VisualStudio.Workload.Office']['selected'] = true
h['Microsoft.VisualStudio.Workload.Universal']['selected'] = true
h['Microsoft.VisualStudio.Workload.VisualStudioExtension']['selected'] = true
h['Microsoft.VisualStudio.Workload.WebCrossPlat']['selected'] = true
h['Component.Android.Emulator']['selected'] = true
h['Component.GitHub.VisualStudio']['selected'] = true
h['Microsoft.Component.Blend.SDK.WPF']['selected'] = true
h['Microsoft.Component.HelpViewer']['selected'] = true
h['Microsoft.Net.Component.3.5.DeveloperTools']['selected'] = true
h['Microsoft.VisualStudio.Component.LinqToSql']['selected'] = true
h['Microsoft.VisualStudio.Component.Phone.Emulator']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.CodedUITest']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.Core']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.FeedbackClient']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.MicrosoftTestManager']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.WebLoadTest']['selected'] = true
h['Microsoft.VisualStudio.Component.TestTools.Core']['selected'] = true
h['Microsoft.VisualStudio.Component.TypeScript.2.0']['selected'] = true
end
24 changes: 16 additions & 8 deletions libraries/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,36 @@ def versions

# Gets the version/edition ISO download URL or raises an error
def source_download_url(version, edition)
url = nil
edition_node = node['visualstudio'][version][edition]
src = iso_source(version, edition)
return url if (src == '' || src.nil?) && (\
edition_node['installer_file'].include?('/') \
|| edition_node['installer_file'].include?('\\') \
)
assert_src_is_not_nil(src, version, edition)
::File.join(src, node['visualstudio'][version][edition]['filename'])
url = ::File.join(src, edition_node['filename']) if src
url
end

private

# Gets the version/edition ISO download root URL
def iso_source(version, edition)
src = node['visualstudio'][version][edition]['default_source']
edition_node = node['visualstudio'][version][edition]

src = edition_node['default_source']
src = node['visualstudio']['source'] if node['visualstudio']['source']
src = node['visualstudio'][version][edition]['source'] if node['visualstudio'][version][edition]['source']
src = edition_node['source'] if edition_node['source']
src
end

# Fails the Chef run if the visualstudio download source is not set
def assert_src_is_not_nil(src, version, edition)
if src.nil?
raise 'The ISO download source is empty! '\
"Set the node['visualstudio']['#{version}']['#{edition}']['source'] " \
'or node[\'visualstudio\'][\'source\'] attribute and run again!'
end
return unless src.nil?
raise 'The ISO download source is empty! '\
"Set the node['visualstudio']['#{version}']['#{edition}']['source'] " \
'or node[\'visualstudio\'][\'source\'] attribute and run again!'
end

def windows_package_is_installed?(package_name)
Expand Down
Loading