繁体   English   中英

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

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

我正在使用Visual Studio 17中使用.NET 4.5.2的MVC.NET项目,该项目由于以下错误而无法构建:

生成还原了NuGet软件包。 再次构建项目以将这些包包括在构建中。 有关更多信息,请参见http://www.postsharp.net/links/nuget-restore

我的PostSharp版本是4.1.30。

每次我构建或重建项目时都会发生此错误,并且在连续构建几次后不会消失。 该错误发生在引用PostSharp的多个项目中。

仅当我在解决方案中进行更改后,才会发生错误。 如果签出Trunk的新副本,则可以加载该网站。 只有在有机会发生这些错误之后。 更改可能很小,例如在不相关的项目中将新的控制器文件添加到错误所引用的位置。

我试过还原NuGet软件包,重新启动计算机,甚至删除我的存储库,然后重新检查Trunk的全新安装。 我如何克服这个错误? 我不确定这是否与PostSharp有关,或更笼统的NuGet错误。

在查看.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>

我尝试将其删除以查看会发生什么,但是也许没有令人惊讶的是它没有构建并且没有报告任何错误。

看起来好像与PostSharp NuGet软件包的升级有关。 在您的.csproj文件中,安装了PostSharp 4.1.25,但是您说您正在使用PostSharp 4.1.30。

以下之一可能会有所帮助:

  • 可以将packages.config中的软件包版本更改为4.1.5,检查项目是否生成,然后根据需要使用NuGet软件包管理器升级到新版本,
  • 或从packages.confing和.csproj(显示的行+对PostSharp.dll和任何其他PostSharp。*。dll的引用)中删除PostSharp,然后使用NuGet软件包管理器安装PostSharp。

请注意,不再支持PostSharp 4.1。 有关受支持版本的列表,请参见https://www.postsharp.net/support/policies#support

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM