Visual Studio build successful, MSBuild fails

后端 未结 7 2440
有刺的猬
有刺的猬 2021-02-19 02:08

I am trying to clean and rebuild a solution file with multiple projects from the command line using MSBUILD. For some reason my build fails (about 10% of the built projects fail

7条回答
  •  独厮守ぢ
    2021-02-19 02:43

    Summary: Set Debug/Release mode in Visual Studio to the same settings as MSBuild to check for compilation errors.

    I encountered the same problem:

    • Tried deleting all "bin" and "obj" folders.

    • Made sure all related projects are indeed being referenced and not just liked to compiled dlls. ex. Project B references A. Remove A from solution. Then add again. B would then reference A but via compiled dll only. Remove reference and re-add the project.

    Finally switched to "Release" in Visual Studio. Turns out I had conditional compilation in some code (eg. #if DEBUG). So what was running in MSBuild and Visual Studio were actually different hence the error "The type or namespace name 'foo' does not exist in the namespace 'bar' (are you missing an assembly reference?)"

提交回复
热议问题