Search code examples
msbuilddotnet-sdk

Where is IntermediateAssembly set initially?


I want you to ask where IntermediateAssembly is set intially.

I ask for the reason that I want to optimize my assignments to only apply after IntermediateAssembly has been initialized.

Consider the following comparisons:

<Project Sdk="Microsoft.NET.Sdk">
    <ItemGroup>
        <!-- NOT WORKING: list is empty -->
        <ModuleInitializerAssemblyLoaderInjectionTargetAssemblies Include="@(IntermediateAssembly->'%(Identity)')" />
    </ItemGroup>
</Project>
<Project InitialTargets="init" Sdk="Microsoft.NET.Sdk">
  <Target Name="init">
    <ItemGroup>
        <!-- WORKING: list is initialized -->
        <ModuleInitializerAssemblyLoaderInjectionTargetAssemblies Include="@(IntermediateAssembly->'%(Identity)')" />
    </ItemGroup>
  </Target>
</Project>

In dotnet sdk I cannot find the reference where IntermediateAssembly is set intially.


Solution

  • After searching, I have found it here https://github.com/dotnet/msbuild/blob/fdddb27ebec8f6a51513b6e869f039a32d3a8c39/src/Tasks/Microsoft.Common.CurrentVersion.targets#L359.

    It is set in Microsoft.Common.CurrentVersion.targets in an ItemGroup under the Project node.