<commit_before><?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Import Project="$(CustomBeforeNuProjTargets)" Condition="'$(CustomBeforeNuProjTargets)' != '' and Exists('$(CustomBeforeNuProjTargets)')"/>

  <!--
      NUSPEC PATH
  -->

  <PropertyGroup>
    <NuSpecPath>$(IntermediateOutputPath)$(Id).nuspec</NuSpecPath>
  </PropertyGroup>

  <!--
      OUTPUT PATHS

      These properties aren't passed to NuGet.exe - they're implicit. However, we need to know the output paths
      at several occasions (e.g. incremental build or clean up) so we want a central spot to capture those.
  -->

  <PropertyGroup>
    <NuGetOutputPath>$([System.IO.Path]::GetFullPath('$(OutDir)$(Id).$(Version).nupkg'))</NuGetOutputPath>
    <NuGetSymbolsOutputPath>$(OutDir)$(Id).$(Version).symbols.nupkg</NuGetSymbolsOutputPath>
  </PropertyGroup>

  <!--
      Properties relevant to Visual Studio:

      $(BuildingInsideVisualStudio)       This will indicate whether this project is building inside the IDE. When
                                          building via MSBuild, this property will not be set.

      $(DesignTimeBuild)                  Visual Studio uses this property to indicate whether it's performing a
                                          design time build or a full build. A design time build is designed to do
                                          minimal amount of work; the intent of those builds is to expose information
                                          around resolved dependencies and properties back to Visual Studio without
                                          actually producing assets on disk.
  -->

  <PropertyGroup>
    <!-- We don't want to build in case we're performing a design time build as we are expected to not
         produce any assets.

         We also don't want to build the references in cases where we build inside the IDE. The reason
         is that Visual Studio already built our dependencies. Doing it again can regress performance.
         However, the real issue is that it impacts correctness as this can result in building the same
         project simultaneously from different projects.

         Most particularly on the correctness side, this shows up when VS is doing a "rebuild". NuProj
         will end up causing multiple build breaks being reported because it will re-delete outputs that
         VS just produced and that other project references that are building in parallel now expect to
         be there. -->
    <BuildProjectReferences Condition="'$(BuildProjectReferences)' == '' and ('$(BuildingInsideVisualStudio)' == 'true' or '$(DesignTimeBuild)' == 'true')">false</BuildProjectReferences>
    <!-- By default we will build (and if applicable, clean) all project references. But this can be used
         to disable that. -->
    <BuildProjectReferences Condition="'$(BuildProjectReferences)' == ''">true</BuildProjectReferences>
  </PropertyGroup>

  <!--
      MSBuildAllProjects is used to keep track of all projects the build depends on.
      We make all targets depending on it to make sure everything rebuilds.
  -->

  <PropertyGroup>
    <MSBuildAllProjects Condition="Exists('$(MSBuildProjectFullPath)')">$(MSBuildAllProjects);$(MSBuildProjectFullPath)</MSBuildAllProjects>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>

  <!--
      OUTPUT GROUPS

      These are the groups we are using to discover outputs from our project references.
  -->

  <PropertyGroup>
    <ProjectOutputGroups>
      BuiltProjectOutputGroup;
      BuiltProjectOutputGroupDependencies;
      DebugSymbolsProjectOutputGroup;
      DebugSymbolsProjectOutputGroupDependencies;
      DocumentationProjectOutputGroup;
      DocumentationProjectOutputGroupDependencies;
      SatelliteDllsProjectOutputGroup;
      SatelliteDllsProjectOutputGroupDependencies;
      SGenFilesOutputGroup;
      SGenFilesOutputGroupDependencies;
    </ProjectOutputGroups>
  </PropertyGroup>

  <!--
      PROJECT PROPERTIES

      These are the properties we forward to our project references.
  -->

  <PropertyGroup>
    <ProjectProperties>
      Configuration=$(Configuration);
      Platform=$(Platform);
    </ProjectProperties>
  </PropertyGroup>

  <!--
      CUSTOM TASKS
  -->

  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="GenerateNuSpec" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="NuGetPack" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="AssignTargetFramework" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="ReadPackagesConfig" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="ReadPdbSourceFiles" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="AssignSourceTargetPaths" />

  <!--
    ===================================================================================================================
    _NuProjGetProjectClosure
    ===================================================================================================================

    This target returns the closure of all project references.

    INPUTS:
        @(_MSBuildProjectReferenceExistent)   The project references that actually exist.

    OUTPUTS:
        @(_ProjectReferenceClosure)           The closure of all references. Doesn't include duplicates.

    =================================================================================================================== -->

  <Target Name="_NuProjGetProjectClosure"
          Returns="@(_ProjectReferenceClosure)">
    <!-- First let's make sure that the project references have been fully build,
             unless building project references is disabled. -->

    <MSBuild Targets="Build"
             Condition="'$(BuildProjectReferences)' == 'true'"
             Projects="@(ProjectReference)"
             Properties="$(ProjectProperties)"
             ContinueOnError="WarnAndContinue"/>

    <!-- Get closure of indirect references -->
    <MSBuild Projects="@(ProjectReference)"
             Targets="_NuProjGetProjectClosure"
             Properties="$(ProjectProperties)"
             ContinueOnError="WarnAndContinue">
      <Output TaskParameter="TargetOutputs"
              ItemName="_ProjectReferenceClosureWithDuplicates" />
    </MSBuild>

    <!-- Remove duplicates from closure -->
    <RemoveDuplicates Inputs="@(_ProjectReferenceClosureWithDuplicates)">
      <Output TaskParameter="Filtered"
              ItemName="_ProjectReferenceClosureWithoutMetadata"/>
    </RemoveDuplicates>

    <ItemGroup>
      <!-- Remove references that are also direct references -->
      <_ProjectReferenceClosureWithoutMetadata Remove="%(ProjectReference.FullPath)" />
      <!-- We can now mark all the closure references as indirect -->
      <_ProjectReferenceClosure Include="@(_ProjectReferenceClosureWithoutMetadata)">
        <DependencyKind>Indirect</DependencyKind>
      </_ProjectReferenceClosure>
      <!-- Now add the direct references -->
      <_ProjectReferenceClosure Include="%(ProjectReference.FullPath)">
        <DependencyKind>Direct</DependencyKind>
      </_ProjectReferenceClosure>
    </ItemGroup>

  </Target>

  <!--
    ===================================================================================================================
    SplitProjectReferences
    ===================================================================================================================

    This target will split the project references into NuProj project references and non-NuProj references.

    INPUTS:
        @(ProjectReference)            The direct project references
        @(_ProjectReferenceClosure)    The direct and indirect project references

    OUTPUTS:
        @(_NuProjProjectReference)            Direct references to NuProj projects.
        @(_NonNuProjProjectReference)         Direct references to regular, i.e. non-NuProj projects.
        @(_NuProjProjectReferenceClosure)     Direct and indirect references to NuProj projects.<commit_msg>Preserve metadata on project references<commit_after><?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <Import Project="$(CustomBeforeNuProjTargets)" Condition="'$(CustomBeforeNuProjTargets)' != '' and Exists('$(CustomBeforeNuProjTargets)')"/>

  <!--
      NUSPEC PATH
  -->

  <PropertyGroup>
    <NuSpecPath>$(IntermediateOutputPath)$(Id).nuspec</NuSpecPath>
  </PropertyGroup>

  <!--
      OUTPUT PATHS

      These properties aren't passed to NuGet.exe - they're implicit. However, we need to know the output paths
      at several occasions (e.g. incremental build or clean up) so we want a central spot to capture those.
  -->

  <PropertyGroup>
    <NuGetOutputPath>$([System.IO.Path]::GetFullPath('$(OutDir)$(Id).$(Version).nupkg'))</NuGetOutputPath>
    <NuGetSymbolsOutputPath>$(OutDir)$(Id).$(Version).symbols.nupkg</NuGetSymbolsOutputPath>
  </PropertyGroup>

  <!--
      Properties relevant to Visual Studio:

      $(BuildingInsideVisualStudio)       This will indicate whether this project is building inside the IDE. When
                                          building via MSBuild, this property will not be set.

      $(DesignTimeBuild)                  Visual Studio uses this property to indicate whether it's performing a
                                          design time build or a full build. A design time build is designed to do
                                          minimal amount of work; the intent of those builds is to expose information
                                          around resolved dependencies and properties back to Visual Studio without
                                          actually producing assets on disk.
  -->

  <PropertyGroup>
    <!-- We don't want to build in case we're performing a design time build as we are expected to not
         produce any assets.

         We also don't want to build the references in cases where we build inside the IDE. The reason
         is that Visual Studio already built our dependencies. Doing it again can regress performance.
         However, the real issue is that it impacts correctness as this can result in building the same
         project simultaneously from different projects.

         Most particularly on the correctness side, this shows up when VS is doing a "rebuild". NuProj
         will end up causing multiple build breaks being reported because it will re-delete outputs that
         VS just produced and that other project references that are building in parallel now expect to
         be there. -->
    <BuildProjectReferences Condition="'$(BuildProjectReferences)' == '' and ('$(BuildingInsideVisualStudio)' == 'true' or '$(DesignTimeBuild)' == 'true')">false</BuildProjectReferences>
    <!-- By default we will build (and if applicable, clean) all project references. But this can be used
         to disable that. -->
    <BuildProjectReferences Condition="'$(BuildProjectReferences)' == ''">true</BuildProjectReferences>
  </PropertyGroup>

  <!--
      MSBuildAllProjects is used to keep track of all projects the build depends on.
      We make all targets depending on it to make sure everything rebuilds.
  -->

  <PropertyGroup>
    <MSBuildAllProjects Condition="Exists('$(MSBuildProjectFullPath)')">$(MSBuildAllProjects);$(MSBuildProjectFullPath)</MSBuildAllProjects>
    <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
  </PropertyGroup>

  <!--
      OUTPUT GROUPS

      These are the groups we are using to discover outputs from our project references.
  -->

  <PropertyGroup>
    <ProjectOutputGroups>
      BuiltProjectOutputGroup;
      BuiltProjectOutputGroupDependencies;
      DebugSymbolsProjectOutputGroup;
      DebugSymbolsProjectOutputGroupDependencies;
      DocumentationProjectOutputGroup;
      DocumentationProjectOutputGroupDependencies;
      SatelliteDllsProjectOutputGroup;
      SatelliteDllsProjectOutputGroupDependencies;
      SGenFilesOutputGroup;
      SGenFilesOutputGroupDependencies;
    </ProjectOutputGroups>
  </PropertyGroup>

  <!--
      PROJECT PROPERTIES

      These are the properties we forward to our project references.
  -->

  <PropertyGroup>
    <ProjectProperties>
      Configuration=$(Configuration);
      Platform=$(Platform);
    </ProjectProperties>
  </PropertyGroup>

  <!--
      CUSTOM TASKS
  -->

  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="GenerateNuSpec" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="NuGetPack" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="AssignTargetFramework" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="ReadPackagesConfig" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="ReadPdbSourceFiles" />
  <UsingTask AssemblyFile="$(NuProjTasksPath)" TaskName="AssignSourceTargetPaths" />

  <!--
    ===================================================================================================================
    _NuProjGetProjectClosure
    ===================================================================================================================

    This target returns the closure of all project references.

    INPUTS:
        @(_MSBuildProjectReferenceExistent)   The project references that actually exist.

    OUTPUTS:
        @(_ProjectReferenceClosure)           The closure of all references. Doesn't include duplicates.

    =================================================================================================================== -->

  <Target Name="_NuProjGetProjectClosure"
          Returns="@(_ProjectReferenceClosure)">
    <!-- First let's make sure that the project references have been fully build,
             unless building project references is disabled. -->

    <MSBuild Targets="Build"
             Condition="'$(BuildProjectReferences)' == 'true'"
             Projects="@(ProjectReference)"
             Properties="$(ProjectProperties)"
             ContinueOnError="WarnAndContinue"/>

    <!-- Get closure of indirect references -->
    <MSBuild Projects="@(ProjectReference)"
             Targets="_NuProjGetProjectClosure"
             Properties="$(ProjectProperties)"
             ContinueOnError="WarnAndContinue">
      <Output TaskParameter="TargetOutputs"
              ItemName="_ProjectReferenceClosureWithDuplicates" />
    </MSBuild>

    <!-- Remove duplicates from closure -->
    <RemoveDuplicates Inputs="@(_ProjectReferenceClosureWithDuplicates)">
      <Output TaskParameter="Filtered"
              ItemName="_ProjectReferenceClosureWithoutMetadata"/>
    </RemoveDuplicates>

    <ItemGroup>
      <!-- Remove references that are also direct references -->
      <_ProjectReferenceClosureWithoutMetadata Remove="%(ProjectReference.FullPath)" />
      <!-- We can now mark all the closure references as indirect -->
      <_ProjectReferenceClosure Include="@(_ProjectReferenceClosureWithoutMetadata)">
        <DependencyKind>Indirect</DependencyKind>
      </_ProjectReferenceClosure>
      <!-- Now add the direct references, preserving metadata -->
      <_ProjectReferenceClosure Include="@(ProjectReference->'%(FullPath)')">
        <DependencyKind>Direct</DependencyKind>
      </_ProjectReferenceClosure>
    </ItemGroup>

  </Target>

  <!--
    ===================================================================================================================
    SplitProjectReferences
    ===================================================================================================================

    This target will split the project references into NuProj project references and non-NuProj references.

    INPUTS:
        @(ProjectReference)            The direct project references
        @(_ProjectReferenceClosure)    The direct and indirect project references

    OUTPUTS:
        @(_NuProjProjectReference)            Direct references to NuProj projects.
        @(_NonNuProjProjectReference)         Direct references to regular, i.e. non-NuProj projects.
        @(_NuProjProjectReferenceClosure)     Direct and indirect references to NuProj projects.
{'fraction_non_alphanumeric': 0.15557998900494777, 'fraction_numerical': 0.0010995052226498076, 'mean_word_length': 3.4671214188267396, 'pattern_counts': {'":': 0, '<': 155, '<?xml version=': 2, '>': 154, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4991055', 'n_tokens_mistral': 4017, 'n_tokens_neox': 3575, 'n_words': 1127}