Visual Studio 经常重新构建,IntelliSense 失效。

3
问题

1) Visual Studio无论源代码是否更改,都会不断重建每个项目。 2) Intellisense也出现了问题。 每个命令都会显示“没有可用的其他信息”错误。 3) Visual Studio显示错误E1696无法打开源文件“CURRENTLYOPENSOURCEFILEINCAPS.CPP”,尽管成功构建了该项目。 错误图标与导致构建失败的错误不同。

我所做的事情

我已启用诊断输出。 对于零检查cmake目标,它无法找到一个生成.stamp.rule,我已经检查过,在构建之前存在,并且未被删除和重新生成,文件路径是正确的。 所有单独的项目都有类似的存在文件,但Visual Studio说它们丢失了。

我已经阅读了许多Stack Overflow帖子以使intellisense再次正常工作,但什么都没有起作用。 当使用解决方案资源管理器打开所有文件时,其中原来有文件路径的地方现在都显示“(全局范围)”。

我已经使用msbuild进行了构建,它说“正在创建“x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild”,因为指定了“AlwaysCreate”。 我不知道为什么要指定AlwaysCreate。 我读到如果#include尝试包含不存在的内容,就会发生这种情况,但我不明白它是如何编译的 - 无论如何,这是一个大型代码库,如果这是原因,那么肯定检查先前提交的时候没有问题的应该可以解决它 - 但是没有。

我有一个源外构建,所以我尝试删除它并重新CMaking一切,以便清除所有缓存变量。

我尝试将每个设置重置为出厂设置。

我已禁用并行构建。

我以管理员模式运行。

我已删除我的存储库和构建输出中的所有内容,并重新克隆并检出在此之前发生的过去提交。

我尝试将源代码复制到另一个驱动器,并在驱动器的不同文件夹深度上进行了尝试。

我尝试卸载并重新安装Visual Studio两次。

可以确认,创建新的虚拟项目不会出现上述3个问题。

我尝试了删除所有内容,重置VS,重新安装VS,克隆之前工作的提交,cmaking,以管理员身份构建vs,在管理员身份下构建vs,仍然存在所有3个问题。

诊断输出中的第一个失败点

1>------ Up-To-Date check: Project: ZERO_CHECK.vcxproj, Configuration: Debug x64 ------
1>Project is not up-to-date: build input 'e:\blabla\blabuilddir\cmakefiles\66f04b81c84059a8a3158e97cbfec9b8\generate.stamp.rule' is missing.

这不是必须的。
在决定/执行AlwaysCreate操作之前,还有更多输出。
>Done building target "_HandlePackageFileConflicts" in project "ALL_BUILD.vcxproj".
16>Target "ResolveAssemblyReferences" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets":
16>  Added Item(s): 
16>      _ReferenceInstalledAssemblyDirectory=
16>          C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
16>          C:\Program Files (x86)\Windows Kits\10\References
16>  Set Property: ResolveAssemblyReferencesStateFile=x64\Debug\ALL_BUILD\ALL_BUILD.vcxprojAssemblyReference.cache
16>  Set Property: ResolveAssemblyReferencesSilent=false
16>  Set Property: ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch=Warning
16>  Set Property: FindDependenciesOfExternallyResolvedReferences=false
16>  Task "ResolveAssemblyReference" skipped, due to false condition; ('@(Reference)'!='' or '@(_ResolvedProjectReferencePaths)'!='' or '@(_ExplicitReference)' != '') was evaluated as (''!='' or ''!='' or '' != '').
16>Done building target "ResolveAssemblyReferences" in project "ALL_BUILD.vcxproj".
16>Target "GenerateBindingRedirects" skipped, due to false condition; ('$(AutoGenerateBindingRedirects)' == 'true' and '$(GenerateBindingRedirectsOutputType)' == 'true') was evaluated as ('' == 'true' and 'true' == 'true').
16>Target "_RemoveZipFileSuggestedRedirect" skipped, due to false condition; ('$(_TargetFrameworkVersionWithoutV)' >= '4.7.1' And '$(AllowZipFileRedirect)' != 'true') was evaluated as ('4.0' >= '4.7.1' And '' != 'true').
16>Target "GenerateBindingRedirectsUpdateAppConfig" skipped, due to false condition; ('$(AutoGenerateBindingRedirects)' == 'true' and '$(GenerateBindingRedirectsOutputType)' == 'true' and Exists('$(_GenerateBindingRedirectsIntermediateAppConfig)')) was evaluated as ('' == 'true' and 'true' == 'true' and Exists('x64\Debug\ALL_BUILD\ALL_BUILD.config')).
16>Target "ResolveComReferences" skipped, due to false condition; ('@(COMReference)'!='' or '@(COMFileReference)'!='') was evaluated as (''!='' or ''!='').
16>Target "AfterResolveReferences" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets":
16>Done building target "AfterResolveReferences" in project "ALL_BUILD.vcxproj".
16>Target "ImplicitlyExpandDesignTimeFacades" skipped, due to false condition; ('$(ImplicitlyExpandDesignTimeFacades)' == 'true') was evaluated as ('' == 'true').
16>Target "ResolveTestReferences" skipped, due to false condition; ('@(Shadow)'!='') was evaluated as (''!='').
16>Target "ResolveReferences" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets":
16>Done building target "ResolveReferences" in project "ALL_BUILD.vcxproj".
16>Target "PrepareForBuild" skipped. Previously built successfully.
16>Target "PrepareForBuild" skipped. Previously built successfully.
16>Target "InitializeBuildStatus" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppBuild.targets":
16>  Task "ReadLinesFromFile"
16>    Task Parameter:File=x64\Debug\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate
16>    Output Item(s): 
16>        _ReadProjectStateLine=
16>            #TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
16>            Debug|x64|E:\blaWork\bla\blaBuild-win64-vc15\|
16>  Done executing task "ReadLinesFromFile".
16>  Set Property: ProjectStateLine=#TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
16>  Set Property: StateBuildType=Build
16>  Task "WriteLinesToFile"
16>    Task Parameter:Overwrite=True
16>    Task Parameter:File=x64\Debug\ALL_BUILD\ALL_BUILD.tlog\ALL_BUILD.lastbuildstate
16>    Task Parameter:
16>        Lines=
16>            #TargetFrameworkVersion=v4.0:PlatformToolSet=v141:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0.17763.0
16>            Debug|x64|E:\blaWork\bla\blabuild-win64-vc15\|
16>  Done executing task "WriteLinesToFile".
16>  Task "Touch"
16>    Task Parameter:AlwaysCreate=True
16>    Task Parameter:Files=x64\Debug\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild
16>    Touching "x64\Debug\ALL_BUILD\ALL_BUILD.tlog\unsuccessfulbuild".
16>  Done executing task "Touch".
16>Done building target "InitializeBuildStatus" in project "ALL_BUILD.vcxproj".

请接受我诚挚的点赞!最后一个已知的良好状态是什么?你认为它在上次工作和现在之间发生了什么?它曾经工作过吗? - Bathsheba
1
请提供一个最小可重现示例(MRE),复制您的项目,尽可能删除其中的内容,直到问题消失,然后在此处发布您的CMake文件。 - Alan Birtles
禁用智能感知,比它带来的麻烦更多。但是Alan是对的,如果你真的想找到问题的根源,你需要找到错误引入的确切位置。在那些工作正常的空项目和不工作的完整项目之间,存在一个问题开始的点。你需要找到那个点。 - john
@Bathsheba,它大约在两周前就能正常工作。尝试的解决方案之一是检查旧提交版本,在那个版本中它能正常工作,但这并没有解决问题。 - codeMetis
@john Intellisense和Visual Studio的调试器是唯一阻止我完全在Vim上开发的东西:p - codeMetis
2个回答

0

作为代码Metis解决方案的补充,您可以在PowerShell中运行以下命令,而不是针对项目的每个子目录手动运行命令:

(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ disable}

这将递归地将fsutil命令应用于当前目录的所有子目录。


0

该问题显然是由于Windows的大小写敏感实现有问题引起的。

背景 我在各种Linux/Windows平台上工作,所以当我了解到Windows大小写敏感性时,我很兴奋,并在大约两周前尝试了一下。在启用存储库文件夹的大小写敏感性后,cmake无法再找到编译器,我没有时间弄清楚原因,因此将其切换回去。我使用的命令不是递归的,因此我必须没有禁用所有启用的文件夹,因此仍然存在某些大小写敏感性。

解决我的问题的步骤:

  1. 在管理员模式下运行Windows PowerShell
  2. fsutil.exe file setCaseSensitiveInfo C:\folder disable
  3. 从驱动器到最深的源代码文件的每个目录级别上重复执行第2步操作。

应该有一个递归标志之类的东西,但如果没有,可以很容易地通过PowerShell循环遍历文件夹,但我现在不想费心去正确获取语法。

此处有关于Windows大小写敏感性的更多信息


干得好。完全同意关于Visual Studio调试器的看法,但是在我看来,Intellisense太不稳定了,而且占用资源太多。 - john
嗨,codeMetis,感谢您的分享,请将您的回复标记为答案,这将有助于其他社区成员更轻松地搜索到这些有用的信息,这只是一个提醒 :) - Sara Liu - MSFT

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接