MSB4018 horror (not a simple error)

Guglielmo Cancelli 5 Reputation points
2023-11-20T17:57:32.81+00:00

I would like to report that for a few days now, even when creating a new empty VB solution with only the default form, when I try to compile I always get MSB4018, which obviously doesn't make any sense, being the default project.

I tried repairing the VS2022 installation but that did not change the result. Not even running InstallCleanup and then performing a clean re-installation changed anything.

A few days earlier I had done an update of VS.

In short, I can no longer code! 🤬

I'm using win10

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

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 32,146 Reputation points Microsoft Vendor
    2023-11-21T02:43:56.5766667+00:00

    Hello @Guglielmo Cancelli ,

    Welcome to Microsoft Q&A forum.

    Please try following to clean some cache files and fix any corrupted files first.

    1. Run CMD as administrator, run DISM.exe /Online /Cleanup-image /Restorehealth command, wait for it finishes running, run sfc /scannow command.
    2. Navigate to C:\Users\{username}\AppData\Local\Microsoft\VisualStudio\17.0_XXXXXXXX folder, rename this folder.
    3. Reboot your machine and rename %Temp% folder(C:\Users\{username}\AppData\Local\Temp).
    4. Update Windows OS and make sure that there’s no Windows Update Errors.
    5. Launch VS as administrator, create a new project and check again.

    Besides, do you have full permissions on your machine(please check following: antivirus, group policy, permission limitations)? Does running VS as administrator work?

    If there are more detailed error messages, please share them with us to check further.

    Best Regards,

    Tianyu


    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.


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.