<commit_before><!--
***********************************************************************************************
Microsoft.NET.Sdk.DefaultItems.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

Copyright (c) .NET Foundation. All rights reserved. 
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>

  <PropertyGroup>
   <EnableDefaultItems Condition=" '$(EnableDefaultItems)' == '' ">true</EnableDefaultItems>
   <EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">true</EnableDefaultCompileItems>
    <EnableDefaultEmbeddedResourceItems Condition=" '$(EnableDefaultEmbeddedResourceItems)' == '' ">true</EnableDefaultEmbeddedResourceItems>
    <EnableDefaultNoneItems Condition=" '$(EnableDefaultNoneItems)' == '' ">true</EnableDefaultNoneItems>
  </PropertyGroup>

  <PropertyGroup>    
    <!-- Set DefaultItemExcludes property for items that should be excluded from the default Compile, etc items.
         This is in the .targets because it needs to come after the final BaseOutputPath has been evaluated. -->
    
    <!-- bin folder, by default -->
    <DefaultItemExcludes>$(DefaultItemExcludes);$(BaseOutputPath)/**</DefaultItemExcludes>
    <!-- obj folder, by default -->
    <DefaultItemExcludes>$(DefaultItemExcludes);$(BaseIntermediateOutputPath)/**</DefaultItemExcludes>

    <!-- Various files that should generally always be ignored -->
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.user</DefaultItemExcludes>
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.*proj</DefaultItemExcludes>
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.sln</DefaultItemExcludes>
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.vssscc</DefaultItemExcludes>
    
    <!-- WARNING: This pattern is there to ignore folders such as .git and .vs, but it will also match items included with a
         relative path outside the project folder (for example "..\Shared\Shared.cs").  So be sure only to apply it to items
         that are in the project folder. -->
    <DefaultItemExcludesInProjectFolder>$(DefaultItemExcludesInProjectFolder);**/.*/**</DefaultItemExcludesInProjectFolder>

    <!-- TODO: Verify why this was originally added and whether we really need it -->
    <DefaultItemExcludes>$(DefaultItemExcludes);packages/**</DefaultItemExcludes>
    
  </PropertyGroup>

  <!-- Set the default versions of the NETStandard.Library or Microsoft.NETCore.App packages to reference.
       The implicit package references themselves are defined in Microsoft.NET.Sdk.props, so that they can be overridden
       in the project file. -->
  <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard' And '$(NetStandardImplicitPackageVersion)' == ''">
    <NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
  </PropertyGroup>
  
  <!--
    Determine the NetCoreImplicitPackageVersion and RuntimeFrameworkVersion
    
    The RuntimeFrameworkVersion is the version that is written to the runtimeconfig.json, and is the version of the runtime
    that the app should run on.
    
    If RuntimeFrameworkVersion is not set, then derive the RuntimeFrameworkVersion from the TargetFrameworkVersion,
    and use the latest known version of Microsoft.NETCore.App as the NetCoreAppImplicitPackageVersion, unless that
    property is already set.
    
    If RuntimeFrameworkVersion is set, then use that version for the NetCoreAppImplicitPackageVersion, unless
    NetCoreAppImplicitPackageVersion is already set.
    
  -->

  <Choose>
    <When Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(RuntimeFrameworkVersion)' == ''">
      <PropertyGroup>
        <!-- Use the version of the framework runtime matching the target framework version-->
        <RuntimeFrameworkVersion>$(_TargetFrameworkVersionWithoutV)</RuntimeFrameworkVersion>
      
        <!-- Normalize RuntimeFrameworkVersion to 3 digits -->
        <RuntimeFrameworkVersion Condition=" $(RuntimeFrameworkVersion.Split('.').Length) == 1">$(RuntimeFrameworkVersion).0.0</RuntimeFrameworkVersion>
        <RuntimeFrameworkVersion Condition=" $(RuntimeFrameworkVersion.Split('.').Length) == 2">$(RuntimeFrameworkVersion).0</RuntimeFrameworkVersion>

        <NetCoreAppImplicitPackageVersion Condition="'$(NetCoreAppImplicitPackageVersion)' == ''">1.1.0</NetCoreAppImplicitPackageVersion>
      </PropertyGroup>
    </When>
    
    <When Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(RuntimeFrameworkVersion)' != ''">
      <PropertyGroup>
        <NetCoreAppImplicitPackageVersion Condition="'$(NetCoreAppImplicitPackageVersion)' == ''">$(RuntimeFrameworkVersion)</NetCoreAppImplicitPackageVersion>
      </PropertyGroup>
    </When>
  </Choose>

  <UsingTask TaskName="CheckForImplicitPackageReferenceOverrides" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />

  <!-- Remove package references with metadata IsImplicitlyDefined = true, if there are other PackageReference items with the same identity -->
  <Target Name="CheckForImplicitPackageReferenceOverrides" BeforeTargets="_CheckForInvalidConfigurationAndPlatform;CollectPackageReferences">
    <PropertyGroup>
      <ImplicitPackageReferenceInformationLink>https://aka.ms/sdkimplicitrefs</ImplicitPackageReferenceInformationLink>
    </PropertyGroup>

    <CheckForImplicitPackageReferenceOverrides
        PackageReferenceItems="@(PackageReference)"
        MoreInformationLink="$(ImplicitPackageReferenceInformationLink)">
      <Output TaskParameter="ItemsToRemove" ItemName="_PackageReferenceToRemove" />
    </CheckForImplicitPackageReferenceOverrides>

    <ItemGroup>
      <!-- Note that the condition here is important, otherwise the Remove will operate based just on item identity and remove all items
           that had duplicates, instead of leaving the ones without IsImplicitlyDefined set to true. -->
      <PackageReference Remove="@(_PackageReferenceToRemove)" Condition="'%(PackageReference.IsImplicitlyDefined)' == 'true' "/>
    </ItemGroup>

  </Target>

  <UsingTask TaskName="CheckForDuplicateItems" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />

  <Target Name="CheckForDuplicateItems" BeforeTargets="_CheckForInvalidConfigurationAndPlatform;CoreCompile">

    <PropertyGroup>
      <DefaultItemsMoreInformationLink>https://aka.ms/sdkimplicititems</DefaultItemsMoreInformationLink>

      <!-- For the design-time build, we will continue on error and remove the duplicate items.
           This is because otherwise there won't be any references to pass to the compiler, leading to design-time
           compilation errors for every API that is used in the project.  Amidst all the compile errors, it would
           be easy to miss the duplicate items error which is the real source of the problem. -->
      <CheckForDuplicateItemsContinueOnError>false</CheckForDuplicateItemsContinueOnError>
      <CheckForDuplicateItemsContinueOnError Condition="'$(DesignTimeBuild)' == 'true'">ErrorAndContinue</CheckForDuplicateItemsContinueOnError>
    </PropertyGroup>

    <CheckForDuplicateItems
      Items="@(Compile)"<commit_msg>Add target to deduplicate PackageReference items before NuGet restore without loading any SDK tasks<commit_after><!--
***********************************************************************************************
Microsoft.NET.Sdk.DefaultItems.targets

WARNING:  DO NOT MODIFY this file unless you are knowledgeable about MSBuild and have
          created a backup copy.  Incorrect changes to this file will make it
          impossible to load or build your projects from the command-line or the IDE.

Copyright (c) .NET Foundation. All rights reserved. 
***********************************************************************************************
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>

  <PropertyGroup>
   <EnableDefaultItems Condition=" '$(EnableDefaultItems)' == '' ">true</EnableDefaultItems>
   <EnableDefaultCompileItems Condition=" '$(EnableDefaultCompileItems)' == '' ">true</EnableDefaultCompileItems>
    <EnableDefaultEmbeddedResourceItems Condition=" '$(EnableDefaultEmbeddedResourceItems)' == '' ">true</EnableDefaultEmbeddedResourceItems>
    <EnableDefaultNoneItems Condition=" '$(EnableDefaultNoneItems)' == '' ">true</EnableDefaultNoneItems>
  </PropertyGroup>

  <PropertyGroup>    
    <!-- Set DefaultItemExcludes property for items that should be excluded from the default Compile, etc items.
         This is in the .targets because it needs to come after the final BaseOutputPath has been evaluated. -->
    
    <!-- bin folder, by default -->
    <DefaultItemExcludes>$(DefaultItemExcludes);$(BaseOutputPath)/**</DefaultItemExcludes>
    <!-- obj folder, by default -->
    <DefaultItemExcludes>$(DefaultItemExcludes);$(BaseIntermediateOutputPath)/**</DefaultItemExcludes>

    <!-- Various files that should generally always be ignored -->
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.user</DefaultItemExcludes>
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.*proj</DefaultItemExcludes>
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.sln</DefaultItemExcludes>
    <DefaultItemExcludes>$(DefaultItemExcludes);**/*.vssscc</DefaultItemExcludes>
    
    <!-- WARNING: This pattern is there to ignore folders such as .git and .vs, but it will also match items included with a
         relative path outside the project folder (for example "..\Shared\Shared.cs").  So be sure only to apply it to items
         that are in the project folder. -->
    <DefaultItemExcludesInProjectFolder>$(DefaultItemExcludesInProjectFolder);**/.*/**</DefaultItemExcludesInProjectFolder>

    <!-- TODO: Verify why this was originally added and whether we really need it -->
    <DefaultItemExcludes>$(DefaultItemExcludes);packages/**</DefaultItemExcludes>
    
  </PropertyGroup>

  <!-- Set the default versions of the NETStandard.Library or Microsoft.NETCore.App packages to reference.
       The implicit package references themselves are defined in Microsoft.NET.Sdk.props, so that they can be overridden
       in the project file. -->
  <PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard' And '$(NetStandardImplicitPackageVersion)' == ''">
    <NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>
  </PropertyGroup>
  
  <!--
    Determine the NetCoreImplicitPackageVersion and RuntimeFrameworkVersion
    
    The RuntimeFrameworkVersion is the version that is written to the runtimeconfig.json, and is the version of the runtime
    that the app should run on.
    
    If RuntimeFrameworkVersion is not set, then derive the RuntimeFrameworkVersion from the TargetFrameworkVersion,
    and use the latest known version of Microsoft.NETCore.App as the NetCoreAppImplicitPackageVersion, unless that
    property is already set.
    
    If RuntimeFrameworkVersion is set, then use that version for the NetCoreAppImplicitPackageVersion, unless
    NetCoreAppImplicitPackageVersion is already set.
    
  -->

  <Choose>
    <When Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(RuntimeFrameworkVersion)' == ''">
      <PropertyGroup>
        <!-- Use the version of the framework runtime matching the target framework version-->
        <RuntimeFrameworkVersion>$(_TargetFrameworkVersionWithoutV)</RuntimeFrameworkVersion>
      
        <!-- Normalize RuntimeFrameworkVersion to 3 digits -->
        <RuntimeFrameworkVersion Condition=" $(RuntimeFrameworkVersion.Split('.').Length) == 1">$(RuntimeFrameworkVersion).0.0</RuntimeFrameworkVersion>
        <RuntimeFrameworkVersion Condition=" $(RuntimeFrameworkVersion.Split('.').Length) == 2">$(RuntimeFrameworkVersion).0</RuntimeFrameworkVersion>

        <NetCoreAppImplicitPackageVersion Condition="'$(NetCoreAppImplicitPackageVersion)' == ''">1.1.0</NetCoreAppImplicitPackageVersion>
      </PropertyGroup>
    </When>
    
    <When Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(RuntimeFrameworkVersion)' != ''">
      <PropertyGroup>
        <NetCoreAppImplicitPackageVersion Condition="'$(NetCoreAppImplicitPackageVersion)' == ''">$(RuntimeFrameworkVersion)</NetCoreAppImplicitPackageVersion>
      </PropertyGroup>
    </When>
  </Choose>

  <UsingTask TaskName="CheckForImplicitPackageReferenceOverrides" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />

  <!-- Remove package references with metadata IsImplicitlyDefined = true, if there are other PackageReference items with the same identity -->
  <Target Name="CheckForImplicitPackageReferenceOverrides" BeforeTargets="_CheckForInvalidConfigurationAndPlatform;CollectPackageReferences">
    <PropertyGroup>
      <ImplicitPackageReferenceInformationLink>https://aka.ms/sdkimplicitrefs</ImplicitPackageReferenceInformationLink>
    </PropertyGroup>

    <CheckForImplicitPackageReferenceOverrides
        PackageReferenceItems="@(PackageReference)"
        MoreInformationLink="$(ImplicitPackageReferenceInformationLink)">
      <Output TaskParameter="ItemsToRemove" ItemName="_PackageReferenceToRemove" />
    </CheckForImplicitPackageReferenceOverrides>

    <ItemGroup>
      <!-- Note that the condition here is important, otherwise the Remove will operate based just on item identity and remove all items
           that had duplicates, instead of leaving the ones without IsImplicitlyDefined set to true. -->
      <PackageReference Remove="@(_PackageReferenceToRemove)" Condition="'%(PackageReference.IsImplicitlyDefined)' == 'true' "/>
    </ItemGroup>

  </Target>

  <!-- Running an SDK task before the NuGet restore task causes issues when running on .NET Framework because it causes the
      .NET Standard NuGet DLLs to be loaded from the SDK path rather than the .NET Framework versions from the NuGet targets
      path.  To avoid this, we create a separate target to run before NuGet restore which deduplicates the items without
      causing the SDK tasks to be loaded (but doesn't generate a warning message, because we need to load the tasks for that). -->
  <PropertyGroup Condition="'$(DisableImplicitFrameworkReferences)' != 'true'">
    <_ImplicitPackageName Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">NETStandard.Library</_ImplicitPackageName>
    <_ImplicitPackageName Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">Microsoft.NETCore.App</_ImplicitPackageName>
  </PropertyGroup>

  <ItemGroup Condition="'$(_ImplicitPackageName)' != ''">
    <!-- Filter PackageReference to items where the ItemSpec matches the implicit package name, and add IsImplicitlyDefined metadata
         for items that don't have it-->
    <_ImplicitPackageReferenceCheck
        Include="@(PackageReference->WithMetadataValue('Identity', '$(_ImplicitPackageName)'))">
      <IsImplicitlyDefined Condition="'%(IsImplicitlyDefined)' != 'true' ">false</IsImplicitlyDefined>
    </_ImplicitPackageReferenceCheck>

    <!-- Now filter down to an item with just the implicit reference and another one with just the overriding reference -->
    <_ImplicitPackageReference Include="@(_ImplicitPackageReferenceCheck->WithMetadataValue('IsImplicitlyDefined', 'true'))"/>
    <_OverridingPackageReference Include="@(_ImplicitPackageReferenceCheck->WithMetadataValue('IsImplicitlyDefined', 'false'))"/>
  </ItemGroup>

  <Target Name="CheckForImplicitPackageReferenceOverridesBeforeRestore" BeforeTargets="_GetRestoreProjectStyle">
    <ItemGroup>
      <!-- Remove both the implicit and the override item, if there was both an implicit and an override item -->
      <PackageReference Remove="@(PackageReference->WithMetadataValue('Identity', '$(_ImplicitPackageName)'))"
                        Condition="'@(_ImplicitPackageReference)' != '' And '@(_OverridingPackageReference)' != ''"
                      />

      <!-- Add the override item back -->
      <PackageReference Include="@(_OverridingPackageReference)"
                        Condition="'@(_ImplicitPackageReference)' != '' And '@(_OverridingPackageReference)' != ''" />
    </ItemGroup>
  </Target>

  <UsingTask TaskName="CheckForDuplicateItems" AssemblyFile="$(MicrosoftNETBuildTasksAssembly)" />

  <Target Name="CheckForDuplicateItems" BeforeTargets="_CheckForInvalidConfigurationAndPlatform;CoreCompile">

    <PropertyGroup>
      <DefaultItemsMoreInformationLink>https://aka.ms/sdkimplicititems</DefaultItemsMoreInformationLink>

      <!-- For the design-time build, we will continue on error and remove the duplicate items.
           This is because otherwise there won't be any references to pass to the compiler, leading to design-time
           compilation errors for every API that is used in the project.  Amidst all the compile errors, it would
           be easy to miss the duplicate items error which is the real source of the problem. -->
      <CheckForDuplicateItemsContinueOnError>false</CheckForDuplicateItemsContinueOnError>
      <CheckForDuplicateItemsContinueOnError Condition="'$(DesignTimeBuild)' == 'true'">ErrorAndContinue</CheckForDuplicateItemsContinueOnError>
    </PropertyGroup>

    <CheckForDuplicateItems
      Items="@(Compile)"
{'fraction_non_alphanumeric': 0.12222222222222222, 'fraction_numerical': 0.0018048505358150028, 'mean_word_length': 4.859550561797753, 'pattern_counts': {'":': 0, '<': 218, '<?xml version=': 0, '>': 220, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4827067', 'n_tokens_mistral': 4439, 'n_tokens_neox': 4129, 'n_words': 1210}