Generator expressions in VS_DOTNET_REFERENCE_refname

Are generator expressions supported for the VS_DOTNET_REFERENCE_refname target property?

This is how I tried to use it:

# the `some` is a C# library which needs to refer to the DLL from the target `thing`
set_target_properties(some
    PROPERTIES
        VS_DOTNET_REFERENCE_thing "$<TARGET_FILE:thing>"
)

but that results in the following inside the generated some.csproj:

<ItemGroup>
    <Reference Include="thing">
      <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
      <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
      <Private>True</Private>
      <HintPath>E:\path\to\my\project\$&lt;TARGET_FILE:thing&gt;</HintPath>
    </Reference>
  </ItemGroup>

so it does not get evaluated (but at least it gets “HTML-encoded”, so the project file is not “broken”).

This apparently means that generator expressions are not supported for the VS_DOTNET_REFERENCE_<refname> target property? A follow-up question would be how can one know whether a particular target property supports generator expressions or not?

The general rule is that generator expressions are not supported unless the documentation explicitly says so. The only exception to that that I can think of is test properties, where all test properties support generator expressions and are not individually documented as so.

1 Like