我研究了这个问题,但没有一个解决办法有效。我安装了Visual Studio Professional 2015,我正在使用TFS。我的NuGet版本是3.1.6。这个问题只发生在我的c# Web API/MVC项目中。

我得到以下错误:

这个项目引用了NuGet包(s),这是缺失的 电脑。使用NuGet包还原来下载它们。更多的 信息,见http://go.microsoft.com/fwlink/?LinkID=322105。的 丢失的文件是 . . \ \ Microsoft.Net.Compilers.1.0.0 \制造\ Microsoft.Net.Compilers.props包

I do not have .nuget folder in my solutions. I have a packages folder in the solution and when I delete it, it seems like NuGet does rebuild the dependencies but the project still has the above error. I tried removing the project from TFS and it didn't fix it. Along with the above error, all the references in the project have yellow warning signs and say they are missing. When I checked the NuGet Package Manager for the project, everything that is "missing" has a green tick next to it, including Microsoft.Net.Compilers. I tried adding a new Web API/MVC project and it faced a similar problem where most references such as Owin were "missing" with the yellow warning sign.


当前回答

当从Git部署时,我在Azure中失败地构建了这个问题。

原来我的.gitignore从..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props中排除了build文件夹。

一旦构建文件夹(强制)提交到Git,问题就解决了。

其他回答

Not sure if this will help anyone, but I had this issue come up when I deleted the source code from my local machine without having ever saved the solution file to TFS. (During initial development, I was right-clicking and checking in the project in Solution Explorer, but forgot to ever check in the solution itself.) When I needed to work on this again, all I had in TFS was the .csproj file, no .sln file. So in VS I did a File --> Source Control --> Advanced -- Open from Server and opened the .csproj file. From there I did a Save All and it asked me where I wanted to save the .sln file. I was saving this .sln file to the project directory with the other folders (App_Data, App_Start, etc.), not the top level directory. I finally figured out that I need to save the .sln file up a directory from the project folder so it's on the same level as the project folder. All my paths resolved and I was able to build it again.

我收到了这个令人沮丧的消息。最后对我有用的是删除/包内的所有文件和文件夹,让VS在下次构建时重新获取所有内容。

遇到这个问题

按以下步骤求解

清除packages文件夹中的内容(先备份) 使用“更新-包-重新安装”从包管理控制台的NuGet中重新获取和重新安装包(Tools -> NuGet包管理器->包管理控制台) 从.csproj文件中删除冗余路径。注意:NuGet会添加新的路径到csproj文件,但它不会删除旧的路径… (有一些机会csproj文件有多个路径为同一文件)

为什么我们需要“Microsoft.Net.Compilers.props”? 它将提供“\roslyn”文件夹。如果没有它,你可能仍然可以编译程序,但不能使用@{html.RenderPartial…}

错误信息是完全正确的。我试了所有的花招,没有一个奏效。项目(简单的MVC Web应用程序测试)从Windows 8.1 VS 2015社区转移到我在Windows 10上的新测试箱。所有VS 2015的最新更新都适用。 我甚至无法安装任何更新版本的编译器包。

Loop:
<LOOP>This seems to be a Ground Hog Day phenomena.</LOOP>
GoTo Loop

我最终只是将Microsoft.Net.Compilers.1.0.0从旧项目复制到新项目中,它工作了。 然后我可以开始将其他包更新到新版本。 在我看来是nuget项目升级过程的bug。

注意:最初的项目是在VS 2015中创建的,没有任何遗留的nuget方法。

我通过从.csproj文件中删除这段代码来解决我的问题:

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
  <PropertyGroup>
    <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
  </PropertyGroup>
  <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>