visual-studio - 仅具有自定义目标的最小 Visual Studio 项目:禁用 IntelliSense 并允许单个文件处理?
问题描述
对于我们的 Visual Studio 解决方案,我想创建一个项目,它只生成一些带有自定义脚本的文件。我有一个可行的解决方案,进一步简化以在此处提供示例:
这是我的minimal.vcxproj
:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Universal|Win32">
<Configuration>Universal</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="common.fooconf" />
</ItemGroup>
<ItemGroup>
<Foo Include="file1.foo" />
<Foo Include="file2.foo" />
</ItemGroup>
<Target Name="Build" Inputs="common.fooconf;@(Foo)" Outputs="Output\%(Foo.Filename).bar">
<MakeDir Directories="Output" />
<Exec Command='TYPE "common.fooconf" "%(Foo.FullPath)" > "Output\%(Foo.Filename).bar"' />
</Target>
<Target Name="Clean">
<RemoveDir Directories="Output" />
</Target>
<Target Name="Rebuild" DependsOnTargets="Clean;Build" />
</Project>
我需要这个minimal.vcxproj.filters
来使三个包含的文件显示在 VS 的解决方案资源管理器中:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="common.fooconf"/>
</ItemGroup>
<ItemGroup>
<Foo Include="file1.foo"/>
<Foo Include="file2.foo"/>
</ItemGroup>
</Project>
现在还有两个问题:
加载项目时,我得到
error : Designtime build failed for project '[...]\minimal.vcxproj' configuration 'Universal|Win32'. IntelliSense might be unavailable. Check *.designtime.log files in your %TEMP% directory.
If I look up in the log, the error iserror MSB4057: The target "GetClCommandLines" does not exist in the project.
当然 IntelliSense doesn't make sense here (TYPE is just a placeholder for a custom script),但一定有办法摆脱这个警告。构建(例如 via )就像一个魅力(甚至是增量),但触发处理单个文件(例如)F7对我们来说非常重要。CtrlF7但我不知道如何使这项工作。
解决方案
使用 Visual Studio 2019,我需要添加以下目标以在没有警告的情况下加载项目。这是通过检查设计时日志并逐步添加目标来完成的,直到没有更多警告为止。
<Target Name="GetProjectDirectories" />
<Target Name="GetClCommandLines" />
<Target Name="GetGeneratedFiles" />
<Target Name="GetAssemblyReferences" />
<Target Name="GetWinMDReferences" />
<Target Name="GetComReferences" />
<Target Name="GetSDKReferences" />
<Target Name="GetProjectReferences" />
<Target Name="GetForeignReferences" />
<Target Name="GetResolvedReferences" />
<Target Name="GetResolvedSDKReferences" />
<Target Name="GetProjectReferencesInfo" />
<Target Name="GetResolvedLinkLibs" />
推荐阅读
- javascript - 嵌套多层异步/等待似乎不等待
- javascript - 传递给函数的值变得未定义
- r - 将字符串添加为具有定义函数的公式
- ios - 首次启动应用程序 Xcode 11 iOS 13 后如何使入职场景消失
- java - 包文件夹在哪里?那应该存储在android设备中吗?
- javascript - select2,无法选择 AJAX 结果
- java - 从firebase获取坐标以绘制折线
- javascript - 将 JavaScript 变量发送到 PHP
- java - 用户输入不是调用方法(Java)
- python - 如何使用 distinct() 为 Django ListView 中的每个标题项仅显示来自子模型的一条记录