NuGet dependency loop detected installing Microsoft.Data.Tools.Msbuild - powershell

I need to install the Microsoft.Data.Tools.Msbuild package. Is there anything I can do about this?
I used the command specified at https://www.nuget.org/packages/Microsoft.Data.Tools.Msbuild, but it should specify -RequiredVersion.
PS C:\> Install-Package Microsoft.Data.Tools.Msbuild -RequiredVersion 16.0.62004.28040 -Scope CurrentUser -ProviderName 'NuGet' -Source 'https://api.nuget.org/v3/index.json'
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'nuget.org'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
Install-Package: Dependency loop detected for package 'Microsoft.Data.Tools.Msbuild'.

Related

'No match was found ..' when installing a module with -MinimumVersion

I believe I might be misunderstanding the -MinimumVersion parameter of Install-Module
The help states
Specifies the minimum version of a single module to install. The version installed must be greater than or equal to MinimumVersion. If there is a newer version of the module available, the newer version is installed.
However, with the following command
Install-Module -Name RunAsUser -MinimumVersion 2.3.1
I receive this error
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'RunAsUser'.
Try Get-PSRepository to see all available registered module repositories.
If I instead run
Install-Module -Name RunAsUser -RequiredVersion 2.3.1
It will install version 2.3.1 successfully. If I run
Install-Module -Name RunAsUser
It will install the latest which is 2.4.0 Am I misusing the -MinimumVersion parameter?
Powershell version 5.1.19041.2364
I got this error trying to update PowershellGet with -Scope CurrentUser
PackageManagement\Install-Package : The following commands are already available on this
system:'Find-Package,Install-Package,Uninstall-Package'. This module 'PackageManagement' may override the existing
commands. If you still want to install this module 'PackageManagement', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
Seemed like all these issues related to 1.0.0.1 so I simply went into C:\Program Files\WindowsPowershell\Modules\PowerhsellGet and moved the folder 1.0.0.1 out of there. Now everything is working as expected.

Unable to install NuGet package provider in PowerShell Core on Linux

I'm trying to set up the NuGet package provider on Linux in PowerShell 7 so I can useInstall-Package to get a package from the NuGet Gallery. However, when I run:
Install-PackageProvider -Name NuGet -Force
I get the following error:
Install-PackageProvider: No match was found for the specified search criteria for the provider 'NuGet'.
The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified
package has the tags.
I did a bit of searching and found a few questions from this site and others where this error occurs, some answers saying I need to force TLS 1.2:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
some saying to specify -RequiredVersion on Install-PackageSource, some saying to use-ForceBootstrap, and some saying to use -Force. None of these work and I'm still met with the same error each time. Get-PackageProvider lists NuGet as a provider.
I'm was also unable to install the NuGet provider on Windows using PowerShell Core with the same error. Is this just not supported from PowerShell Core?
I also received this error and specifying the version (currently 3.0.0.1) also fails. What worked for me was piping the packageprovider into Install-PackageProvider
Get-PackageProvider | where name -eq 'nuget' | Install-PackageProvider
You may add -Force if you want to avoid answering yes to The package(s) come(s) from a package source that is not marked as trusted. Are you sure you want to install software from ''?
The NuGet location has been updated. You can also do it in one line:
Register-PackageSource -Name nuget.org -ProviderName NuGet -Location "https://api.nuget.org/v3/index.json" -Trusted
Having TLS12 set in conjunction with Install Nuget package worked for me.
Below is how I used the command:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet
In addition to #DougMaurer's answer, I also had to configure the package source as well:
$sourceArgs = #{
Name = 'nuget.org'
Location = 'https://api.nuget.org/v3/index.json'
ProviderName = 'NuGet'
}
Register-PackageSource #sourceArgs

Angular build error on Azure DevOps with powershell script

I prepared a powershell script in azure devops build pipeline to create an artifact, but when I start build queue, I get an error which is below.
The build command requires to be run in an Angular project, but a
project definition could not be found.
Can someone help me please.
Powershell script:
npm install
npm install -g typescript
npm install -g #angular/cli
ng build --configuration=production
This is all the result of powershell script:
##[section]Starting: PowerShell Script
==============================================================================
Task : PowerShell
Description : Run a PowerShell script on Windows, macOS, or Linux.
Version : 2.148.0
Author : Microsoft Corporation
Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
==============================================================================
Generating script.
========================== Starting Command Output ===========================
##[command]"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'd:\a\_temp\90129c3e-4840-41d7-895c-2f9c8f6e5968.ps1'"
npm WARN saveError ENOENT: no such file or directory, open 'D:\a\1\s\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'D:\a\1\s\package.json'
npm WARN s No description
npm WARN s No repository field.
npm WARN s No README data
npm WARN s No license field.
up to date in 5.231s
found 0 vulnerabilities
C:\npm\prefix\tsc -> C:\npm\prefix\node_modules\typescript\bin\tsc
C:\npm\prefix\tsserver -> C:\npm\prefix\node_modules\typescript\bin\tsserver
+ typescript#3.4.5
updated 1 package in 2.063s
C:\npm\prefix\ng -> C:\npm\prefix\node_modules\#angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules\#angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ #angular/cli#7.3.9
added 295 packages from 180 contributors in 88.373s
The build command requires to be run in an Angular project, but a project definition could not be found.
##[error]PowerShell exited with code '1'.
##[section]Finishing: PowerShell Script
As the error said, you try to run ng build not in the project folder.
You need to run cd path/to/project-folder before.
Another option, in the Azure DevOps PowerShell task there is a option to specify "Working Directory" so enter there the project path.

Unable to script installation of NuGet Package Provider in Powershell

I am trying to install the NuGet Package Provider using this command.
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
I've also tried adding the -Confirm:$false flag. I continue to be prompted for confirmation.
For example,
NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to
interact with NuGet-based repositories. The NuGet
provider must be available in 'C:\Program
Files\PackageManagement\ProviderAssemblies' or
'C:\Users\Booker\AppData\Local\PackageManagement\ProviderAssemblies'. You
can also install the NuGet provider by
running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -
Force'. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"):
I want to complete this installation in a script. How can I bypass the confirmation prompt?
This works to get the Nuget Package Provider installed without confirmation.
Find-PackageProvider -Name 'Nuget' -ForceBootstrap -IncludeDependencies

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

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