<Project DefaultTargets="CreateLib" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <IlcCompileDependsOn>ComputeIlcCompileInputs;BuildOneFrameworkLibrary;SetupOSSpecificProps</IlcCompileDependsOn>
    <CreateLibDependsOn>BuildAllFrameworkLibrariesAsSingleLib</CreateLibDependsOn>
    <IlcMultiModule>true</IlcMultiModule>
    <NativeIntermediateOutputPath Condition="'$(FrameworkObjPath)' != ''">$(FrameworkObjPath)\</NativeIntermediateOutputPath>
    <BuildingFrameworkLibrary>true</BuildingFrameworkLibrary>
    <Optimize Condition="'$(Configuration)' == 'Release' and '$(Optimize)' == ''">true</Optimize>
    <DebugSymbols Condition="'$(DebugSymbols)' == ''">true</DebugSymbols>
    <_targetOS>$(TargetOS)</_targetOS>
    <_targetOS Condition="$(_targetOS.StartsWith('win'))">win</_targetOS>
    <_targetArchitecture>$(TargetArchitecture)</_targetArchitecture>
  </PropertyGroup>

  <Import Project="$(MSBuildThisFileDirectory)\Microsoft.DotNet.ILCompiler.SingleEntry.targets" />

  <Target Name="BuildAllFrameworkLibraries"
    DependsOnTargets="$(IlcDynamicBuildPropertyDependencies)"
    Inputs="@(DefaultFrameworkAssemblies)"
    Outputs="@(DefaultFrameworkAssemblies->'$(NativeIntermediateOutputPath)\%(Filename)$(NativeObjectExt)')">
    <ItemGroup>
      <ProjectToBuild Include="$(MSBuildProjectFullPath)">
        <AdditionalProperties>
          LibraryToCompile=%(DefaultFrameworkAssemblies.Identity)
        </AdditionalProperties>
      </ProjectToBuild>
    </ItemGroup>
    <MSBuild Projects="@(ProjectToBuild)" Targets="IlcCompile" BuildInParallel="true" />
  </Target>

  <Target Name="BuildAllFrameworkLibrariesAsSingleLib"
    DependsOnTargets="BuildAllFrameworkLibraries">
    <ItemGroup>
      <LibInputs Include="$(NativeIntermediateOutputPath)\*$(NativeObjectExt)" />
    </ItemGroup>
  </Target>

  <Target Name="BuildOneFrameworkLibrary">
    <PropertyGroup>
      <IlcGenerateMetadataLog>true</IlcGenerateMetadataLog>
    </PropertyGroup>
    <ItemGroup>
      <ManagedBinary Include="$(LibraryToCompile)" />
      <IlcCompileInput Include="@(ManagedBinary)" />
    </ItemGroup>
  </Target>

</Project>
