Flutter Windows: cannot build App error MSB8066

Viewed 7498

I am getting this error while building for windows

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(238,5): error MSB8066: Custom build for 'D:\DSI projects\sanjali_app\build\windows\CMakeFiles\a6c8cc86bdf940a07f4885a881770ba0\flutter_windows.dll.rule;D:\DSI projects\sanjali_app\build\windows\CMakeFiles\9c479cc21d461e620769ab96f5bca778\flutter_assemble.rule' exited with code 1. [D:\DSI projects\sanjali_app\build\windows\flutter\flutter_assemble.vcxproj] Exception: Build process failed.

11 Answers

Updated Aug 2021

Faced the same error for couple of hours, and none of the issue on Github or answer on StackOverflow seems to be working for me.

So after my research I found out that there is no specific reason why Error MSB8066 error occur, but it can be due to space in your project Folder path as mentioned by @aishamhasan or some other undetermined reason. In my case, there is a simple file that is missing.

Error detected in pubspec.yaml:
[   +2 ms]   [        ] No file or variants found for asset: images/project_app.png.

In order to quickly find out what causing this problem, you can run your project from the command line instead of using run functionality on android studio.

flutter run -d windows -v

And inside your verbose, lookout for any error, or you can directly search for Error and then try to figure out what was causing the error.

Followed the same approach and I was able to resolve the error very quickly.

Sometimes I get this error too. I have found that it happens whenever I forget to add a final slash "/" when declaring an assets folder in pubspec.yaml. For example:

This will produce the error:

flutter:
  assets:
    - assets/
    - assets/game_logos

Adding the final slash solves the error:

flutter:
  assets:
    - assets/
    - assets/game_logos/

Removing spaces on the Projects Folder Path Solves the Issue.

Flutter Issues

I got MSB8066 when I generate python bindings, and fixed this by disabling BUILD_PYTHON_BINDINGS in CMakeLists.txt

The solution that worked for me is that I deleted build folder/dir from my project

I faced the same issue due to some errors were there in some of the dart files. Check for red-underlined errors in the dart files you may have missed. These errors don't allow the project to run. After resolving the errors the project is running fine.

Non-Alphanumeric Characters in the project name also cause it.

I played arround with json in my asset folder. I deleted it and missed to remove it from pubspec as well.

Make sure your program has the 'main' function. Missing the 'main' will cause the same problem.

void main(){
 runApp(MyApp());
}

In my case I had an assets image that I removed from the folder but had the path in pubspec.yaml, so I deleted the path then the app could run in Windows.

None of the above methods worked for me. First, I get an export zip file from project. And extract its content. And open it, instead of the main project. Only this worked for me after 1 day. But don't know why!

Related