Skip to content

Commit c841b36

Browse files
committed
Add feature parameter to dotnet::install::feature
This will allow specification of different feature names. Necessary specifically because the feature name to install .NET 3.5 on Server 2012 is not the same feature as to install 4.5. The feature name for .NET 3.5 in Server 2012 is not AS-NET-Framework, which we use as the default feature. This commit also updates the dotnet type to attempt installation of the correct feature when 3.5 is specified on Server 2012.
1 parent 0ec9c73 commit c841b36

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ Ensures the state of .net on the system. Present or Absent.
6161
The version of .net that you want to be managed by this definition.
6262

6363
#####`package_dir`
64-
If installing .NET from a directory or a mounted network location then this is that directory
64+
If installing .NET from a directory or a mounted network location then this is
65+
that directory. If the version of .NET being installed is a Windows feature, it
66+
may sometimes be necessary to specify package\_dir as the path to installation
67+
media, such as `D:\sources\sxs`.
6568

6669
##Reference
6770

manifests/init.pp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939

4040
Variant[String, Undef]
4141
$package_dir = undef,
42-
43-
Variant[String, Undef]
44-
$source = undef,
4542
) {
4643

4744
include dotnet::params
@@ -55,7 +52,11 @@
5552
case $version {
5653
'3.5': {
5754
case $windows_version {
58-
'2008 R2', /^2012/: { $type = 'feature' }
55+
/^2012/: {
56+
$type = 'feature'
57+
$feature = 'NET-Framework-Features'
58+
}
59+
'2008 R2': { $type = 'feature' }
5960
'7', '8', '8.1': { $type = 'dism' }
6061
/^2003/, '2008', 'XP', 'Vista': { $type = 'package' }
6162
default: { $type = 'err' }
@@ -96,6 +97,8 @@
9697
dotnet::install::feature { "dotnet-feature-${version}":
9798
ensure => $ensure,
9899
version => $version,
100+
feature => $feature,
101+
source => $package_dir,
99102
}
100103
}
101104
'dism': {

manifests/install/feature.pp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
#
22
define dotnet::install::feature(
3+
$version,
34
$ensure = 'present',
4-
$version = '',
5+
$feature = 'AS-NET-Framework',
6+
$source = undef,
57
) {
68

9+
$source_flag = $source ? {
10+
undef => '',
11+
default => "-source ${source}",
12+
}
13+
714
if $ensure == 'present' {
815
exec { "install-dotnet-feature-${version}":
9-
command => 'Import-Module ServerManager; Add-WindowsFeature as-net-framework',
16+
command => "Import-Module ServerManager; Add-WindowsFeature ${feature} ${source_flag}",
1017
provider => powershell,
1118
logoutput => true,
1219
creates => "C:/Windows/Microsoft.NET/Framework/v${version}",
1320
}
1421
} else {
1522
exec { "uninstall-dotnet-feature-${version}":
16-
command => 'Import-Module ServerManager; Remove-WindowsFeature as-net-framework',
23+
command => "Import-Module ServerManager; Remove-WindowsFeature ${feature}",
1724
provider => powershell,
1825
logoutput => true,
1926
onlyif => "If (-Not(Test-Path C:/Windows/Microsoft.NET/Framework/v${version})) { Exit 1 }",

0 commit comments

Comments
 (0)