Report error/warning if missing files in project/solution in Visual Studio

后端 未结 4 1668
谎友^
谎友^ 2020-12-31 11:45

Is there a way for Visual Studio to report an error/warning when you build a solution that has missing files (yellow triangle icon with exclamation) that do have necessarily

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-31 11:56

    If you happen to have a linux-like environment with access to the project folder (for instance, if you use git for version control, you can probably use the included Git Bash for this, or if you use Cygwin), here's my really quick and dirty way:

    grep ' /dev/null
    

    (How this works: I try to ls every file named in the project, and send the stdout output of the ls command to /dev/null, so it will be hidden. If any files do not exist, ls will barf their names to stderr rather than stdout, so those will be visible.)

    Note that this doesn't understand URL-encoded escapes, so you will get a few false positives if your project contains filenames with characters like '(' in them.

提交回复
热议问题