Dominique
Dominique

Reputation: 17565

How to add logs to "Microsoft.Common.CurrentVersion.targets"?

As mentioned in my previous question, I'm having troubles getting my debugging symbols file created, so I'm trying to add logs in the corresponding target file.

While compiling my project, I see the following in the build output window:

1>Property reassignment: $(_DebugSymbolsProduced)="true" (previous value: "false") at C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets (175,5)

This corresponds with what I see in the corresponding target file (Microsoft.Common.CurrentVersion.targets), hereby with the mentioned line numbers:

173:  <!-- Whether or not a .pdb file is produced. -->
174:  <_DebugSymbolsProduced>false</_DebugSymbolsProduced>
175:  <_DebugSymbolsProduced Condition="'$(DebugSymbols)'=='true'">true</_DebugSymbolsProduced>
176:  <_DebugSymbolsProduced Condition="'$(DebugType)'=='none'">false</_DebugSymbolsProduced>
177:  <_DebugSymbolsProduced Condition="'$(DebugType)'=='pdbonly'">true</_DebugSymbolsProduced>
178:  <_DebugSymbolsProduced Condition="'$(DebugType)'=='full'">true</_DebugSymbolsProduced>
179:  <_DebugSymbolsProduced Condition="'$(DebugType)'=='portable'">true</_DebugSymbolsProduced>
180:  <_DebugSymbolsProduced Condition="'$(DebugType)'=='embedded'">false</_DebugSymbolsProduced>
181:  <_DebugSymbolsProduced Condition="'$(ProduceOnlyReferenceAssembly)'=='true'">false</_DebugSymbolsProduced>

I see that in line 174, the value is set to false, but in line 175, the value is set to true. So, at that point, the compiler is set to generate the debugging symbols (_DebugSymbolsProduced=true).

Later on in the build output window, I see the following:

1>Set Property: _DebugSymbolsProduced=false

... but when looking into the target file (Microsoft.Common.CurrentVersion.targets), I have totally no clue where and why this value is set.

No clue at all? Well, there are the following lines:

    <!-- Record the .pdb if one was produced. -->
    <PropertyGroup>
      <_DebugSymbolsProduced Condition="!Exists('@(_DebugSymbolsIntermediatePath)')">false</_DebugSymbolsProduced>
    </PropertyGroup>

... and indeed there is no entry in the build output log about _DebugSymbolsIntermediatePath, but is this the reason that parameter is set to false?

In order to get an answer, I would like to add additional logs in Microsoft.Common.CurrentVersion.targets, something like this:

  <Log_Output>Investigating ItemGroup _DebugSymbolsProduced. Current value=$(_DebugSymbolsProduced)</Log_Output>
  <ItemGroup Condition="'$(_DebugSymbolsProduced)' == 'true'">
    <Log_Output>Investigating ItemGroup inside tag</Log_Output>
    <_DebugSymbolsIntermediatePath Include="$(IntermediateOutputPath)$(TargetName).compile.pdb" Condition="'$(OutputType)' == 'winmdobj' and '@(_DebugSymbolsIntermediatePath)' == ''"/>
    <_DebugSymbolsIntermediatePath Include="$(IntermediateOutputPath)$(TargetName).pdb" Condition="'$(OutputType)' != 'winmdobj' and '@(_DebugSymbolsIntermediatePath)' == ''"/>
    <_DebugSymbolsOutputPath Include="@(_DebugSymbolsIntermediatePath->'$(OutDir)%(Filename)%(Extension)')" />
  </ItemGroup>

  <Log_Output>Investigating PropertyGroup _DebugSymbolsProduced. Current value=$(_DebugSymbolsProduced)</Log_Output>
  <Log_Output>OutputType=$()</Log_Output>
  <PropertyGroup Condition="'$(_DebugSymbolsProduced)' == 'true' and '$(OutputType)' == 'winmdobj'">
    <Log_Output>Investigating PropertyGroup inside tag</Log_Output>
    <WinMDExpOutputPdb Condition="'$(WinMDExpOutputPdb)' == ''">$(IntermediateOutputPath)$(TargetName).pdb</WinMDExpOutputPdb>
    <_WinMDDebugSymbolsOutputPath>$([System.IO.Path]::Combine('$(OutDir)', $([System.IO.Path]::GetFileName('$(WinMDExpOutputPdb)'))))</_WinMDDebugSymbolsOutputPath>
  </PropertyGroup>

and:

    <!-- Record the .pdb if one was produced. -->
    <Log_Output>Investigating explicit PropertyGroup. Before: _DebugSymbolsProduced. Current value=$(_DebugSymbolsProduced)</Log_Output>
    <Log_Output>Investigating explicit PropertyGroup. Before: _DebugSymbolsIntermediatePath. Current value=$(_DebugSymbolsIntermediatePath)</Log_Output>
    <PropertyGroup>
      <_DebugSymbolsProduced Condition="!Exists('@(_DebugSymbolsIntermediatePath)')">false</_DebugSymbolsProduced>
    </PropertyGroup>
    <Log_Output>Investigating explicit PropertyGroup. After: _DebugSymbolsProduced. Current value=$(_DebugSymbolsProduced)</Log_Output>

Obviously, <Log_Output> does not exist :-)
What tag can I use to add additional logs to the Microsoft.Common.CurrentVersion.targets target file in order to know why that value is set to false?

Upvotes: 0

Views: 45

Answers (0)

Related Questions