How to clean up the solution from packages?

youki 1,021 Reputation points
2023-01-29T19:28:43.11+00:00

1 Question:

I would like to clean up my NuGet - Solution of my project so that i only have and need 1 version of each package, is it possible at all?

I had the problem that my nuget package manager always freezes, so i removed a lot of things, reinstalled Visual Studio but that was a bad idea. Couldn't restore it.

I got messages like:

  • the package is missing...
  • the package already exists
  • can't read pch.h #include <wil/cppwinrt_helpers.h>
  • and so on...

Current state:

User's image

User's image

User's image

2 Question:

If I install the latest stable WindowsAppSDK 1.2.230118.102 and I try to debug, it doesn't work and says it needs the current installed/ previous version 1.2.221209.1, why? It wasn't like that before?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,423 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 30,821 Reputation points Microsoft Vendor
    2023-01-30T10:01:10.99+00:00

    Hi @youki

    Welcome to Microsoft Q&A! 

    Please go to Tools > Options > NuGet Package Manager > Package Sources and ensure that the nuget.org package source is checked. 

    For corrupted packages, please try to remove related code (such as the following entries) from .csproj file:

    <Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.221121.5\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.221121.5\build\native\Microsoft.Windows.CppWinRT.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\Microsoft.Windows.CppWinRT.2.0.221121.5\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.221121.5\build\native\Microsoft.Windows.CppWinRT.props'))" />
        <Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.221121.5\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.221121.5\build\native\Microsoft.Windows.CppWinRT.targets'))" />
      </Target>
    

    Meanwhile, go to packages.config and remove the entry for Microsoft.WindowsAppSDK. Then, re-launch your VS and open your project again. 

    If it doesn’t work, you can uninstall all installed packages from NuGet Package Manager and try again. 

    Sincerely,

    Anna

     


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.