<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <!-- .NET Standard target does not copy referenced DLLs into bin folder, so we need to enable it explicitly. -->
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
    <!-- Avoid CS0436. see also https://github.com/dotnet/roslyn-analyzers/blob/main/src/PerformanceSensitiveAnalyzers/PerformanceSensitiveAnalyzers.md -->
    <GeneratePerformanceSensitiveAttribute>false</GeneratePerformanceSensitiveAttribute>
    <!-- Title for DLL file properties -->
    <AssemblyTitle>SonarAnalyzer C#</AssemblyTitle>
  </PropertyGroup>

  <!-- Warning: when adding a package reference, we must make sure this package is available on oldest supported .NET version (currently netstandard2.0) or packaged with the analyzer.
       For instance, System.ValueTuple is not available in 4.6.1 and must be added to the final packaging if we add it here -->
  <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="1.3.2" />
    <PackageReference Include="System.Collections.Immutable" Version="1.1.37">
      <!-- Downgrade System.Collections.Immutable to support VS2015 Update 3 -->
      <NoWarn>NU1605, NU1701</NoWarn>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <!-- We need to update NuGet and JAR packaging after changing references -->
    <ProjectReference Include="..\SonarAnalyzer.Core\SonarAnalyzer.Core.csproj" />
    <ProjectReference Include="..\SonarAnalyzer.CSharp.Core\SonarAnalyzer.CSharp.Core.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Using Include="Microsoft.CodeAnalysis" />
    <Using Include="Microsoft.CodeAnalysis.CSharp" />
    <Using Include="Microsoft.CodeAnalysis.CSharp.Syntax" />
    <Using Include="Microsoft.CodeAnalysis.CSharp.Extensions" />
    <Using Include="Microsoft.CodeAnalysis.Diagnostics" />
    <Using Include="SonarAnalyzer.AnalysisContext" />
    <Using Include="SonarAnalyzer.CFG.Extensions" />
    <Using Include="SonarAnalyzer.Common" />
    <Using Include="SonarAnalyzer.Core.Analyzers" />
    <Using Include="SonarAnalyzer.Core.Extensions" />
    <Using Include="SonarAnalyzer.Core.Facade" />
    <Using Include="SonarAnalyzer.Core.Semantics" />
    <Using Include="SonarAnalyzer.Core.Semantics.Extensions" />
    <Using Include="SonarAnalyzer.Core.Syntax.Extensions" />
    <Using Include="SonarAnalyzer.Core.Syntax.Utilities" />
    <Using Include="SonarAnalyzer.CSharp.Core.Common" />
    <Using Include="SonarAnalyzer.CSharp.Core.Extensions" />
    <Using Include="SonarAnalyzer.CSharp.Core.Facade" />
    <Using Include="SonarAnalyzer.CSharp.Core.Syntax.Extensions" />
    <Using Include="SonarAnalyzer.CSharp.Core.Syntax.Utilities" />
    <Using Include="SonarAnalyzer.CSharp.Core.Wrappers" />
    <Using Include="SonarAnalyzer.CSharp.Syntax.Extensions" />
    <Using Include="SonarAnalyzer.CSharp.Syntax.Utilities" />
    <Using Include="SonarAnalyzer.Helpers" />
    <Using Include="StyleCop.Analyzers.Lightup" />
  </ItemGroup>

  <Target Name="SignDlls" Condition="'$(SignAssembly)' == 'true'">
    <Message Importance="high" Text="Signing analyzer assemblies from $(OutputPath)" />
    <Exec WorkingDirectory="$(OutputPath)" Command="signtool sign /du https://www.sonarsource.com/ /d &quot;Roslyn analyzers that spot Bugs, Vulnerabilities and Code Smells in your code.&quot; /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 /csp &quot;DigiCert Signing Manager KSP&quot; /kc &quot;$(SM_KP)&quot; /f &quot;$(SM_CLIENT_CRT_FILE)&quot; SonarAnalyzer*.dll" />
  </Target>

  <Target Name="CopyBinaries" AfterTargets="Build" DependsOnTargets="SignDlls">
    <ItemGroup>
      <BinariesToCopy Include="$(OutputPath)Google.Protobuf.dll" />
      <BinariesToCopy Include="$(OutputPath)SonarAnalyzer.CFG.dll" />
      <BinariesToCopy Include="$(OutputPath)SonarAnalyzer.Core.dll" />
      <BinariesToCopy Include="$(OutputPath)SonarAnalyzer.CSharp.Core.dll" />
      <BinariesToCopy Include="$(OutputPath)SonarAnalyzer.ShimLayer.dll" />
      <BinariesToCopy Include="$(OutputPath)SonarAnalyzer.CSharp.dll" />
    </ItemGroup>
    <Copy SourceFiles="@(BinariesToCopy)" DestinationFolder="$(BinariesFolder)" />
  </Target>

</Project>
