Skip to content

Commit fce92f3

Browse files
committed
restarting work on prtgshell2
1 parent fbdaf0b commit fce92f3

16 files changed

+752
-1589
lines changed

.gitignore

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
11+
[Dd]ebug/
12+
[Rr]elease/
13+
x64/
14+
build/
15+
[Bb]in/
16+
[Oo]bj/
17+
18+
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
19+
!packages/*/build/
20+
21+
# MSTest test Results
22+
[Tt]est[Rr]esult*/
23+
[Bb]uild[Ll]og.*
24+
25+
*_i.c
26+
*_p.c
27+
*.ilk
28+
*.meta
29+
*.obj
30+
*.pch
31+
*.pdb
32+
*.pgc
33+
*.pgd
34+
*.rsp
35+
*.sbr
36+
*.tlb
37+
*.tli
38+
*.tlh
39+
*.tmp
40+
*.tmp_proj
41+
*.log
42+
*.vspscc
43+
*.vssscc
44+
.builds
45+
*.pidb
46+
*.log
47+
*.scc
48+
49+
# Visual C++ cache files
50+
ipch/
51+
*.aps
52+
*.ncb
53+
*.opensdf
54+
*.sdf
55+
*.cachefile
56+
57+
# Visual Studio profiler
58+
*.psess
59+
*.vsp
60+
*.vspx
61+
62+
# Guidance Automation Toolkit
63+
*.gpState
64+
65+
# ReSharper is a .NET coding add-in
66+
_ReSharper*/
67+
*.[Rr]e[Ss]harper
68+
69+
# TeamCity is a build add-in
70+
_TeamCity*
71+
72+
# DotCover is a Code Coverage Tool
73+
*.dotCover
74+
75+
# NCrunch
76+
*.ncrunch*
77+
.*crunch*.local.xml
78+
79+
# Installshield output folder
80+
[Ee]xpress/
81+
82+
# DocProject is a documentation generator add-in
83+
DocProject/buildhelp/
84+
DocProject/Help/*.HxT
85+
DocProject/Help/*.HxC
86+
DocProject/Help/*.hhc
87+
DocProject/Help/*.hhk
88+
DocProject/Help/*.hhp
89+
DocProject/Help/Html2
90+
DocProject/Help/html
91+
92+
# Click-Once directory
93+
publish/
94+
95+
# Publish Web Output
96+
*.Publish.xml
97+
98+
# NuGet Packages Directory
99+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
100+
#packages/
101+
102+
# Windows Azure Build Output
103+
csx
104+
*.build.csdef
105+
106+
# Windows Store app package directory
107+
AppPackages/
108+
109+
# Others
110+
sql/
111+
*.Cache
112+
ClientBin/
113+
[Ss]tyle[Cc]op.*
114+
~$*
115+
*~
116+
*.dbmdl
117+
*.[Pp]ublish.xml
118+
*.pfx
119+
*.publishsettings
120+
121+
# RIA/Silverlight projects
122+
Generated_Code/
123+
124+
# Backup & report files from converting an old project file to a newer
125+
# Visual Studio version. Backup files are not needed, because we have git ;-)
126+
_UpgradeReport_Files/
127+
Backup*/
128+
UpgradeLog*.XML
129+
UpgradeLog*.htm
130+
131+
# SQL Server files
132+
App_Data/*.mdf
133+
App_Data/*.ldf
134+
135+
136+
#LightSwitch generated files
137+
GeneratedArtifacts/
138+
_Pvt_Extensions/
139+
ModelManifest.xml
140+
141+
# =========================
142+
# Windows detritus
143+
# =========================
144+
145+
# Windows image file caches
146+
Thumbs.db
147+
ehthumbs.db
148+
149+
# Folder config file
150+
Desktop.ini
151+
152+
# Recycle Bin used on file shares
153+
$RECYCLE.BIN/
154+
155+
# Mac desktop service store files
156+
.DS_Store
157+
158+
# testing file (has creds in it)
159+
testing.ps1

buildmodule.ps1

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
[CmdletBinding()]
2+
Param (
3+
[Parameter(Mandatory=$False,Position=0)]
4+
[switch]$PushToStrap
5+
)
6+
7+
function ZipFiles {
8+
[CmdletBinding()]
9+
Param (
10+
[Parameter(Mandatory=$True,Position=0)]
11+
[string]$ZipFilePath,
12+
13+
[Parameter(ParameterSetName="Directory",Mandatory=$True,Position=1)]
14+
[string]$SourceDir,
15+
16+
[Parameter(ParameterSetName="Files",Mandatory=$True,Position=1)]
17+
[Array]$SourceFiles,
18+
19+
[Parameter(Mandatory=$False)]
20+
[switch]$Force
21+
22+
)
23+
Add-Type -Assembly System.IO.Compression.FileSystem
24+
$CompressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
25+
26+
if (Test-Path $ZipFilePath) {
27+
if ($Force) {
28+
$Delete = Remove-Item $ZipFilePath
29+
} else {
30+
Throw "$ZipFilePath exists, use -Force to replace"
31+
}
32+
}
33+
34+
if ($SourceFiles) {
35+
$TempZipFolder = 'newzip'
36+
$TempZipFullPath = "$($env:temp)\$TempZipFolder"
37+
$CreateFolder = New-Item -Path $env:temp -Name $TempZipFolder -ItemType Directory
38+
$Copy = Copy-Item $SourceFiles -Destination $TempZipFullPath
39+
$SourceDir = $TempZipFullPath
40+
}
41+
42+
[System.IO.Compression.ZipFile]::CreateFromDirectory($SourceDir,$ZipFilePath, $CompressionLevel, $false)
43+
44+
$Cleanup = Remove-Item $TempZipFullPath -Recurse
45+
}
46+
47+
48+
$ScriptPath = Split-Path $($MyInvocation.MyCommand).Path
49+
$ModuleName = Split-Path $ScriptPath -Leaf
50+
51+
$SourceDirectory = "src"
52+
$SourcePath = $ScriptPath + "\" + $SourceDirectory
53+
$CmdletPath = $SourcePath + "\" + "cmdlets"
54+
$HelperPath = $SourcePath + "\" + "helpers"
55+
$CsPath = $SourcePath + "\" + "cs"
56+
$OutputFile = $ScriptPath + "\" + "$ModuleName.psm1"
57+
$ManifestFile = $ScriptPath + "\" + "$ModuleName.psd1"
58+
$DllFile = $ScriptPath + "\" + "$ModuleName.dll"
59+
$CsOutputFile = $ScriptPath + "\" + "$ModuleName.cs"
60+
61+
###############################################################################
62+
# Create Manifest
63+
$ManifestParams = @{ Path = $ManifestFile
64+
ModuleVersion = '1.0'
65+
RequiredAssemblies = @("$ModuleName.dll")
66+
Author = 'Brian Addicks'
67+
RootModule = "$ModuleName.psm1"
68+
PowerShellVersion = '4.0'
69+
RequiredModules = @()}
70+
71+
New-ModuleManifest @ManifestParams
72+
73+
###############################################################################
74+
#
75+
76+
$CmdletHeader = @'
77+
###############################################################################
78+
## Start Powershell Cmdlets
79+
###############################################################################
80+
81+
82+
'@
83+
84+
$HelperFunctionHeader = @'
85+
###############################################################################
86+
## Start Helper Functions
87+
###############################################################################
88+
89+
90+
'@
91+
92+
$Footer = @'
93+
###############################################################################
94+
## Export Cmdlets
95+
###############################################################################
96+
97+
Export-ModuleMember *-*
98+
'@
99+
100+
$FunctionHeader = @'
101+
###############################################################################
102+
#
103+
'@
104+
105+
###############################################################################
106+
# Start Output
107+
108+
$CsOutput = ""
109+
110+
###############################################################################
111+
# Add C-Sharp
112+
113+
$AssemblyRx = [regex] '^using\ .+?;'
114+
$NameSpaceStartRx = [regex] "namespace $ModuleName {"
115+
$NameSpaceStopRx = [regex] '^}$'
116+
117+
$Assemblies = @()
118+
$CSharpContent = @()
119+
120+
$c = 0
121+
foreach ($f in $(ls $CsPath)) {
122+
foreach ($l in (gc $f.FullName)) {
123+
$AssemblyMatch = $AssemblyRx.Match($l)
124+
$NameSpaceStartMatch = $NameSpaceStartRx.Match($l)
125+
$NameSpaceStopMatch = $NameSpaceStopRx.Match($l)
126+
127+
if ($AssemblyMatch.Success) {
128+
$Assemblies += $l
129+
continue
130+
}
131+
132+
if ($NameSpaceStartMatch.Success) {
133+
$AddContent = $true
134+
continue
135+
}
136+
137+
if ($NameSpaceStopMatch.Success) {
138+
$AddContent = $false
139+
continue
140+
}
141+
142+
if ($AddContent) {
143+
$CSharpContent += $l
144+
}
145+
}
146+
}
147+
148+
#$Assemblies | Select -Unique | sort -Descending
149+
150+
$CSharpOutput = $Assemblies | Select -Unique | sort -Descending
151+
$CSharpOutput += "namespace $ModuleName {"
152+
$CSharpOutput += $CSharpContent
153+
$CSharpOutput += '}'
154+
155+
$CsOutput += [string]::join("`n",$CSharpOutput)
156+
$CsOutput | Out-File $CsOutputFile -Force
157+
158+
159+
Add-Type -ReferencedAssemblies @(
160+
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml")).Location,
161+
([System.Reflection.Assembly]::LoadWithPartialName("System.Web")).Location,
162+
([System.Reflection.Assembly]::LoadWithPartialName("System.Xml.Linq")).Location
163+
) -OutputAssembly $DllFile -OutputType Library -TypeDefinition $CsOutput
164+
165+
###############################################################################
166+
# Add Cmdlets
167+
168+
$Output = $CmdletHeader
169+
170+
foreach ($l in $(ls $CmdletPath)) {
171+
$Contents = gc $l.FullName
172+
Write-Verbose $l.FullName
173+
$Output += $FunctionHeader
174+
$Output += $l.BaseName
175+
$Output += "`r`n`r`n"
176+
$Output += [string]::join("`n",$Contents)
177+
$Output += "`r`n`r`n"
178+
}
179+
180+
181+
###############################################################################
182+
# Add Helpers
183+
184+
$Output += $HelperFunctionHeader
185+
186+
foreach ($l in $(ls $HelperPath)) {
187+
$Contents = gc $l.FullName
188+
$Output += $FunctionHeader
189+
$Output += $l.BaseName
190+
$Output += "`r`n`r`n"
191+
$Output += [string]::join("`n",$Contents)
192+
$Output += "`r`n`r`n"
193+
}
194+
195+
###############################################################################
196+
# Add Footer
197+
198+
$Output += $Footer
199+
200+
###############################################################################
201+
# Output File
202+
203+
$Output | Out-File $OutputFile -Force
204+
205+
if ($PushToStrap) {
206+
$FilesToZip = ls "$PSScriptRoot\$ModuleName*" -Exclude *.zip
207+
$CreateZip = ZipFiles -ZipFilePath "$PSScriptRoot\$ModuleName.zip" -SourceFiles $FilesToZip -Force
208+
$StageFolder = "\\vmware-host\Shared Folders\Dropbox (Personal)\strap\stages\$ModuleName\"
209+
$Copy = Copy-Item "$PSScriptRoot\$ModuleName.zip" $StageFolder -Force
210+
}

0 commit comments

Comments
 (0)