c# – 在Microsoft.Net.Compilers上添加依赖项后无法加载Visual Studio 2015项目

我的项目依赖于NuGet包Microsoft.Net.Compilers:

<package id="Microsoft.Net.Compilers" version="1.3.2" 
         targetFramework="net461" developmentDependency="true" />

但是,如果我在清除package文件夹后加载Visual Studio,我的项目将不会加载以下错误

The imported project “C:\MyService\packages\Microsoft.Net.Compilers.1.3.2\tools\Microsoft.CSharp.Core.targets” was not found. Confirm that the path in the declaration is correct,and that the file exists on disk.
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.CurrentVersion.targets

所以它不会加载项目,因为它缺少一个使用Nuget在构建时恢复的文件,只有在我可以加载项目时它才有效.

解决方法

您可以使用Nuget命令行工具恢复您的包.如果你的系统还没有它,你可以在这里找到它: https://www.nuget.org/

在命令行上发出以下命令:

nuget restore

相关文章

目录简介使用JS互操作使用ClipLazor库创建项目使用方法简单测...
目录简介快速入门安装 NuGet 包实体类User数据库类DbFactory...
本文实现一个简单的配置类,原理比较简单,适用于一些小型项...
C#中Description特性主要用于枚举和属性,方法比较简单,记录...
[TOC] # 原理简介 本文参考[C#/WPF/WinForm/程序实现软件开机...
目录简介获取 HTML 文档解析 HTML 文档测试补充:使用 CSS 选...