﻿<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows</TargetFramework>
    <RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
    <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
    <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
    <GenerateSupportedRuntime>false</GenerateSupportedRuntime>
    <UseWpf>true</UseWpf>
    <RootNamespace>ICSharpCode.ILSpy</RootNamespace>

    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>

    <ApplicationIcon>Images\ILSpy-Large.ico</ApplicationIcon>
    <ApplicationManifest>app.manifest</ApplicationManifest>

    <SignAssembly>True</SignAssembly>
    <AssemblyOriginatorKeyFile>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.snk</AssemblyOriginatorKeyFile>
    <ServerGarbageCollection>true</ServerGarbageCollection>
    <GarbageCollectionAdaptationMode>1</GarbageCollectionAdaptationMode>
    <EnableWindowsTargeting>true</EnableWindowsTargeting>
  </PropertyGroup>

  <ItemGroup>
    <RuntimeHostConfigurationOption Include="Switch.System.Windows.Media.EnableHardwareAccelerationInRdp" Value="true" />
  </ItemGroup>

  <PropertyGroup Condition="'$(Configuration)' == 'Debug'">
    <DebugType>full</DebugType>
    <DebugSymbols>true</DebugSymbols>
    <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)' == 'Release'">
    <DebugType>pdbonly</DebugType>
    <DebugSymbols>true</DebugSymbols>
  </PropertyGroup>

  <PropertyGroup>
    <CodeAnalysisRuleSet>..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.ruleset</CodeAnalysisRuleSet>
  </PropertyGroup>

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

  <ItemGroup>
    <PackageReference Include="AvalonEdit" Version="$(AvalonEditVersion)" />
    <PackageReference Include="Dirkster.AvalonDock.Themes.VS2013" Version="4.72.0" />
    <PackageReference Include="Microsoft.VisualStudio.Composition" Version="17.4.16" />
    <PackageReference Include="DataGridExtensions" Version="2.5.14" />
    <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.39" />
    <PackageReference Include="TomsToolbox.Wpf.Styles" Version="$(WpfStylesToolboxVersion)" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Include="..\doc\ILSpyAboutPage.txt" />
    <EmbeddedResource Include="..\doc\ILSpyAboutPage_zh_Hans.txt" />
    <EmbeddedResource Include="..\doc\third-party-notices.txt" />
    <EmbeddedResource Include="..\doc\license.txt">
      <Link>license.txt</Link>
    </EmbeddedResource>
    <Resource Include="Images\NuGet.png" />
    <Resource Include="Images\ILSpy.ico" />
    <EmbeddedResource Include="TextView\CSharp-Mode.xshd" />
    <EmbeddedResource Include="TextView\ILAsm-Mode.xshd" />
    <EmbeddedResource Include="TextView\Asm-Mode.xshd" />
    <EmbeddedResource Include="TextView\XML-Mode.xshd" />
    <None Remove="Properties\launchSettings.json" />
  </ItemGroup>

  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\ICSharpCode.ILSpyX\ICSharpCode.ILSpyX.csproj" />
    <ProjectReference Include="..\ICSharpCode.Decompiler\ICSharpCode.Decompiler.csproj" />
    <ProjectReference Include="..\SharpTreeView\ICSharpCode.TreeView.csproj" />
  </ItemGroup>

  <ItemGroup Condition="'$(Configuration)' == 'Debug'">
    <PackageReference Include="Microsoft.DiaSymReader.Converter.Xml" Version="$(DSRConverterXmlVersion)" />
  </ItemGroup>

  <PropertyGroup>
    <VCToolsVersionPropsFileNameDefault>Microsoft.VCToolsVersion.default.props</VCToolsVersionPropsFileNameDefault>
    <VCBasePath>$(MSBuildToolsPath)\..\..\..\VC\</VCBasePath>
    <!-- In VS 2022 there is an extra directory level that's why we need to add one more '..'  -->
    <VCBasePath Condition="!Exists('$(VCBasePath)Auxiliary\Build\$(VCToolsVersionPropsFileNameDefault)')">$(MSBuildToolsPath)\..\..\..\..\VC\</VCBasePath>
    <VCToolsVersionPropsFile>$(VCBasePath)Auxiliary\Build\$(VCToolsVersionPropsFileNameDefault)</VCToolsVersionPropsFile>
    <EnableNETAnalyzers>True</EnableNETAnalyzers>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <NoWarn>1701;1702;CA1001;CA2213</NoWarn>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <NoWarn>1701;1702;CA1001;CA2213</NoWarn>
  </PropertyGroup>

  <Import Project="$(VCToolsVersionPropsFile)" Condition="Exists('$(VCToolsVersionPropsFile)')" />

  <ItemGroup>
    <SortResXInput Include="Properties\*.resx" />
    <SortResXInput Include="..\ILSpy.AddIn\*.resx" />
    <SortResXInput Include="..\ILSpy.ReadyToRun\Properties\*.resx" />
    <SortResXStamp Include="obj\sort-resx.stamp" />
  </ItemGroup>

  <Target Name="SortResX" BeforeTargets="BeforeBuild" Inputs="@(SortResXInput)" Outputs="@(SortResXStamp)" Condition="'$(GITHUB_ACTIONS)' != 'true'">
    <PropertyGroup Condition=" '$(OS)' == 'Windows_NT' ">
      <SortResX>powershell -NoProfile -ExecutionPolicy Bypass -File BuildTools/sort-resx.ps1</SortResX>
    </PropertyGroup>
    <Exec WorkingDirectory=".." Command="$(SortResX)" Timeout="60000" />
    <Touch Files="@(SortResXStamp)" AlwaysCreate="true" />
  </Target>

  <Target Name="ApplyStackExtension" AfterTargets="PostBuildEvent" Condition="'$(VCToolsVersion)'!=''">
    <Exec Command="&quot;$(VCBasePath)Tools\MSVC\$(VCToolsVersion)\bin\Hostx64\x64\editbin.exe&quot; /stack:16777216 &quot;$(TargetDir)$(TargetName).exe&quot;&#xD;&#xA;EXIT 0" />
  </Target>
</Project>
