install-package with chocolatey never adds anything to the path environment variable - powershell

The command install-package <packagename> -providerName chocolatey never seems to add anything to the PATH envirnoment variable (Windows 10 Build 15063).
For example running
install-package docfx -providerName chocolatey
install-package wkthmltopdf -providerName chocolatey
does not do it. Where as
choco install docfx
choco install wkhtmltopdf
does it. When I run the latter the commands docfx and wkhtmltopdf are available in the command line.
So my question is: How is installation different when using the choco command directly compared to install-package and what can I do about this?

As Rob Reynolds pointed out to me on gitter that package provider is not ready for prime time:
do not use the
prototype provider for OneGet/PackageManagement - it's not official,
it's a non-fully featured prototype made by MS and it may have
security issues. See
https://github.com/chocolatey/chocolatey-oneget/issues/5#issuecomment-275404099
for details

Related

what is the correct way of installing Google.Apis.Calendar.v3 using PowerShell

Using PowerShell v7.3.1, I am trying to install the Google.Apis.Calendar.v3 library, but I get this error.
As suggested I run Get-PackageSource
I have also installed .NET Framework 4.8.1
I have also tried Install-Module PowerShellGet -Force, which successfully installed the module, but then when I try Install-Package Google.Apis.Calendar.v3 I get the same error.
what is the correct way of installing Google.Apis.Calendar.v3 using PowerShell?
Google.Apis.Calendar.v3 is a Google package. Which is hosted on NuGet
You don't appear to have NuGet set as a package source See: register-packagesource
register-PackageSource -Name MyNuGet -Location https://www.nuget.org/api/v2 -ProviderName NuGet

How to use Powershell's Uninstall-Package to uninstall *a* specific package from *a* specific csproject

So I'm trying to automate some workflow and I'm running into issues with uninstalling/reinstalling a specific package on a specific csproject. I know this is possible with Package-Manager, but how would I achieve this within a powershell script? Here's what my script looks like so far:
# delete package folder from local feed
Remove-Item 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\<packageFolder>' -Recurse
# delete past package
Remove-Item '.\<package>.nupkg'
# pack new package
nuget pack '<nuspecPath>.nuspec' -NoDefaultExcludes
# push package to local feed
nuget add '.\<package>.nupkg' -Source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages'
**# Everything below this is not currently working #**
# Remove project's outdated package
Uninstall-Package -Name '<packageName>' -Project '<pathToProject>' -Force
# Install new package to project
Install-Package -Name '<packageName>' -Project '<pathToProject>' -Source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages' -Force
So, apparently -Project or -ProjectName are not recognized atrributes when using Uninstall-Package in powershell.. So, how do I specify powershell to uninstall a specific package on a specific csproject? Any help or insights would be much appreciated!
I tried the above code and kept getting complaints about -ProjectName attribute. I thought that this command would uninstall a nuget package from a specific project and then reinstall a new version of that package to the project.
The following answer is valid for .NET (Core) SDK-style projects, but does not work for "classic" .NET Framework projects (see this comment):
You may use the dotnet CLI to manage your projects and solutions.
Run the following command to list all packages:
dotnet list <PATH-TO-PROJECT> package
Run the following command to remove a package from the project:
dotnet remove <PATH-TO-PROJECT> package <PACKAGE-NAME>
See Install and manage NuGet packages with the dotnet CLI for more information.

Download Nuget Package using Nuget.exe

Im working on an automation solution for transfering nuget packages from nuget.org to a private nuget feed. Is it possible to download nuget packages using nuget.exe? If i run the following command, it fails because it tries to install it to the directory, but i dont need to install the package i just need to download it.
.\nuget.exe install Microsoft.AspNetCore.App.Runtime.linux-x64 -source nuget.org -force
This throws the following error:
Error NU5000: Package 'Microsoft.AspNetCore.App.Runtime.linux-x64 7.0.1' has a package type 'DotnetPlatform' that is not supported by project 'C:\foo'.
I am looking for something like a -force option, so that i can just download the package without installing it.

How install Nuget Microsoft.ML.OnnxRuntime.Gpu for ONNX Runtime in Ubuntu 18?

I'm trying to use ONNX runtime for Ubuntu: https://onnxruntime.ai/
I selected Linux, C++, x64, then CUDA. It says "Install Nuget package Microsoft.ML.OnnxRuntime.Gpu
Refer to docs for requirements."
When I click on "Microsoft.ML.OnnxRuntime.Gpu", I'm taken to https://www.nuget.org/packages/Microsoft.ML.OnnxRuntime.Gpu
There, it just says "Install-Package Microsoft.ML.OnnxRuntime.Gpu -Version 1.8.1". Now what am I supposed to do?
They expect you to install nuget in linux with
sudo apt-get install -y nuget
And then run the following with the version you want installed.
nuget install Microsoft.ML.OnnxRuntime.Gpu -Version 1.12.0
That's the expected approach. Personally, for me that didn't work. I kept getting some error saying "'Microsoft.ML.OnnxRuntime.Managed' already has a dependency defined for 'System.Memory'." So I did it a different way. I just went to https://github.com/microsoft/onnxruntime/releases/tag/v1.12.0. And then at the bottom under assets it lists pre-built .tgz packages for the different setups. You can just download one and unpack it.

Nuget install fails for pre-release package with dependencies

I have two pre-release nuget packages A.nuget and B.nuget, and B depends on A.
Install A.nuget works:
nuget.exe install A -Source E:\out\packages -OutputDirectory e:\NugetCache -Prerelease -PackageSaveMode nuspec;nupkg
Installing B.nuget fails:
nuget.exe install B -Source E:\out\packages -OutputDirectory e:\NugetCache -Prerelease -PackageSaveMode nuspec;nupkg
Unable to resolve dependency 'A.1.0.0.196-moma159241025'
I double checked and A.1.0.0.196-moma159241025 is installed under e:\NugetCache.
How can I resolve this error?
The work-around I use to solve this uses the -IgnoreDependencies switch, meaning the chosen package will install without its dependencies, regardless of whether Nuget can find them or not.
Install all packages "B" depends on (including "A")
Install package "B" using the -IgnoreDependencies switch
Install-Package A -IncludePrerelease
Install-Package SomeDependencyFromB
Install-Package SomeOtherDependencyFromB
Install-Package B -IncludePrerelease -IgnoreDependencies
https://docs.nuget.org/consume/package-manager-console-powershell-reference