Skip to content

Improve handling of source files with special extensions in .csproj

Michael Stürmer requested to merge stuermic/cmake:csproj-improvements into master

Ok, this is the last MR for C# support for the time being. This is the full C# support we use for our projects.

It mainly adds some <Link> and <DependentUpon> tags to the generated .csproj files so the generators & UI editors of Visual Studio know the connections. As an example this means: if I have a C# target with a two files #name.Designer.cs and #name.settings something like this will be generated:

    <Compile Include="#cmake-current-source-dir\Properties\#name.Designer.cs" >
      <AutoGen>True</AutoGen>
      <DependentUpon>#name.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
      <Link>Properties\#name.Designer.cs</Link>
    </Compile>
...
    <None Include="#cmake-current-source-dir\Properties\#name.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <LastGenOutput>Properties\#name.Designer.cs</LastGenOutput>
      <Link>Properties\#name.settings</Link>
    </None>

There are also some source file properties introduced which are closely related to C#:

  • VS_RESOURCE_GENERATOR allows setting the generator for resources
  • VS_COPY_TO_OUT_DIR can be used to finetune when the file should be copied to the output directory. For me this turned out to be espcially helpful when developing VSIX extensions
  • VS_INCLUDE_IN_VSIX allows adding the source file to VSIX packages (I use it for resource files like images etc.)

Merge request reports