Aus*_*ris 284 msbuild visual-studio-2010 visual-studio nuget
我有一个ASP.NET MVC5应用程序,昨天工作,现在我在尝试构建时收到此错误:
此项目引用此计算机上缺少的NuGet包.
我检查了两个选项,允许nuget自动下载并安装检查/打开的缺失包.我还尝试删除packages文件夹中的所有文件,然后让nuget重新下载它们.此外,当我打开nuget并寻找更新时,它说没有必要安装.我无法想象还有什么可以超越这个令人惊讶的恼人问题.
Lor*_*sen 430
在我的情况下,我不得不从.csproj文件中删除以下内容:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<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>
Run Code Online (Sandbox Code Playgroud)
实际上,在此代码段中,您可以看到错误消息的来源.
我正在从MSBuild集成包恢复转换为自动包恢复(http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore)
Iva*_*ago 75
一种解决方案是从.csproj文件中删除以下内容:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<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>
Run Code Online (Sandbox Code Playgroud)
怎么样?
Nik*_* G. 46
在我的情况下,它发生在我将我的解决方案文件夹从一个位置移动到另一个位置后,重新组织了一点,并在此过程中其相对文件夹结构发生了变化.
所以我必须在我的.csproj
文件中编辑类似于以下条目的所有条目
<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')" />
Run Code Online (Sandbox Code Playgroud)
至
<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')" />
Run Code Online (Sandbox Code Playgroud)
(注意从改变..\packages\
到packages\
.在你的情况下它可能是一个不同的相对结构,但你明白了.)
M.A*_*M.A 21
通过右键单击我的解决方案,然后单击" 启用NuGet包还原"选项,我可以轻松解决此问题
(PS:确保您具有Nuget安装工具 - >扩展和更新 - > Nuget包管理器for Visual Studio 2013.如果没有先安装此扩展)
希望能帮助到你.
小智 17
在我的情况下,它与Microsoft.Build.Bcl版本有关.我的nuget包版本是1.0.21,但我的项目文件仍然指向版本1.0.14
所以我改变了我的.csproj文件:
<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>
Run Code Online (Sandbox Code Playgroud)
至:
<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="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\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.21\build\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" />
Run Code Online (Sandbox Code Playgroud)
构建再次运行.
Wil*_* Jr 12
我有同样的问题。我在复制现有项目并将其传输到我的解决方案目录的文件夹中并将其作为现有项目添加到我的空解决方案时遇到了它。所以我必须编辑我的 csproj 文件并查找这行特定的代码,大多数情况下,这可以在最后几行找到:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Run Code Online (Sandbox Code Playgroud)
在该行之后,我必须将这些注释掉:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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\EntityFramework.6.4.0\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\packages\EntityFramework.6.4.0\build\EntityFramework.props'))" />
<Error Condition="!Exists('..\..\..\..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets'))" />
</Target>
<Import Project="..\..\..\..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('..\..\..\..\..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" />
Run Code Online (Sandbox Code Playgroud)
您的解决方案将提示您的项目发生了更改,只需选择重新加载全部:
RAM*_*RAM 11
如果您正在使用TFS
从解决方案的文件夹中删除NuGet.exe
和NuGet.targets
文件.nuget
.确保文件本身也从解决方案工作区中删除.保留NuGet.Config
文件以继续绕过将包添加到源代码管理.
编辑解决方案中的每个项目文件(例如.csproj,.vbproj)并删除对该NuGet.targets
文件的任何引用.在您选择的编辑器中打开项目文件,然后删除以下设置:
<RestorePackages>true</RestorePackages>
...
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
...
<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>
Run Code Online (Sandbox Code Playgroud)
如果您不使用TFS
.nuget
从解决方案中删除该文件夹.确保文件夹本身也从解决方案工作区中删除.
编辑解决方案中的每个项目文件(例如.csproj,.vbproj)并删除对该NuGet.targets
文件的任何引用.在您选择的编辑器中打开项目文件,然后删除以下设置:
<RestorePackages>true</RestorePackages>
...
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
...
<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>
Run Code Online (Sandbox Code Playgroud)
Ami*_*oon 10
删除了 .csproj 文件中的以下几行
<Import Project="$(SolutionDir)\.nuget\NuGet.targets"
Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<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>
Run Code Online (Sandbox Code Playgroud)
包裹是否可能已恢复到错误的文件夹?检查csproj文件中的路径是否正确.
如果它们不同,则可能是由于现在正在将包恢复到其他位置而导致的.这可能是由于在检查NuGet.Config文件时指定了这样的节点:
<add key="repositoryPath" value="..\..\Packages" />
Run Code Online (Sandbox Code Playgroud)
这些包正在恢复,项目仍在查看旧位置.
小智 5
一种解决方案是从 .csproj 文件中删除以下内容:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
Run Code Online (Sandbox Code Playgroud)
此项目引用此计算机上缺少的 NuGet 包。启用 NuGet 包还原以下载它们。有关详细信息,请参阅http://go.microsoft.com/fwlink/?LinkID=322105。丢失的文件是 {0}。
小智 5
首先要尝试的是右键单击解决方案并选择“还原 Nuget 包”。
在我的情况下,这不起作用,所以我遵循了一些关于删除项目文件中的“导入”和“目标”的建议,这适用于我的 3 个项目中的 2 个,但在最后一个中出现了不同的错误。
有效的是打开包管理器控制台并运行:
Update-Package -reinstall -ProjectName MyProjectName
Run Code Online (Sandbox Code Playgroud)
这需要一些时间,但由于它重新安装了所有包,您的项目将毫无问题地编译
归档时间: |
|
查看次数: |
151435 次 |
最近记录: |