首页 > 解决方案 > 仅具有自定义目标的最小 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>

现在还有两个问题:

标签: visual-studiomsbuildtarget

解决方案


使用 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" />

推荐阅读