Skip to content

Commit 4153772

Browse files
author
zappy-shu
committed
adding documentation, fixing lint issues, defaulting to ensure=present, and fix onlyif script for removal so it only runs if the assembly to remove is currently installed into the GAC
1 parent 539d1c1 commit 4153772

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

manifests/gacassembly.pp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1+
# windowsgac::gacassembly - use to manage asseblies in the .NET Framework Global Assembly Cache
2+
#
3+
# @author Nick Adcock
4+
#
5+
# @param [present, absent] ensure
6+
#
7+
# @param [String] assemblypath
8+
#
9+
# @example Ensure $assembly installed into the GAC
10+
# class { $assembly: }
11+
#
12+
# @example Ensure $assembly not in the GAC
13+
# class { $assembly:
14+
# ensure => absent
15+
# }
16+
117
define windowsgac::gacassembly (
218
$assemblypath = $name,
3-
$ensure,
19+
$ensure = present,
420
) {
521
$exists_script = sprintf('
622
$full_name = [System.Reflection.AssemblyName]::GetAssemblyName("%s").FullName
@@ -10,27 +26,27 @@
1026
$get_enterprise_services_script = '
1127
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
1228
$publish = New-Object System.EnterpriseServices.Internal.Publish'
13-
29+
1430
if $ensure == present {
1531
$command = sprintf('
1632
%s; $publish.GacInstall("%s")
1733
', $get_enterprise_services_script, $assemblypath)
18-
19-
exec { "GacInstall($assemblypath)":
34+
35+
exec { "GacInstall(${assemblypath})":
2036
provider => powershell,
21-
command => $command,
22-
onlyif => "try { $exists_script; exit 1 } catch { exit 0 }"
23-
}
37+
command => $command,
38+
onlyif => "try { ${exists_script}; exit 1 } catch { exit 0 }",
39+
}
2440
}
2541
else {
2642
$command = sprintf('
2743
%s; $publish.GacRemove("%s")
2844
', $get_enterprise_services_script, $assemblypath)
29-
30-
exec { "GacRemove($assemblypath)":
45+
46+
exec { "GacRemove(${assemblypath})":
3147
provider => powershell,
32-
command => $command,
33-
onlyif => $exists_script
34-
}
48+
command => $command,
49+
onlyif => "try { ${exists_script}; exit 0 } catch { exit 1 }",
50+
}
3551
}
3652
}

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zappyshu-windowsgac",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"author": "Zappy Shu",
55
"summary": "Installs and removes .NET assemblies in the Global Assembly Cache",
66
"license": "Apache-2.0",

0 commit comments

Comments
 (0)