jberezanski / ChocolateyPackages

Chocolatey packages maintained by me
MIT License
83 stars 51 forks source link

Repackage DOTNETFX for offline use #124

Closed avawda closed 1 year ago

avawda commented 2 years ago

I am trying to manually repackage DOTNETFX with the local install file embedded, as the destination machine does not have internet access. I am trying to use this guide : https://docs.chocolatey.org....

But the install.ps1 for dotnetfx is rather different to the one used in demo link above (for Notepad++). This is the Dotnet version below. So how do I safely replace the URL to instead point to the ./tools path (where I will place the .exe file) ?

$version = '4.8' $arguments = @{ PackageName = 'dotnetfx' Release = 528040 Version = $version ProductNameWithVersion = "Microsoft .NET Framework $version" Url = 'https://download.visualstud... Checksum = '9B1F71CD1B86BB6EE6303F7BE6FBBE71807A51BB913844C85FC235D5978F3A0F' ChecksumType = 'sha256' }

Install-DotNetFramework @arguments

jberezanski commented 2 years ago

Yes, the .NET packages are constructed differently than the simple example from the docs. The Install-DotNetFramework function comes from the chocolatey-dotnetfx.extension module (specifically, from here).

As you can see in the source code, the Url value is eventually passed to the Get-ChocolateyWebFile helper. I believe this helper supports local filesystem (file:) URIs (of the format file:///C:/ProgramData/...). To construct such an URI, you can use the $Env:chocolateyPackageFolder environment variable (provided by Chocolatey), which will point to the location where your package is extracted on the target machine. You should take care, however, to replace Windows path separators (backslashes) with slashes expected by the uri syntax.

Putting it all together, the Url in your package could probably be set as such:

Url = "file:///${Env:chocolateyPackageFolder}/tools/ndp48-x86-x64-allos-enu.exe".Replace('\', '/')
jberezanski commented 1 year ago

Closing due to inactivity.