我有一个WebApplication包含引用WCF服务。
在使用Visual Studio 2010构建时,构建失败,没有任何错误或警告。但是使用MsBuild构建.csproj是成功的。
不知道我应该在Visual Studio中尝试什么来解决/诊断问题。你能帮帮我吗?
我发现构建一直在失败,
从状态栏中显示的文本。
从输出窗口:
========== 构建:0成功或更新,1失败,0跳过 ==========
输出选项卡包含配置详细信息。
------构建开始:项目:<projectName here>配置:调试任何CPU
这里有一些你可以尝试的方法:
If your solution contains more than one project, try building each project one at a time. (You may even want to try opening each project independently of the solution.)
If applicable, ensure that all of your projects (including dependencies and tests) target the same version of the .NET Framework. (Thanks to user764754 for this suggestion!)
Tip: Check Tools → Extension and Updates to ensure that your packages are up-to-date.
Ensure that all dependency projects are built to target the same platform as your main project.
Try restarting Visual Studio.
As suggested by Bill Yang, try running Visual Studio as Administrator, if you aren't already. (If you are already running Visual Studio as Administrator, perhaps try the opposite?)
Try restarting your computer.
Try "Rebuild All".
Run "Clean Solution", then remove your *vspscc* and *vssscc* files, restart Visual Studio, and then "Rebuild All".
As suggested by Andy, close Visual Studio, delete the .suo file, and restart Visual Studio.
As suggested by Arun Prasad E S, close Visual Studio, delete the .vs folder in your solution directory, and then re-open Visual Studio. (This folder is auto-generated by Visual Studio and contains cache, configuration settings, and more. More details can be found in these questions: Visual Studio - Deleting .vs folder and https://stackoverflow.com/q/48897191.)
As suggested by MrMalith, close Visual Studio, delete the obj folder in your solution directory, clear your temporary folder, and then re-open Visual Studio.
我注意到,如果在错误列表中选择了“构建+智能感知”,它会导致错误消息被吞噬。
将此选项更改为“Build Only”,将显示所有错误消息:
我不知道这是否是Visual Studio中的bug,但它确实揭示了隐藏的错误消息,这是确定失败的关键。
有些人,比如Richard J Foster,建议将“MSBuild项目构建输出详细信息”设置为“诊断”(可能的最高选项),但这并没有为我解决问题,因为Visual Studio似乎在抑制错误消息本身。
作为一种替代方法,您可以尝试使用来自“output”选项卡的原始输出消息,这些消息没有被Visual Studio过滤。要么就地搜索字符串"error"和/或"failed",要么将所有输出复制到您最喜欢的文本编辑器并在那里进行搜索。
为了确保每次构建时都出现输出窗口,您可以转到工具→选项→项目和解决方案→常规,并确保选中“在构建开始时显示输出窗口”选项。
作为额外的故障排除步骤,还可以通过运行dotnet build从PowerShell命令行构建项目。这将向您显示完整的构建输出,包括Visual Studio可能隐藏的任何错误。