13

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.

aihamhasan
  • 479
  • 1
  • 6
  • 11

19 Answers19

27

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.

ouflak
  • 2,458
  • 10
  • 44
  • 49
Atul Chaudhary
  • 1,491
  • 2
  • 15
  • 23
  • 1
    This solution worked perfectly. The exact error is shown while running this command in terminal. Thanks. – Sankar Arumugam Sep 30 '21 at 13:05
  • 1
    This solution helps me to know where the issue was. In my case after doing this, only need to perform flutter pub upgrade --major-version due the issue was at some outdated dependencies, specially win32, that was causing the error. Thanks so much again. – CNK Jan 06 '23 at 08:25
11

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/
gustgon1212
  • 177
  • 1
  • 9
  • 1
    Yeap, that was it. And just a heads up for others: If you added any asset path to your `pubspec.yaml` and suddenly start to see this error, try this before anything else. – KHAN Aug 06 '22 at 19:16
3

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.

Wilson Toribio
  • 990
  • 1
  • 4
  • 15
2

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

teminali
  • 21
  • 2
2

This can happen for a few reasons, an asset's path is missing the slash: So: assets: assets/image

While it should be like this: assets: assets/image/

With the slash at the end.

The other more normal one, and which could really be causing such an error, could be the following;

The directory your project is in contains a special character, for example:

C:\Users\Aurélio Fernam\Documents\Projets\my_project

As you can see, "Aurélio" contains a special character. This could be causing this error.

Also try not to have a folder with space in your project path, like this:

C:\Users\Aurélio Fernam\Documents\Projets\my_project

Notice that "Aurélio Fernando/" besides having a special character, contains a space.

This could also be a trigger.

After having moved the project to a better directory, run flutter clean and run the project normally.

1

Removing spaces on the Projects Folder Path Solves the Issue.

Flutter Issues

aihamhasan
  • 479
  • 1
  • 6
  • 11
1

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

ZQ.Chai
  • 11
  • 2
1

I got this error

C:\dev..\client\build\windows\CMakeFiles\0950da8beda6981876b8c7492aa5c9b3\flutter_windows.dll.rule;C:\dev..\client\build\windows\CMakeFiles\4176b1834887218866857c2082a6e590\flutter_assemble.rule" �����訫� ��� � ����� 1. [C:\dev..\client\build\windows\flutter\flutter_assemble.vcxproj] Exception: Build process failed.

The problem was in pubspec.yaml, the link to the image was duplicated in assets:

assets:
    - assets/images/
    - assets/images/iconMars40.png
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
1

simple steps to remove this error

1)flutter clean 2)flutter pub get

This will help u to make your project free from this error.

0

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.

0

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

Flashman VC
  • 63
  • 1
  • 7
0

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

Thoxh
  • 149
  • 9
0

Deleting the build folder in my project fixed the issue for me, you can also run a flutter clean, then run your project again.

Gwhyyy
  • 7,554
  • 3
  • 8
  • 35
0

In my case I use:

flutter pub get
0

I uninstalled Visual Studio BuildTools and re-installed it again, then it worked.

I only installed BuildTools (not fully installed Visual Studio). So if you installed fully Visual Studio, you can try to uninstall and re-install fully Visual Studio.

0

check if you have recently create file or added new dependencies in pubspec.yaml if it's the cas then delete them. It worked for me.

0

I had the same error, upgrade packages to latest version in pubspec.yaml solved error.

0

you can fix with

dart fix

and reload the project

Mucahit
  • 1
  • 3
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 18 '23 at 07:33
-1

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!


UPDATE: This error fix for me when run Android Studio as administrator.

Maysam R
  • 915
  • 10
  • 12