1

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:

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.

My version of PostSharp is 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.

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. 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. How can I get past this error? I'm not sure if it's definitely related to PostSharp, or a more general NuGet error.

After looking in the .csproj file to see what is causing the error in one of the projects, I found these lines:

 <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.

8
  • Could you try to delete all package from the local folder and rebuild the project? Don't forget to backup the folder..:D. Commented Oct 2, 2018 at 13:25
  • @Sham - Which packages do you mean, and from which folder? I'm on Windows. Just checking to be sure! Commented Oct 2, 2018 at 13:26
  • The packages folder (in your project folder) can be safely deleted to force NuGet to restore again. This sounds like a PostSharp issue to me, though. Commented Oct 2, 2018 at 13:27
  • 1
    There would be a folder name packages in solution directory where .sln is present. Commented Oct 2, 2018 at 13:29
  • Should I also delete 'packages.xml' from the projects which the error mentions are failing that don't have a 'packages' folder? I can only find one packages folder which is in my startup projects folder (there are 42 projects in total). Commented Oct 2, 2018 at 13:31

1 Answer 1

3

This looks like an issue with upgrading of the PostSharp NuGet package. In your .csproj file, there is PostSharp 4.1.25 installed, but you say you are using 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,
  • 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.

Please note that PostSharp 4.1 is no longer supported. See https://www.postsharp.net/support/policies#support for list of supported versions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.