Minimal Visual Studio project with custom target only: Disable IntelliSense and allow single file processing?

Viewed 451

For our Visual Studio Solution, I want to create one project that just generates some files with custom scripts. I have a somewhat-working solution, further reduced to provide as an example here:

This is my 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>

And I need this minimal.vcxproj.filters to make the three contained files show up in VS's solution explorer:

<?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>

Now there are still two problems:

  • When loading the project, I get 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 is error MSB4057: The target "GetClCommandLines" does not exist in the project. Of course IntelliSense doesn't make sense here (TYPE is just a placeholder for a custom script), but there must be a way of getting rid of this warning.

  • Build (e.g. via F7) works like a charm (even incremental), but it would be really important for us to trigger processing single files (e.g. CtrlF7). But I can't find out how to make this work.

1 Answers

Using Visual Studio 2019, I needed to add the following targets to have the project load without warnings. This was done by checking the designtime logs and incrementally adding targets, until there were no more warnings.

  <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" />
Related