VS中warning MSB8004和error MSB4018解決方案

糖醋麻辣蝦發表於2018-01-18

問題如下:

 

warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.

其實這個問題很簡單,因為把英文翻譯過來即可,輸出路徑結尾缺少一個反斜線。

 

解決方案:專案-專案屬性-配置屬性-常規-輸出路徑,現在的路徑是下圖這樣的:

 將其改為

即可。

 

問題如下:

 

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.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)

   at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray 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>d__20.MoveNext()

大概錯誤是這個樣子的,這個錯誤主要是在連結器的輸出路徑中,我是從一篇文章中看到的解決方案的,文章原地址如下:

https://stackoverflow.com/questions/11985085/how-do-i-fix-error-msb4018-in-visual-studio-2010/17771120

 

解決方案:專案-專案屬性-配置屬性-連結器-常規-輸出檔案,原來是如下圖的樣子

 

點選<繼承>的那個選項,得到結果如下圖所示:

再次執行,成功!希望能對一些人有所幫助,如有問題希望各位多指教。

相關文章