sharpdevelop nuget: set-project says unknown project - powershell

I am trying to follow this post
to add nuget packages to my solution through the command line.
However, when I try to run the following command:
Install-package nuget -solution mysolution.sln -projectName myproject
I get the following error,
Can't read Microsoft Solution file format 12.00
Install-Package : A project must be open to run this command.
At line:1 char:16
+ install-package <<<< nuget -solution mysolution.sln -projectname
myproject
+ CategoryInfo : InvalidOperation: (:) [Install-Package], Invalid OperationException
+ FullyQualifiedErrorId : NoProjectOpen,ICSharpCode.PackageManagement.Cmdlets.InstallPackageCmdlet
Based on this post, I tried setting the project name
set-project myproject mysolution.sln
I get this error,
Can't read Microsoft Solution file format 12.00
Set-Project : Unknown project: myproject
At line:1 char:12
+ set-project <<<< myproject mysolution.sln
+ CategoryInfo : NotSpecified: (:) [Set-Project], ApplicationException
+ FullyQualifiedErrorId : System.ApplicationException,ICSharpCode.PackageManagement.Cmdlets.SetProjectCmdlet
I checked the sln file and it has the exact project name that I am trying to add. Any guesses on what could be the problem? Alternatively, is there any way to find the project names of my solution through some command so that I can cross-check?

Related

How do I install MongoDB driver for PowerShell using Install-Package?

I am trying to interact with MongoDB from powershell and need to install the driver package. Per instructions from https://www.nuget.org/packages/mongodb.driver I issue the command:
Install-Package MongoDB.Driver -Version 2.8.0
But I get an error:
Install-Package : A parameter cannot be found that matches parameter name 'Version'.
At line:1 char:32
+ Install-Package MongoDB.Driver -Version 2.8.0
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Install-Package], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
Not sure how to proceed.
> Get-PackageSource
Name ProviderName IsTrusted Location
---- ------------ --------- --------
PSGallery PowerShellGet False https://www.powershellgallery.com/api/v2
nuget.org NuGet False https://api.nuget.org/v3/index.json
My Downloads NuGet False C:\Users\Richard\Downloads
I tried downloading and installing from there, but still get an error:
> Install-Package -scope currentuser mongodb.driver
The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'My Downloads'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
Install-Package : One or more errors occurred.
At line:1 char:1
+ Install-Package -scope currentuser mongodb.driver
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ($TXkgRG93bmxvYW...2ZXI=\Mi44LjA=\:String) [Install-Package], Exception
+ FullyQualifiedErrorId : One or more errors occurred.,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
you can use .NET CLI and use this command
dotnet add package MongoDB.Driver --version 2.8.0
or
dotnet add package MongoDB.Driver --version 2.9.0-beta1
or remove version to install last stable version automaticly like:
Install-Package MongoDB.Driver
also see this articel :
https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting

Install MS Access DAO Primary Interop Assembly for Use with PowerShell Script

I am trying to automate Microsoft Access 2016 with PowerShell, but I appear to be missing an Office Primary Interop Assembly called Microsoft.Office.Interop.Access.Dao. I've tried a few approaches in PowerShell, and these are the errors that I get:
PS > $app.Application.OpenCurrentDatabase()
The following exception occurred while retrieving member "Application": "Could not load file or assembly 'Microsoft.Office.Interop.Access.Dao, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified."
At line:1 char:1
+ $app.Application.OpenCurrentDatabase()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
+ FullyQualifiedErrorId : CatchFromBaseGetMember
PS > Add-Type -Assembly "Microsoft.Office.Interop.Access.Dao"
Add-Type : Could not load file or assembly 'Microsoft.Office.Interop.Access.Dao, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
At line:1 char:1
+ Add-Type -Assembly "Microsoft.Office.Interop.Access.Dao"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Type], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.AddTypeCommand
Please note the difference in version (15.0.0.0 vs 12.0.0.0).
The only version of Office that I have installed on this machine is Office 2016 via Office 365 download. I have run gacutil /l from a Visual Studio Command Prompt, and I see that the other Office PIAs, version 15.0.0.0, are installed.
According to the NuGet Web site, I could download the assembly via NuGet Package Manager Console, if I were working on a Visual Studio Solution, but I cannot install the assembly with PowerShell:
PS > Install-Package Microsoft.Office.Interop.Access.Dao
Install-Package : No match was found for the specified search criteria and package name 'Microsoft.Office.Interop.Access.Dao'. Try Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Install-Package Microsoft.Office.Interop.Access.Dao
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
My questions are:
How can I install Microsoft.Office.Interop.Access.Dao to the GAC
so I can reference it in PowerShell scripts?
If nuget.org is listed as a PackageSource in PowerShell, why can't I use the Install-Package command to install this assembly?
Why did this assembly not get installed with Office 2016/365?
The accepted answer will provide at least a solution to my first question - How can I install Microsoft.Office.Interop.Access.Dao to the GAC so I can reference it in PowerShell scripts?

Neo4j with Windows Powershell : xxxx is not a Neo4j Home directory

I've installed Neo4j (exe installer) and I've also extracted the powershell module from the zip file but now when I try to do anything I just get an error message like:
PS C:\dev\github\neo4j-sandbox\src\ps> Get-Neo4jServer c:\dev\github\neo4j-sandbox\neo4jdb
Get-Neo4jServer : c:\dev\github\neo4j-sandbox\neo4jdb is not a Neo4j Home directory
At line:1 char:1
+ Get-Neo4jServer c:\dev\github\neo4j-sandbox\neo4jdb
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-Neo4jServer
At first I thought perhaps I was misinterpreting what the neo4j "home directory" was and tried pointing it to the installation directory, but I just get the same error message.
PS C:\dev\github\neo4j-sandbox\src\ps> Get-Neo4jServer "c:\Program Files\Neo4j CE 2.3.2"
Get-Neo4jServer : c:\Program Files\Neo4j CE 2.3.2 is not a Neo4j Home directory
At line:1 char:1
+ Get-Neo4jServer "c:\Program Files\Neo4j CE 2.3.2"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-Neo4jServer
So, what is the "Neo4j Home Directory" - I couldn't find a definition for that anywhere. Is it the data directory, or the installation directory, or something completely different.
It seems that somehow or another the installation via the exe download is different from the installation in the zip. I would have expected them to be the same, with the exe version just being automated.
Anyway, if you extract the zip file and copy the contents of the neo4j-community-2.3.2 (or appropriate for your version/edition) folder inside the zip file into a folder on your hard-drive, then point the PowerShell script at that folder it is happy to report the version of the installation.

EF7: "The EntityFramework package is not installed" when it is

Have already entered Install-Package EntityFramework.Commands –Pre, but when I try Add-Migration Initial I get the following error:
The EntityFramework package is not installed on project '…'.
As another clue, when I try the Use-DbContext command, I also get an error. Here's my Package Manager Console session:
PM> Install-Package EntityFramework.Commands –Pre
Package 'EntityFramework.Commands.7.0.0-rc1-final' already exists in project '…'
PM> Add-Migration Initial
The EntityFramework package is not installed on project '…'.
PM> Use-DbContext
Use-DbContext : The term 'Use-DbContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
+ Use-DbContext
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Use-DbContext:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
What am I doing wrong?

Nuget - Update-Package : Archive file cannot be size 0

Has anyone had this error when trying to use the package manager with Nuget? This happens to me when I am using either the GUI or the console.
I have cleared my local cache directory.
PM> Update-Package [My Name]
Update-Package : Archive file cannot be size 0.
At line:1 char:15
+ Update-Package <<<< [My Name]
+ CategoryInfo : NotSpecified: (:) [Update-Package], FileFormatException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.UpdatePackageCommand
PM>
Thanks for any help