|
| 1 | +<Project Sdk="Microsoft.NET.Sdk"> |
| 2 | + |
| 3 | + <PropertyGroup> |
| 4 | + <Description>Pre-built binaries for NetCord, $(Description)</Description> |
| 5 | + <GeneratePackageOnBuild>false</GeneratePackageOnBuild> |
| 6 | + |
| 7 | + <VcpkgInstalledDir>bin\natives</VcpkgInstalledDir> |
| 8 | + <VcpkgMsbuildPath>vcpkg/scripts/buildsystems/msbuild/vcpkg</VcpkgMsbuildPath> |
| 9 | + <RepositoryRoot>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\..'))</RepositoryRoot> |
| 10 | + </PropertyGroup> |
| 11 | + |
| 12 | + <ItemGroup> |
| 13 | + <Compile Remove="vcpkg\**" /> |
| 14 | + <None Remove="vcpkg\**" /> |
| 15 | + <None Include="$(VcpkgMsbuildPath).*"> |
| 16 | + <Link>vcpkg\%(Filename)%(Extension)</Link> |
| 17 | + </None> |
| 18 | + </ItemGroup> |
| 19 | + |
| 20 | + <Import Project="$(VcpkgMsbuildPath).props" Condition="Exists('$(VcpkgMsbuildPath).props')" /> |
| 21 | + |
| 22 | + <!-- Use vcpkg integration with MSBuild Platform (normalize AnyCPU to x64). --> |
| 23 | + <PropertyGroup> |
| 24 | + <VcpkgEnableManifest>true</VcpkgEnableManifest> |
| 25 | + |
| 26 | + <VcpkgOSTarget Condition="'$(VcpkgOSTarget)' == ''">windows</VcpkgOSTarget> |
| 27 | + <VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == '' and ('$(Platform)' == 'Any CPU' or '$(Platform)' == 'AnyCPU')">x64</VcpkgPlatformTarget> |
| 28 | + <VcpkgPlatformTarget Condition="'$(VcpkgPlatformTarget)' == ''">$(Platform)</VcpkgPlatformTarget> |
| 29 | + |
| 30 | + <DebugDefinedDir Condition="'$(Configuration)' == 'Debug'">debug</DebugDefinedDir> |
| 31 | + <BuildNativeOutputPath>$(VcpkgInstalledDir)\$(VcpkgPlatformTarget)-$(VcpkgOSTarget)\$(DebugDefinedDir)</BuildNativeOutputPath> |
| 32 | + </PropertyGroup> |
| 33 | + |
| 34 | + <ItemGroup> |
| 35 | + <None Include="$(BuildNativeOutputPath)\**"> |
| 36 | + <Link>Built Natives $(DebugDefinedDir)\%(RecursiveDir)%(Filename)%(Extension)</Link> |
| 37 | + </None> |
| 38 | + </ItemGroup> |
| 39 | + |
| 40 | + <Import Project="$(VcpkgMsbuildPath).targets" Condition="Exists('$(VcpkgMsbuildPath).targets')" /> |
| 41 | + |
| 42 | + <Target Name="_EnsureVcpkgSubmodule" BeforeTargets="PrepareForBuild" Condition="!Exists('$(VcpkgMsbuildPath).targets')"> |
| 43 | + <Message Text="vcpkg submodule is missing. Initializing/updating submodule..." Importance="High" /> |
| 44 | + <Exec Command="git -C "$(RepositoryRoot)" submodule update --init --recursive -- NetCord.Natives/vcpkg" /> |
| 45 | + <Error Condition="!Exists('$(VcpkgMsbuildPath).targets')" Text="Failed to initialize the 'vcpkg' submodule. Ensure git is available and rerun the build." /> |
| 46 | + <Warning Text="vcpkg submodule was initialized during this build. Run the build again so vcpkg MSBuild targets are imported." Condition="Exists('$(VcpkgMsbuildPath).targets')" /> |
| 47 | + </Target> |
| 48 | + |
| 49 | + <Target Name="_LogVcpkgSelection" BeforeTargets="VcpkgTripletSelection"> |
| 50 | + <Message Text="Using VcpkgManifestRoot='$(VcpkgManifestRoot)', Platform='$(Platform)', VcpkgOSTarget='$(VcpkgOSTarget)', VcpkgPlatformTarget='$(VcpkgPlatformTarget)', VcpkgTriplet='$(VcpkgTriplet)'" Importance="High" /> |
| 51 | + </Target> |
| 52 | + |
| 53 | + <Target Name="ClCompile" BeforeTargets="Build" /> |
| 54 | + |
| 55 | + <Target Name="PackageNatives" BeforeTargets="_GetPackageFiles" DependsOnTargets="ClCompile"> |
| 56 | + |
| 57 | + <ItemGroup> |
| 58 | + <NativesBuilt Include="$(BuildNativeOutputPath)\bin\*;$(BuildNativeOutputPath)\lib\*" /> |
| 59 | + <NativesBuilt Remove="**/pkgconf*.*" /> |
| 60 | + |
| 61 | + <Content Include="@(NativesBuilt)"> |
| 62 | + <Link>%(RecursiveDir)%(FileName)%(Extension)</Link> |
| 63 | + <Pack>true</Pack> |
| 64 | + <PackagePath>runtimes\$(VcpkgOSTarget)-$(VcpkgPlatformTarget)\$(DebugDefinedDir)\</PackagePath> |
| 65 | + </Content> |
| 66 | + |
| 67 | + <None Include="$(MSBuildProjectName).props;$(MSBuildProjectName).targets"> |
| 68 | + <Pack>true</Pack> |
| 69 | + <PackagePath>build\</PackagePath> |
| 70 | + </None> |
| 71 | + |
| 72 | + </ItemGroup> |
| 73 | + |
| 74 | + <Message Text="$(MSBuildProjectName) packaged items:" Importance="high" /> |
| 75 | + <Message Text=" %(Content.Identity) -> [pkg].\%(Content.PackagePath)%(Filename)%(Extension)" |
| 76 | + Importance="high" Condition="'%(Content.Pack)' == 'true'" /> |
| 77 | + |
| 78 | + </Target> |
| 79 | + |
| 80 | +</Project> |
0 commit comments