我研究了这个问题,但没有一个解决办法有效。我安装了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.
0
对于nuget引用,我们可以通过引用或通过包添加a。配置文件。
在Visual Studio 2017中,字母顺序或nuget引用由VS自动处理。
但是在Visual Studio 2019中。如果你的nuget引用不是按字母顺序排列的,那么VS就不要在引用文件夹中加载文件。
为了解决这个问题。——删除.csproj/vbproj或package.config中的所有引用。
——保存在记事本中。尝试通过Nuget包管理器添加这些。
第一次试试。一旦安装。
—右键单击解决方案->恢复所有nuget包。
-你会看到它加载了一个nuget引用。
——现在一个一个做。
——如果你100%确定你的参考文献是按字母顺序排列的。只需将它们全部粘贴到.csproj/vbproj或package.config中即可。
—恢复溶液中的所有核。
你会看到所有的符号都将被加载。在解决方案资源管理器的顶部图标刷新你的引用文件夹。
快乐的引用。
这似乎有多种原因。
对于我来说,.csproj文件包含了对Microsoft.Bcl.Build.targets两个不同版本的引用:
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="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=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use 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('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
我删除了旧的参考,它解决了这个问题。