How do I fix Error MSB4018 in Visual Studio 2010?

11,275

I had the same problem. I had an old Visual Studio 2005 C++ project, which I reopened with Visual Studio 2010 C++. For me, the first suggestion proposed at Microsoft Connect worked:

The issue stems from the unexpected $(TargetDir) found in the property page under Link->OutputFile. During the build process, we tried to expand the OutputFile to a fullpath but only got an empty value. Thus, it led to the index out-of-bound exception.

It is unlikely we will be able to fix these before VS2010 release. The workaround is to correct OutputPath or inherit from parent.

Right-click on the project and go to Properties > Linker > General. Then set "Output File" to "<Inherit from parent or project defaults>"

Hope that fixes it for you too.

Share:
11,275

Related videos on Youtube

TahaYusuf
Author by

TahaYusuf

Updated on September 16, 2022

Comments

  • TahaYusuf
    TahaYusuf over 1 year

    error MSB4018: The "VCMessage" task failed unexpectedly. System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) at System.String.Format(IFormatProvider provider, String format, Object[] args) at Microsoft.Build.Shared.ResourceUtilities.FormatString(String unformatted, Object[] args) at Microsoft.Build.Utilities.TaskLoggingHelper.FormatString(String unformatted, Object[] args) at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args) at Microsoft.Build.Utilities.TaskLoggingHelper.LogWarningWithCodeFromResources(String messageResourceName, Object[] messageArgs) at Microsoft.Build.CPPTasks.VCMessage.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 990 6 vtk_minimal

  • Kiran Pagar
    Kiran Pagar over 9 years
    Excellent, I changed the Output file path and change it back the way it was, and it started working for all solutions.