如何在Visual Studio 2013中安装MongoDB.Driver。

huangapple go评论71阅读模式
英文:

How to install MongoDB.Driver in Visual Studio 2013

问题

我正在使用Visual Studio Ultimate 2013尝试在我的项目(.NET Framework 4.6)中安装MongoDB.Driver包,但我遇到了以下错误:

无效的静态方法调用语法:
"[MSBuild]::IsOsPlatform('Windows')"。方法
'[MSBuild]::IsOsPlatform'未找到。静态方法调用应该
采用以下形式:$([FullTypeName]::Method()),例如
$([System.IO.Path]::Combine(a, b))。
C:\ProjectPath\packages\MongoDB.Libmongocrypt.1.0.0\build\MongoDB.Libmongocrypt.targets

我尝试在其他项目中安装并修复Visual Studio,但没有成功。

英文:

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.

答案1

得分: 1

分享我的经验:
2020年1月6日 07:27:40

当我在我的项目(.NET Framework 4.6.1)中使用以下命令时:

Install-Package MongoDB.Driver

包管理器控制台显示:
> 无效的静态方法调用语法:“[MSBuild]::IsOsPlatform('Windows')”。未找到方法“[MSBuild]::IsOsPlatform”。

我只是重新启动了我的vs2015,然后尝试通过以下命令安装此包:

Install-Package MongoDB.Driver -Version 2.5.0

我成功了!

英文:

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!

答案2

得分: 1

在项目文件中添加了条件检查。您可以移除该错误条件,然后构建应该可以工作。

移除了项目文件中的条件,然后工作正常。

请注意,代码部分不需要翻译。

英文:

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')" />-->

答案3

得分: 0

最新版本(MongoDB.Driver 版本 2.10)似乎无法在 Visual Studio 2013 中安装,所以解决方案是安装与 Visual Studio 2013 兼容的先前版本。在这种情况下,最新兼容的版本是 2.9.3。

我不得不使用 Package Manager Console 安装先前版本,命令如下:

Install-Package MongoDB.Driver -Version 2.9.3

要打开 Package Manager Console,您需要前往:

工具 > NuGet 包管理器 > 包管理器控制台

英文:

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

huangapple
  • 本文由 发表于 2020年1月4日 01:56:39
  • 转载请务必保留本文链接:https://go.coder-hub.com/59583165.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定