Skip to content

Nuget not Found and CMake Error #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rayliverified opened this issue Mar 24, 2022 · 33 comments
Closed

Nuget not Found and CMake Error #819

rayliverified opened this issue Mar 24, 2022 · 33 comments

Comments

@rayliverified
Copy link

🐛 Bug Report

Building Permissions Handler on Windows fails due to 2 errors.

  1. Nuget not installed
  2. Failed to run cppwinrt.exe

CC @azchohfi

Expected behavior

Building for Windows works.

Nuget.exe not found, trying to download or use cached version.
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


Exception: Unable to generate build files

Reproduction steps

  1. If Nuget is not added to the PATH, Nuget not installed error occurs.
  2. Run a project with permission_handler on Windows.
Launching lib\main.dart on Windows in debug mode...
Building Windows application...
CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:38 (message):
  Failed to run cppwinrt.exe


Exception: Unable to generate build files
@azchohfi
Copy link
Contributor

This has nothing to do with the download of nuget.exe or the fact that it is not on the PATH. This message is expected if nuget.exe is not on the PATH, but it is only informative, not an error.
Nuget.exe is being downloaded and is being executed. The problem seems to be that the "nuget.exe install" command is failing. Seems like a misconfiguration in your Visual Studio, which sets the default nuget sources. Could you please send a screenshot of the NuGet Package Manager tab on VS's Options? It should have the nuget.org option, poiting to the nuget v3.

@rayliverified
Copy link
Author

Thank you for taking a look Alexandre

snap_screen_20220325132730

@azchohfi
Copy link
Contributor

Do you have multiple installations of VS? This is really weird, and I don't know exactly what is happening. Does it work if you do have nuget.exe on your path?

@rayliverified
Copy link
Author

Unfortunately not, I've added nuget to my path. The installation error disappears but the second error persists.

I did have VS 2019 installed before upgrading to VS 2022 a few weeks ago. But during this testing, I've only had 1 VS installed.

@azchohfi
Copy link
Contributor

I can't reproduce this, so I don't know what is happening. Can you try to run the full command from the command line?
nuget.exe install Microsoft.Windows.CppWinRT -Version 2.0.210806.1 -OutputDirectory packages
This should be executed from the build folder, so something like:
your_project\build\windows
If this command succeeds, then the build process should work. If not, we can probably at least get some more info into why this is happening.

@rayliverified
Copy link
Author

snap_screen_20220325154407

@rayliverified
Copy link
Author

Succeeds but builds still fail with:

CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:38 (message):
  Failed to run cppwinrt.exe


Exception: Unable to generate build files

@azchohfi
Copy link
Contributor

What happens if you run the cppwinrt command?
./packages/Microsoft.Windows.CppWinRT.2.0.210806.1/bin/cppwinrt.exe -input sdk -output include

Maybe this is a missing SDK?

@rayliverified
Copy link
Author

Hmmm, am I supposed to see anything happen? The cppwinrt.exe file is there. When I run the command, there's no output but it seems to succeed.

@azchohfi
Copy link
Contributor

This is what is weird then.
There might be some issue with your VS's cmake, or something else, since this:
https://github.com/Baseflow/flutter-permission-handler/blob/master/permission_handler_windows/windows/CMakeLists.txt#L34-L38
Is also not running fine, as you mentioned that it failed.
I honestly don't know what is happening with your box. Can you try to replicate this in a different machine?

@rayliverified
Copy link
Author

No worries! Let's wait and see if anyone else has this issue.
I ran this on another computer and it failed as well.

@GauravCalidig
Copy link

Facing the same
image

@afonseca69
Copy link

I have the same issue. Only in windows mode. If I remove permission_handler from pubspec.yaml, it runs ok.
Until last Friday, it was ok.

@azchohfi
Copy link
Contributor

Facing the same image

The screenshot you sent is not an issue, just a "warning". It can be safely ignored. Are you having the same other issue when building? If you run the ./packages/Microsoft.Windows.CppWinRT.2.0.210806.1/bin/cppwinrt.exe -input sdk -output include command, does it succeed?

@jmolins
Copy link

jmolins commented Apr 2, 2022

Same error here before updating Visual Studio:
Nuget.exe not found, trying to download or use cached version.
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

After updating Visual Studio Installer and Visual Studio 2019 the error was gone.
The warning (first line) still appears but the application compiles.

@guchengxi1994
Copy link

same issue, when i ran flutter run -d windows or flutter build windows ,it never finished.
i am using vs 2022
image

@Misutesu
Copy link

Same error here before reinstall Visual Studio 2022.

At first,i am using vs 2022
1.Nuget is not added to the PATH,build failed with
Nuget.exe not found, trying to download or use cached version.;
2.Nuget is added to the PATH,build failed with
CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:38 (message): Failed to run cppwinrt.exe;
3.reinstall vs 2019 the same problem;
4.reinstall vs 2022 the same problem;
5.install vs 2022 after uninstall vs and use VisualStudioUninstaller,build successed;

I hope this may help you.

@Misutesu
Copy link

Same error here before reinstall Visual Studio 2022.

At first,i am using vs 2022 1.Nuget is not added to the PATH,build failed with Nuget.exe not found, trying to download or use cached version.; 2.Nuget is added to the PATH,build failed with CMake Error at flutter/ephemeral/.plugin_symlinks/permission_handler_windows/windows/CMakeLists.txt:38 (message): Failed to run cppwinrt.exe; 3.reinstall vs 2019 the same problem; 4.reinstall vs 2022 the same problem; 5.install vs 2022 after uninstall vs and use VisualStudioUninstaller,build successed;

I hope this may help you.

I had the same problem again today after I executed flutter clean.

But this time the error message is more detailed,Maybe it's because I have http_proxy|https_proxy configured in path.
The following is the error message.

Nuget.exe not found, trying to download or use cached version.
  Performing download step (download and verify) for 'nuget-populate'
  -- verifying file...
         file='G:/Develop/Flutter-Project/map_demo/build/windows/_deps/nuget-subbuild/nuget-populate-prefix/src/nuget.exe'
  -- SHA256 hash of
      G:/Develop/Flutter-Project/map_demo/build/windows/_deps/nuget-subbuild/nuget-populate-prefix/src/nuget.exe
    does not match expected value
      expected: '04eb6c4fe4213907e2773e1be1bbbd730e9a655a3c9c58387ce8d4a714a5b9e1'
        actual: 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
  -- File already exists but hash mismatch. Removing...
  -- Downloading...
     dst='G:/Develop/Flutter-Project/map_demo/build/windows/_deps/nuget-subbuild/nuget-populate-prefix/src/nuget.exe'
     timeout='none'
     inactivity timeout='none'
  -- Using src='https://dist.nuget.org/win-x86-commandline/v6.0.0/nuget.exe'
  CMake Error at nuget-subbuild/nuget-populate-prefix/src/nuget-populate-stamp/download-nuget-populate.cmake:170 (message):
    Each download failed!

CUSTOMBUILD : error : downloading 'https://dist.nuget.org/win-x86-commandline/v6.0.0/nuget.exe' failed [G:\Develop\Flutter-Project\map_demo\build\windows\_deps\nuget-subbuild\nuget-populate.vcxproj]
            status_code: 4
            status_string: "A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision."
            log:
            --- LOG BEGIN ---
            Uses proxy env variable no_proxy == 'localhost,127.0.0.1,::1'

    Uses proxy env variable https_proxy == 'https://127.0.0.1:7891'

    Unsupported proxy 'https://127.0.0.1:7891', libcurl is built without the
    HTTPS-proxy support.

    Closing connection -1



            --- LOG END ---

@guchengxi1994
Copy link

I removed this package and related codes when build on windows and add them on mobiles now ...

@au-top
Copy link

au-top commented May 3, 2022

set no_proxy var !

@guchengxi1994
Copy link

I download a nuget.exe file and add it to PATH , it can build apps now.

@XuanTung95
Copy link

Fixed after downloading Nuget.exe manually and adding it to the PATH

@Nashev
Copy link

Nashev commented Jun 3, 2022

For me helped manual downloading of nuget like in comment #819 (comment), then adding the https://api.nuget.org/v3/index.json into NuGet sources through UI on Visual Studio Settings (like at screenshot at #819 (comment)) and then manual running command from #819 (comment)...
May be i'v a little overkill...

@ollyde
Copy link

ollyde commented Jun 3, 2022

This randomly started happening to me today; didn't change anything. Very strange.

@EwertonDutra
Copy link

Adding to the path manually didn't help
But this is just an annoying error. As far as I can see it doesn't interfere at all.

@JaffaKetchup
Copy link

Sometimes this happens to me, sometimes it doesn't. When it does happen, sometimes it recovers, sometimes it crashes out.

@jcollier7
Copy link

I also had the problem building windows desktop. Updated VS2019, added nuget.exe to path, added nuget.org to VS sources, still compile error. Uninstalled VS2019, Installed VS2022 using VS Installer & C++ workloads. Compiles fine.

@otizhi
Copy link

otizhi commented Dec 30, 2022

I also needed to delete the windows directory in my project and had to run flutter create . again. After that all was fine.

@lucasjinreal
Copy link

what happend?

➜ nuget.exe install Microsoft.Windows.CppWinRT -Version 2.0.210806.1 -OutputDirectory packages
Feeds used:

Argument cannot be null or empty
参数名: primarySources

@mvanbeusekom
Copy link
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.

@lucasjinreal
Copy link

@mvanbeusekom hello, does vstudio 2019 not able to run this?

@rayliverified
Copy link
Author

Seeing this issue again with Flutter v3.19 update.
It seems to be related to Flutter updates. Windows will build successfully and then fail after updating to the newest version of Flutter.

This is a good reminder that it's always worthwhile to file an issue and document your solutions. Because often times you find it in the search results when you run into the same issue again.

@afonseca69
Copy link

afonseca69 commented Feb 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests