Expanding a NuGet Package (nupkg) From the Command-Line - nuget

I have access to the NuGet command-line tool but not to any unzip tools. Is it possible to install a package already saved locally?
After doing a number of searches, I've come up with nothing that handles such a simple requirement. I've also looked at the code but it's far too lengthy/dense to quickly come to a definite conclusion, though, by all indications, it doesn't support the direct install of a local file.

Since it's really just a zip file.
mv ~/path/to/package.nupkg package.zip
This will change the file extension to be a zip file. Then:
unzip package.zip -d ~/Output/dir

If you have the .nupkg stored locally in a directory and all you want to do is extract the files you could use NuGet.exe and do something like:
NuGet.exe install -o extract-directory MyPackageId -source /Full/Path/To/Directory/Containing/NuGet/Package/NuPkgs
The -source parameter allows you to define a new source. In this case the directory where the .nupkg file exists.
The -o parameter defines the directory where you want the NuGet package extracted to.
The above seems to work on the Mac with NuGet 2.12.

Related

Chocolatey: Make an install script

In order to make install scripts and understanding existing ones, I would like to know what happens behind the scenes of the typical:
choco install notepadplusplus
I found the following here:
Installation
Chocolatey uses Nuget.Core to retrieve the package from the source.
Choco determines if it self-contained or has automation scripts - PowerShell scripts (*.ps1 files), and soon to be open to Scriptcs files in the 0.9.10.x timeframe (I know, right?!).
Choco takes a registry snapshot for later comparison.
If there are automation scripts, choco will run those. They can contain whatever you need to do, if they are PowerShell you have the full power of Posh (PowerShell), but you should try to ensure they are compatible with Posh v2+.
Choco compares the snapshot and determines uninstaller information and saves that to a .registry file.
Choco snapshots the folder based on all files that are currently in the package directory.
Choco looks for executable files in the package folder and generates shims into the $env:ChocolateyInstall\bin folder so those items are available on the path. Those could have been embedded into the package or brought down from somewhere (internet, ftp, file folder share, etc) and placed there.
That given,
How can I get the .nupkg package URL? In general it seems like this:
https://chocolatey.org/api/v2/package/package-name
Which is the .nupkg package download directory?
Where is the content of the .nupkg package extracted by default? This is important since chocolateyInstall.ps1 sometime uses Split-Path -Parent $MyInvocation.MyCommand.Definition.
"Scriptcs files in the 0.9.10.x timeframe" is rather cryptic. Can you give some references?
Is Posh v2+ simply short for Powershell or is a specific technology?
There are several executable files in $env:ChocolateyInstall\lib without a link in $env:ChocolateyInstall\bin. For example, the mpv.exe of the mpv player is not linked.
Yes, that download URL seems correct. The download directory is always into the Chocolatey installation folder, then lib\packageName, and this is where contents are extracted to.
Right now, installation scripts are only written in PowerShell. This comment is referring to the ability to write in installation scripts in C#, using the ScriptCS run time. Currently, this isn't yet supported.
Yes, this is just a short way of referring to PowerShell.
In the case of the mpv package, you will notice that there is an mpv.exe.ignore file. The presence of this file in the package prevents a shim being created.

How to Build an RPM from Source in One Line without Spec Files etc?

I've been reading about building RPMs, and the process is quite complex. Is there any program/software that works like this:
Download tar.gz file. Extract to directory
cd into directory
Run
RPM file is output into the directory
Does any such program exist? It seems as if it should. After all, when I run make, make install etc, I don't need to specify spec files, provide locations for where the software has to be installed. So why should I have to do all that for creating RPMs?
I've tried using checkinstall, but I keep getting errors like "Directory not found: /root/rpmbuild/BUILDROOT/hello-2.10-1.x86_64/usr"
So is there an easier way?
No. There is no easier way.
Sometimes upstream provide 'make rpm' target. Sometime checkinstall works. But often you have to create the spec file manually.
BTW that error from checkinstall reveals two things:
you are running that command as root. That is very very unwise.
you should create few build directories. Run command rpmdev-setuptree it will create them for you.

How to submit a package to PyPI under a different user than my ~/.pypirc

As far as I can tell from the docs, unlike with say git and .gitignore files, setuptools will only look in your $HOME directory for a .pypirc file.
Mostly I am submitting as 'myself', but now I want to submit a specific project via my employer's dev team account.
setup.py register --help doesn't seem to indicate any way to supply a username/password other than the one from my ~/.pypirc
There's the setup.cfg file which could appear in my project root, but it seems that only allows to specify args accepted by the command, so same as above.
Same for .pydistutils.cfg (?)
Surely I can't be the only one - what's the usual way to do this?
I found a workaround, which is to use https://pypi.python.org/pypi/twine
After installing twine I was able to create a project-specific .pypirc file in the project root, containing the company username/password.
Before using twine you have to generate the package using setup.py though, so the procedure is (from your project root):
$ python setup.py sdist
$ twine register --config-file=./.pypirc dist/*
$ twine upload --config-file=./.pypirc dist/*

How to make NuGet pack not overwrite an existing version

When building a NuGet Pack to an output directory, I do not want it to overwrite an existing version
Existing command:
".nuget\nuget.exe" pack "some.csproj" -output "c:\~packages"
I have looked through the documentation and cannot seem to find a switch that does it. I tried using a if exists "c:\~packages\some.nupkg" exit 1 but the problem is I do not have access to the version number in that context, so I cannot predictably provide a version to check for
This is not currently possible using NuGet.exe.
The options are:
Modify NuGet's source code to allow an extra command line option to support not overwriting the existing NuGet package if it exist. The PackCommand could be changed to support this.
Write a utility to generate the correct package version, then check the package exists before running NuGet.exe. The package version information is read from the AssemblyInformationalVersionAttribute taken from the project's output assembly if you are using nuget pack projectfile.

How to view wget source code?

I've gone to this link http://ftp.gnu.org/gnu/wget/
and downloaded different versions, but I have no idea how to actually unpack it.
You don't need to download it. Take a look at their source code repository and read everything using your browser. Here's main.c for example. More details available at How to Access the Wget Source Code Repository.
tar.gz is a common extension for files that have been "tarred" ("tape archive", using the "tar" program), and "gzipped".
Most Linux systems come with these pre-installed, so you can extract the files using something like this:
tar xf wget-1.13.tar.gz
In Windows, use some unzipper program such as 7-Zip, WinZip, or WinAce or use tar from mingw/cygwin.