-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add PSADT template #16
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||
<?xml version="1.0" encoding="utf-8"?> | ||||||
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. --> | ||||||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||||||
<metadata> | ||||||
<id>psadt-silent.template</id> | ||||||
<version>1.0.0</version> | ||||||
<packageSourceUrl>https://github.com/chocolatey-community/chocolatey-templates/tree/main/src/psadt-silent.template</packageSourceUrl> | ||||||
<owners>Stephen Valdinger, Chocolatey-Community</owners> | ||||||
<title>PSADT Template</title> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
<authors>Stephen Valdinger, The Chocolatey Team,Chocolatey Community Team</authors> | ||||||
<projectUrl>https://github.com/chocolatey-community/chocolatey-templates</projectUrl> | ||||||
<!--<iconUrl>http://rawcdn.githack.com/__REPLACE_YOUR_REPO__/master/icons/psadt-silent.template.png</iconUrl>--> | ||||||
<copyright>Chocolatey Community Team 2023-present</copyright> | ||||||
<licenseUrl>https://raw.githubusercontent.com/chocolatey-community/chocolatey-templates/main/LICENSE</licenseUrl> | ||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||||||
<projectSourceUrl>https://github.com/chocolatey-community/chocolatey-templates</projectSourceUrl> | ||||||
<bugTrackerUrl>https://github.com/chocolatey-community/chocolatey-templates/issues</bugTrackerUrl> | ||||||
<tags>psadt-silent.template SPACE_SEPARATED</tags> | ||||||
<summary>PSADT Chocolatey Template</summary> | ||||||
<description>### Chocolatey PSADT Template | ||||||
This adds a template for PSADT applications | ||||||
|
||||||
</description> | ||||||
<releaseNotes> | ||||||
### 1.0.0 | ||||||
|
||||||
initial | ||||||
</releaseNotes> | ||||||
</metadata> | ||||||
<files> | ||||||
<!-- this section controls what actually gets packaged into the Chocolatey package --> | ||||||
<file src="templates\**" target="templates" /> | ||||||
</files> | ||||||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Do not remove this test for UTF-8: if “Ω” doesn’t appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. --> | ||
|
||
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd"> | ||
<metadata> | ||
<id>[[PackageNameLower]]</id> | ||
<version>[[PackageVersion]]</version> | ||
<title>[[Software]] (Install)</title> | ||
<authors>UpdateAuthorHere</authors> | ||
<!-- copyright is usually years and software vendor, but not required for internal feeds --> | ||
<copyright>2023 CompanyName</copyright> | ||
<tags>[[Software]] psadt</tags> | ||
<summary>Installs [[Software]] via PSADT interactively</summary> | ||
<description> | ||
Uses existing PSADT framework to install [[Software]] via Chocolatey | ||
</description> | ||
</metadata> | ||
<!-- this section controls what actually gets packaged into the Chocolatey package --> | ||
<files> | ||
<file src="tools\**" target="tools" /> | ||
</files> | ||
</package> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
$ErrorActionPreference = 'Stop' # stop on all errors | ||
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
$zipArchive = Join-Path $toolsDir -ChildPath '[[Zip]]' | ||
$destination = (Join-Path $toolsDir -ChildPath $env:ChocolateyPackageName) | ||
|
||
Get-ChocolateyUnzip -FileFullPath $zipArchive -Destination $destination | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the zip archive is embedded, it is probably best to include the license and verification template files. |
||
|
||
$adtFolder = 'AppDeployToolkit' | ||
$modulePath = Join-Path $destination -ChildPath "$adtFolder" | ||
$module = Join-Path $modulePath -ChildPath 'AppDeployToolkitMain.ps1' | ||
. $module | ||
$adtExe = Join-Path $destination -ChildPath "Deploy-Application.exe" | ||
$deployScript = Join-Path $destination -ChildPath 'Deploy-Application.ps1' | ||
|
||
try { | ||
$packageArgs = @{ | ||
packagename = $env:ChocolateyPackageName | ||
filetype = 'exe' | ||
file = $adtExe | ||
silentArgs = "-DeploymentType 'Install' -DeployMode 'Silent'" | ||
validExitCodes = @(0) | ||
softwareName = '[[Software]]*' | ||
} | ||
|
||
Install-ChocolateyInstallPackage @packageArgs | ||
} catch { | ||
$packageArgs = @{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the reason this catch block is needed? It seems to be doing pretty much the same thing as the try block. |
||
ExetoRun = $adtExe | ||
statements = "-DeploymentType 'Install' -DeployMode 'Silent'" | ||
} | ||
|
||
Start-ChocolateyProcessAsAdmin @packageArgs | ||
} finally { | ||
$packageArgs = @{ | ||
statements = "& { & '$deployScript' -DeploymentType 'Install'}" | ||
} | ||
|
||
Start-ChocolateyProcessAsAdmin @packageArgs | ||
} | ||
|
||
<# | ||
try { | ||
$packageArgs = @{ | ||
ExetoRun = $adtExe | ||
statements = "-DeploymentType 'Install' -DeployMode 'Silent'" | ||
} | ||
|
||
Start-ChocolateyProcessAsAdmin @packageArgs | ||
} | ||
|
||
catch { | ||
$packageArgs = @{ | ||
|
||
statements = "& { & '$deployScript' -DeploymentType 'Install'}" | ||
} | ||
|
||
Start-ChocolateyProcessAsAdmin @packageArgs | ||
} | ||
#> | ||
|
||
#Cleanup | ||
Remove-Item $zipArchive | ||
|
||
#Prevent shims | ||
if(-not (Test-Path "$destination\*.ignore")){ | ||
Get-ChildItem $toolsDir -Recurse -Filter '*.exe' | Foreach-Object { $null = New-Item "$destination\$($_.Name).ignore" -ItemType File } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
$ErrorActionPreference = 'Stop' # stop on all errors | ||
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" | ||
$destination = (Join-Path $toolsDir -ChildPath $env:ChocolateyPackageName) | ||
|
||
|
||
$adtExe = Join-Path $destination -ChildPath "Deploy-Application.exe" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this |
||
|
||
$packageArgs = @{ | ||
ExetoRun = $adtExe | ||
statements = "-DeploymentType 'Uninstall' -DeployMode 'Silent'" | ||
} | ||
|
||
Start-ChocolateyProcessAsAdmin @packageArgs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest switching to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all Chocolatey packages should be silent, this could be simplified to
psadt.template