gpt4 book ai didi

package - 我可以在 Chocolatey 包中包含 MSI 文件吗?

转载 作者:行者123 更新时间:2023-12-04 11:03:57 26 4
gpt4 key购买 nike

我可以放一个 MSI文件或 ISO 镜像到 Chocolatey 包?

所以当我 choco install foo ,它不会从另一个 URL 下载 MSI,而是从包中获取文件?

最佳答案

是的,这绝对是可能的。这实际上正是 ChocolateyGUI 包所做的。你可以在这里看到它的 .nuspec 文件:

https://github.com/chocolatey/ChocolateyGUI/blob/develop/nuspec/chocolatey/ChocolateyGUI.nuspec

<?xml version="1.0"?>
<package>
<metadata>
<id>chocolateygui</id>
<version>$version$</version>
<title>Chocolatey GUI</title>
<authors>Chocolatey</authors>
<owners>Chocolatey</owners>
<projectUrl>https://github.com/chocolatey/ChocolateyGUI</projectUrl>
<projectSourceUrl>https://github.com/chocolatey/ChocolateyGUI</projectSourceUrl>
<packageSourceUrl>https://github.com/chocolatey/ChocolateyGUI/tree/develop/nuspec/chocolatey</packageSourceUrl>
<iconUrl>https://raw.githubusercontent.com/chocolatey/choco/master/docs/logo/chocolateyicon.gif</iconUrl>
<licenseUrl>https://raw.githubusercontent.com/chocolatey/ChocolateyGUI/develop/LICENSE</licenseUrl>
<bugTrackerUrl>https://github.com/chocolatey/ChocolateyGUI/issues</bugTrackerUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>
Chocolatey GUI is a nice GUI on top of the Chocolatey command line tool.

## Features

* View all **installed** and **available** packages
* **Update** installed but outdated packages
* **Install** and **uninstall** packages
* See detailed **package information**

## Notes
This package will only work correctly on Windows 7 SP1 through Windows 10 (1708) or Windows Server 2008 R2 SP1 through Windows Server 2016, and requires .NET Framework 4.5.2 at minimum.
</description>
<summary>A GUI for Chocolatey</summary>
<releaseNotes>
All release notes for Chocolatey GUI can be found on the GitHub site - https://github.com/chocolatey/ChocolateyGUI/releases
</releaseNotes>
<tags>chocolateygui chocolatey admin foss</tags>
<dependencies>
<dependency id="Chocolatey" version="[0.10.3, 0.11)" />
</dependencies>
</metadata>
<files>
<file src="chocolateyInstall.ps1" target="tools"/>
<file src="chocolateyUninstall.ps1" target="tools"/>
<file src="..\..\BuildArtifacts\ChocolateyGUI.msi" target="tools"/>
<file src="..\..\LICENSE" target="tools\LICENSE"/>
<file src="VERIFICATION.txt" target="tools"/>
</files>
</package>

然后,正如您所指出的,您将使用 Install-ChocolateyInstallPackage 来执行安装,然后将使用包中的本地 MSI,而不是首先下载它。您可以在此处查看 ChocolateyGUI 的安装脚本:

https://github.com/chocolatey/ChocolateyGUI/blob/develop/nuspec/chocolatey/chocolateyInstall.ps1
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$fileLocation = Join-Path $toolsDir 'ChocolateyGUI.msi'

$packageArgs = @{
packageName = $env:ChocolateyPackageName
softwareName = 'Chocolatey GUI'
file = $fileLocation
fileType = 'msi'
silentArgs = "/qn /norestart /l*v `"$env:TEMP\$env:ChocolateyPackageName.$env:ChocolateyPackageVersion.log`""
validExitCodes= @(0,1641,3010)
}

Install-ChocolateyInstallPackage @packageArgs

Remove-Item -Force $packageArgs.file

您可以对 ISO 镜像文件执行完全相同的操作,这里有关于使用该 ISO 文件的既定最佳实践的演练:

How To Mount An Iso In Chocolatey Package

注意:如果您打算将软件包推送到 Chocolatey.org,请记住 MSI/ISO 文件的大小。如果这特别大,最好不要将它包含在 nupkg 中,而是使用下载链接。

关于package - 我可以在 Chocolatey 包中包含 MSI 文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32081779/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com