Skip to content

Argument cannot be null or empty 参数名: primarySources CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:29 (message): Failed to install nuget package Microsoft.Windows.CppWinRT.2.0.210806.1 #1025

Closed

Description

@lucasjinreal

Argument cannot be null or empty
参数名: primarySources
CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:29 (message):
Failed to install nuget package Microsoft.Windows.CppWinRT.2.0.210806.1

Activity

  1. shuzibanshou commented on Apr 22, 2023

    @shuzibanshou

    hi bro.I meet the same issue with you.THE SAME.
    do you resolve it?

  2. shuzibanshou commented on Apr 22, 2023

    @shuzibanshou

    nice.I resolved this issue after reinstall windows SDK 11(10.0.22621.0) and delete the build folder in flutter project.
    Download the nuget.exe and Microsoft.Windows.CppWinRT nupkg, let them in the Flutter SDK folder(eg. D:\flutter\bin)
    Run the command in the terminal in the current folder
    "./nuget install Microsoft.Windows.CppWinRT -Version 2.0.210806.1"

  3. sneurlax commented on Jun 6, 2023

    @sneurlax

    nice.I resolved this issue after reinstall windows SDK 11(10.0.22621.0) and delete the build folder in flutter project. Download the nuget.exe and Microsoft.Windows.CppWinRT nupkg, let them in the Flutter SDK folder(eg. D:\flutter\bin) Run the command in the terminal in the current folder "./nuget install Microsoft.Windows.CppWinRT -Version 2.0.210806.1"

    This worked for me, except I had to install the Windows 10 SDK. Then I downloaded the package ("Download package"), placed it in my Flutter's bin folder with a nuget.exe found elsewhere on my system (or from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe), and used nuget install Microsoft.Windows.CppWinRT -Version 2.0.210806.1 to install it in my Flutter project's root folder

  4. gwj41 commented on Jun 14, 2023

    @gwj41

    Argument cannot be null or empty 参数名: primarySources CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:29 (message): Failed to install nuget package Microsoft.Windows.CppWinRT.2.0.210806.1

    Hi, I resolved this issue after I configured nuget package source with "https://nuget.cdn.azure.cn/v3/index.json"

  5. mvanbeusekom commented on Aug 10, 2023

    @mvanbeusekom
    Member

    This is usually caused by an configuration error regarding NuGet package manager. The permission_handler_windows package makes use of NuGet to download the Microsoft.Windows.CppWinRT library which contains is used to generate C++ header files to access the Windows native runtime SDK, needed to communicate with the GPS hardware.

    I am not really sure what causes the configuration error, however here are some steps that can be verified:

    1. Make sure the default NuGet configuration file exists at the following path %appdata%\NuGet\NuGet.Config. If it doesn't exists create it with the following contents:
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
      </packageSources>
    </configuration>
    1. If the default NuGet.Config exists with the appropriate content, verify if you are allowed to connect to the https://api.nuget.org/v3/index.json url. Some organisations are configured behind a firewall or proxy blocking access.
    2. Make sure Visual Studio 2022 (not Visual Studio Code) is installed correctly with the "Desktop development with C++" workload including all default options.

    If this all fails please run flutter build windows -v. The -v switch will provide verbose information and will give more feedback on why NuGet wasn't able to install the Microsoft.Windows.CppWinRT library.

  6. rajvardhant commented on Apr 28, 2025

    @rajvardhant

    Fixing "Argument cannot be null or empty. Parameter name: primarySources" NuGet Error in Flutter
    When working with the permission_handler_windows package in Flutter, you might encounter the error:

    Argument cannot be null or empty. Parameter name: primarySources
    CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:29 (message):
    Failed to install NuGet package Microsoft.Windows.CppWinRT.2.0.210806.1
    

    Root Cause
    This issue usually arises due to a misconfiguration in NuGet package manager settings or network restrictions blocking access to the NuGet package source.

    Resolution Steps
    Follow the steps below to resolve the issue:

    Step 1: Verify and Configure NuGet Config File
    Check if the NuGet configuration file exists at this path:
    %appdata%\NuGet\NuGet.Config

    Use the Run dialog (Win + R) and paste the path to locate it.

    If the file doesn't exist, create it with the following content:

    xml

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <packageSources>
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
      </packageSources>
    </configuration>
    
    
    

    Save and close the file.

    Step 2: Add Package Source Manually
    Run the following commands to manually add and verify the NuGet package source:

    Add the source:

    bash

    nuget sources add -Name "nuget.org" -Source "https://api.nuget.org/v3/index.json" 
    
    

    Verify the source:

    bash

    
    nuget sources list
    
    
    

    Step 3: Install Required Tools
    Ensure Visual Studio 2022 (not Visual Studio Code) is installed.

    Include the "Desktop development with C++" workload during installation.

    Reinstall the Windows 10 SDK, such as version 10.0.22621.0, to ensure compatibility.

    Step 4: Use NuGet Command to Install the Package
    Download nuget.exe from NuGet's website.

    Place nuget.exe in your Flutter SDK's bin folder (e.g., C:\flutter\bin).

    Run the following command in the terminal:

    bash

    nuget install Microsoft.Windows.CppWinRT -Version 2.0.210806.1
    
    

    By following these steps, you should be able to resolve the error and successfully install the Microsoft.Windows.CppWinRT package. Feel free to share feedback or improvements in the comments section below!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions