简体   繁体   English

由于NuGet程序包还原错误,.NET项目的VS Build失败

[英]VS Build fails for .NET project because of NuGet package restore errors

I am working on an MVC.NET project using .NET 4.5.2 in Visual Studio 17 which is unable to build due to the error: 我正在使用Visual Studio 17中使用.NET 4.5.2的MVC.NET项目,该项目由于以下错误而无法构建:

The build restored NuGet packages. 生成还原了NuGet软件包。 Build the project again to include these packages in the build. 再次构建项目以将这些包包括在构建中。 For more information, see http://www.postsharp.net/links/nuget-restore . 有关更多信息,请参见http://www.postsharp.net/links/nuget-restore

My version of PostSharp is 4.1.30. 我的PostSharp版本是4.1.30。

This error happens every time I build or rebuild the proejct and doesn't disappear after building several times in a row. 每次我构建或重建项目时都会发生此错误,并且在连续构建几次后不会消失。 The error is happening for several projects which reference PostSharp. 该错误发生在引用PostSharp的多个项目中。

The error only occurs after I make a change within the solution. 仅当我在解决方案中进行更改后,才会发生错误。 If I checkout a fresh copy of Trunk, I can load the website. 如果签出Trunk的新副本,则可以加载该网站。 It's only after making a chance that these errors occur. 只有在有机会发生这些错误之后。 The change can be small, such as adding a new controller file in an unrelated project to where the errors reference. 更改可能很小,例如在不相关的项目中将新的控制器文件添加到错误所引用的位置。

I've tried restoring my NuGet packages, rebooting my machine, even deleting my repo and re-checking out a clean install of Trunk. 我试过还原NuGet软件包,重新启动计算机,甚至删除我的存储库,然后重新检查Trunk的全新安装。 How can I get past this error? 我如何克服这个错误? I'm not sure if it's definitely related to PostSharp, or a more general NuGet error. 我不确定这是否与PostSharp有关,或更笼统的NuGet错误。

After looking in the .csproj file to see what is causing the error in one of the projects, I found these lines: 在查看.csproj文件以查看是什么导致了一个项目中的错误之后,我找到了以下几行:

 <Import Project="packages\PostSharp.4.1.25\tools\PostSharp.targets" Condition="Exists('packages\PostSharp.4.1.25\tools\PostSharp.targets')" />
 <Target Name="EnsurePostSharpImported" BeforeTargets="BeforeBuild" Condition="'$(PostSharp30Imported)' == ''">
    <Error Condition="!Exists('packages\PostSharp.4.1.25\tools\PostSharp.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://www.postsharp.net/links/nuget-restore." />
    <Error Condition="Exists('packages\PostSharp.4.1.25\tools\PostSharp.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://www.postsharp.net/links/nuget-restore." />
  </Target>

I tried removing it to see what would happen but perhaps unsuprisingly it didn't build and didn't report any errors. 我尝试将其删除以查看会发生什么,但是也许没有令人惊讶的是它没有构建并且没有报告任何错误。

This looks like an issue with upgrading of the PostSharp NuGet package. 看起来好像与PostSharp NuGet软件包的升级有关。 In your .csproj file, there is PostSharp 4.1.25 installed, but you say you are using PostSharp 4.1.30. 在您的.csproj文件中,安装了PostSharp 4.1.25,但是您说您正在使用PostSharp 4.1.30。

One of the following might help: 以下之一可能会有所帮助:

  • Either change the package version in packages.config to 4.1.25, check if the project builds and then use NuGet Package manager to upgrade to a newer version if needed, 可以将packages.config中的软件包版本更改为4.1.5,检查项目是否生成,然后根据需要使用NuGet软件包管理器升级到新版本,
  • or remove PostSharp from packages.confing and .csproj (the lines you are showing + reference to PostSharp.dll and any other PostSharp.*.dll), then install PostSharp using NuGet package manager. 或从packages.confing和.csproj(显示的行+对PostSharp.dll和任何其他PostSharp。*。dll的引用)中删除PostSharp,然后使用NuGet软件包管理器安装PostSharp。

Please note that PostSharp 4.1 is no longer supported. 请注意,不再支持PostSharp 4.1。 See https://www.postsharp.net/support/policies#support for list of supported versions. 有关受支持版本的列表,请参见https://www.postsharp.net/support/policies#support

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NuGet软件包还原失败并显示错误消息-无法构建解决方案 - NuGet Package Restore fails with error message - can't build solution NuGet恢复后,MSBuild在单元测试项目(.NET Core)上失败 - MSBuild fails on Unit Test Project (.NET Core) after NuGet Restore 使用私有NuGet提要(VSTS CI Build),.NET Core NuGet还原失败 - .NET Core NuGet restore fails with private NuGet feed (VSTS CI Build) 对于AppHarbor上的多个软件包,NuGet软件包还原失败 - NuGet package restore fails for several packages on AppHarbor 在没有VS的情况下通过安装包内容来还原Nuget - Nuget restore without VS with package content installation Nuget包还原-未修改所有项目文件 - Nuget Package Restore - All project files not modified 如何为 nuget 包构建具有多个 .net 框架的项目 - How can I build a project with multiple .net frameworks for nuget package 干净的VS 2015 Enterprise + Xamarin安装:错误:项目的NuGet包还原失败 - clean VS 2015 Enterprise + Xamarin Install: error: NuGet Package restore failed for project 构建时的 NuGet 包还原极其缓慢(每个项目约 10 秒) - NuGet Package Restore on build extremely slow (~10sec per project) .NET 核心依赖项的 Nuget 包还原路径 - Nuget package restore path for .NET core dependencies
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM