Carlos Siestrup
Carlos Siestrup

Reputation: 1216

How to install MongoDB.Driver in Visual Studio 2013

I'm using Visual Studio Ultimate 2013 trying to install MongoDB.Driver package in my project(.NET Framework 4.6) and I got the following error:

Invalid static method invocation syntax: "[MSBuild]::IsOsPlatform('Windows')". Method '[MSBuild]::IsOsPlatform' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)).
C:\ProjectPath\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets

I tried installing in others projects and repairing visual studio but it didn`t work.

Upvotes: 3

Views: 2653

Answers (3)

Mahesh Malpani
Mahesh Malpani

Reputation: 1989

There is condition check added in Project file. You can remove that error condition and build should work

</PropertyGroup>
    <Error Condition="!Exists('..\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets'))" />
  </Target>

Removed the condition from project file and then worked

 <!--<Import Project="..\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets" Condition="Exists('..\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets')" />-->

Upvotes: 1

shanzm
shanzm

Reputation: 26

Share my experience: 2020年1月6日 07:27:40

when i used

Install-Package MongoDB.Driver

in my project(.NET Framework 4.6.1)

Package Manager Console print:

Invalid static method invocation syntax: "[MSBuild]::IsOsPlatform('Windows')". Method '[MSBuild]::IsOsPlatform' not found.

I just restart my vs2015 ,I try install this package by

Install-Package MongoDB.Driver -Version 2.5.0

i successed!

Upvotes: 1

Carlos Siestrup
Carlos Siestrup

Reputation: 1216

It seems the lastest version(MongoDB.Driver Version 2.10) can`t be installed in Visual Studio 2013, so the solution is to install a previous version that was compatible with Visual Studio 2013.In this case the lastest compatible is version 2.9.3

I had to install a previous version with Package Manager Console using the command :

Install-Package MongoDB.Driver -Version 2.9.3

In order to open Package Manager Console you need to go to :

Tools > NuGet Package Maneger > Package Manager Console

Upvotes: 0

Related Questions