How to fix 'error MSB4018: The “VCMessage” task failed unexpectedly' in Visual Studio 2013

前端 未结 2 536
梦谈多话
梦谈多话 2021-01-11 18:06

This is what I see:

1>------ Build started: Project: xxx (xxx\\xxx), Configuration: Debug Win32 ------
1>C:\\Program Files (x86)\\MSBuild\\Microsoft.Cp         


        
相关标签:
2条回答
  • 2021-01-11 18:24

    The Fix

    The error was due to the project configuration field Platform Toolset being empty. (The .vcproj project file should list a value such as v120 here)

    Before:

    <PlatformToolset>
    </PlatformToolset>
    

    After:

    <PlatformToolset>v120</PlatformToolset>
    

    This value can be set in DevStudio via project Properties panel > Configuration Properties > General > Platform Toolset :: pick one of the values from the dropdown there.


    The way this was uncovered:

    • create an empty new project in MSVC2013 of the same type

    • use Beyond Compare (or another visual diff tool which can easily edit the files being compared by copying chunks across) to copy the files set across and test (by reloading into DevStudio and running the build process in there).

    • next copy across bits of the project settings (and duplicate the blocks if your original project has multiple build targets like mine had (Win32/x64/Itanium)), test again.

    • rinse and repeat the above until your 'new' project exhibits the same issue as the old one. Narrow down to a minimal XML subset in the .vcproj file.


    Related SO questions and blogs which were tried before all this:

    • How do I fix Error MSB4018 in Visual Studio 2010?
    • https://connect.microsoft.com/VisualStudio/feedback/details/757884/msb4018-with-a-backslash-after-target-name-in-project-settings (Well, the issue is still there... only maybe in a slightly different incantation. My trouble happened on MSVC2013 with all updates as per March/2015)
    • http://marlowa.blogspot.nl/2013/09/a-nasty-net-error-in-visual-studio-2010.html

    The conclusion: if you run into this issue, check all your project configuration entries. And when push comes to shove, dig the bugger out by the above compare-and-test divide-and-conquer process.

    0 讨论(0)
  • 2021-01-11 18:36

    In Visual Studio 2013, you get this error when trying to compile a program created in a project with incorrect settings. For me, this happened when I clean up my installation. If you are trying to clear your temporal files and go to C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\layout and execute the program InstallCleanup.exe it seems to delete temporal files but also your settings. In particular the type of project you are creating.

    How to reproduce the error:

    If you do "New Project" it will display some options 1) Atl 2) CLR 3) General 4) Win 32. You must select Win 32 and then pick Win32 console or Win32 project. By default, it selects something else, then after creating the project you will realize that Properties -> Linker -> System -> Subsystem is empty when it should be /SUBSYSTEM:CONSOLE (or /SUBSYSTEM:WIN32).

    After fix this and try to compile it will generate the MSB4018 error.

    In summary, the solution is to create again the project and verify that the settings are correctly set as explained.

    0 讨论(0)
提交回复
热议问题