![](/img/trans.png)
[英]NuGet Package Restore fails with error message - can't build solution
[英]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。
以下之一可能會有所幫助:
請注意,不再支持PostSharp 4.1。 有關受支持版本的列表,請參見https://www.postsharp.net/support/policies#support 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.