<Project>
  <Import Project=".\Common.props" />

  <ItemGroup>
    <PackageReference Include="MinVer" Version="$(MinVerPkgVer)" Condition="'$(IntegrationBuild)' != 'true'">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="$(MicrosoftCodeAnalysisAnalyzersPkgVer)" Condition=" $(OS) == 'Windows_NT'">
      <PrivateAssets>All</PrivateAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
    <PackageReference Include="Microsoft.DotNet.ApiCompat" Version="6.0.0-beta.21308.1" PrivateAssets="All" />
    <ResolvedMatchingContract Include="$(RepoRoot)\build\LastMajorVersionBinaries\$(AssemblyName)\$(OTelPreviousStableVer)\lib\$(TargetFramework)\$(AssemblyName).dll" />
  </ItemGroup>

  <Target Name="PreBuild" BeforeTargets="DispatchToInnerBuilds;ValidateApiCompatForSrc" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
    <!-- Note: DispatchToInnerBuilds is called for projects with multiple
    targets defined to spawn a build process for each target framework being
    compiled. Executing BEFORE that step means this runs once for a project
    instead of in parallel for each target framework defined. If we ever have a
    project with only a single target, this will NOT run and an alternative
    solution will be needed. -->
    <Exec Command="powershell -ExecutionPolicy Unrestricted -File &quot;$(RepoRoot)\build\PreBuild.ps1&quot; -package $(AssemblyName) -version &quot;$(OTelPreviousStableVer)&quot; -workDir &quot;$(RepoRoot)\build\LastMajorVersionBinaries&quot;" />
  </Target>

  <Target Name="FindContractDependencyPaths" BeforeTargets="ValidateApiCompatForSrc" AfterTargets="ResolveAssemblyReferences" Condition="'$(MinVerTagPrefix)' == 'core-' AND '$(CheckAPICompatibility)' == 'true'">
    <ItemGroup>
      <_ReferencePathDirectories Include="@(ReferencePath -> '%(RootDir)%(Directory)')" />
    </ItemGroup>
    <PropertyGroup>
      <ContractDependencyPaths>@(_ReferencePathDirectories->Distinct())</ContractDependencyPaths>
    </PropertyGroup>
  </Target>

  <PropertyGroup>
    <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)/OpenTelemetry.prod.ruleset</CodeAnalysisRuleSet>
    <NoWarn>$(NoWarn),1573,1712</NoWarn>
    <PackageOutputPath Condition="$(Build_ArtifactStagingDirectory) != ''">$(Build_ArtifactStagingDirectory)</PackageOutputPath>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <!--<MinVerVerbosity>detailed</MinVerVerbosity>-->
    <ApiCompatExcludeAttributeList>$(RepoRoot)\build\GlobalAttrExclusions.txt</ApiCompatExcludeAttributeList>
  </PropertyGroup>

  <Target Name="AssemblyVersionTarget" AfterTargets="MinVer" Condition="'$(MinVerVersion)'!='' AND '$(BuildNumber)' != ''">
    <PropertyGroup>
      <FileVersion>$(MinVerMajor).$(MinVerMinor).$(MinVerPatch).$(BuildNumber)</FileVersion>
    </PropertyGroup>
  </Target>

  <PropertyGroup>
    <RepositoryType>git</RepositoryType>
    <RepositoryUrl>https://github.com/open-telemetry/opentelemetry-dotnet</RepositoryUrl>
    <PackageTags>Observability;OpenTelemetry;Monitoring;Telemetry;Tracing</PackageTags>
    <PackageIcon>opentelemetry-icon-color.png</PackageIcon>
    <PackageProjectUrl>https://opentelemetry.io</PackageProjectUrl>
    <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
    <Authors>OpenTelemetry Authors</Authors>
    <PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
  </PropertyGroup>

  <ItemGroup>
    <None Include="$(MSBuildThisFileDirectory)opentelemetry-icon-color.png" Pack="true" PackagePath="\" />
  </ItemGroup>

  <PropertyGroup Label="SourceLink">
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
    <IncludeSymbols>true</IncludeSymbols>
    <SymbolPackageFormat>snupkg</SymbolPackageFormat>
  </PropertyGroup>

  <ItemGroup Condition="'$(Deterministic)'=='true'">
    <SourceRoot Include="$(MSBuildThisFileDirectory)/" />
  </ItemGroup>

  <PropertyGroup Condition="'$(Deterministic)'=='true'">
    <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
  </PropertyGroup>

  <!--PublicApi Analyzer-->
  <ItemGroup>
    <AdditionalFiles Include=".publicApi\$(TargetFramework)\PublicAPI.Shipped.txt" />
    <AdditionalFiles Include=".publicApi\$(TargetFramework)\PublicAPI.Unshipped.txt" />
    <None Include=".publicApi\*\PublicAPI.Shipped.txt" />
    <None Include=".publicApi\*\PublicAPI.Unshipped.txt" />
  </ItemGroup>

</Project>
