|
10 | 10 | <LangVersion>latest</LangVersion> |
11 | 11 | <Version>1.5.10</Version> |
12 | 12 | <AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
| 13 | + <VcpkgRoot Condition="'$(VCPKG_ROOT)' != '' AND Exists('$(VCPKG_ROOT)\vcpkg.exe')">$(VCPKG_ROOT)</VcpkgRoot> |
| 14 | + <VcpkgRoot Condition="'$(VCPKG_ROOT)' != '' AND Exists('$(VCPKG_ROOT)\vcpkg')">$(VCPKG_ROOT)</VcpkgRoot> |
| 15 | + <VcpkgRoot Condition="'$(VcpkgRoot)' == ''">$(MSBuildThisFileDirectory)vcpkg</VcpkgRoot> |
| 16 | + <ScriptsPath>$(MSBuildThisFileDirectory)scripts\</ScriptsPath> |
| 17 | + <VcpkgOverlayRoot>$(ScriptsPath)vcpkg-overlay\</VcpkgOverlayRoot> |
| 18 | + <!-- 定义平台相关的路径 --> |
| 19 | + <VcpkgTriplet Condition="'$(OS)' == 'Windows_NT'">x64-windows</VcpkgTriplet> |
| 20 | + <VcpkgTriplet Condition="'$(OS)' == 'Unix' AND $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))">x64-osx</VcpkgTriplet> |
| 21 | + <VcpkgTriplet Condition="'$(OS)' == 'Unix' AND $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))">x64-linux</VcpkgTriplet> |
13 | 22 | </PropertyGroup> |
14 | 23 |
|
15 | 24 | <ItemGroup> |
|
56 | 65 | <CopyToOutputDirectory>Always</CopyToOutputDirectory> |
57 | 66 | </None> |
58 | 67 | </ItemGroup> |
| 68 | + |
| 69 | + <!-- 自定义目标:检查并安装 vcpkg --> |
| 70 | + <Target Name="InstallVcpkg" BeforeTargets="Build"> |
| 71 | + <Exec Command="git clone https://github.com/SineStriker/vcpkg-overlay.git $(VcpkgOverlayRoot)" Condition="!Exists('$(VcpkgOverlayRoot)')" /> |
| 72 | + <Exec Command="git clone https://github.com/microsoft/vcpkg.git $(VcpkgRoot)" Condition="!Exists('$(VcpkgRoot)')" /> |
| 73 | + <!-- Windows --> |
| 74 | + <Exec Command="$(VcpkgRoot)\bootstrap-vcpkg.bat" Condition="'$(OS)' == 'Windows_NT' AND !Exists('$(VcpkgRoot)\vcpkg.exe')" /> |
| 75 | + <!-- macOS/Linux --> |
| 76 | + <Exec Command="$(VcpkgRoot)\bootstrap-vcpkg.sh" Condition="'$(OS)' == 'Unix' AND !Exists('$(VcpkgRoot)\vcpkg')" /> |
| 77 | + <Exec Command="$(VcpkgRoot)\vcpkg install --x-manifest-root=$(ScriptsPath)vcpkg-manifest --x-install-root=$(VcpkgOverlayRoot)\installed --triplet $(VcpkgTriplet)" /> |
| 78 | + </Target> |
| 79 | + |
| 80 | + <!-- 将 FFmpeg 的动态库复制到输出目录 --> |
| 81 | + <Target Name="CopyLibraries" AfterTargets="Build"> |
| 82 | + <ItemGroup> |
| 83 | + <!-- Windows --> |
| 84 | + <FFmpegLibraries Include="$(VcpkgOverlayRoot)\installed\$(VcpkgTriplet)\bin\*.dll" Condition="'$(OS)' == 'Windows_NT'" /> |
| 85 | + <!-- macOS --> |
| 86 | + <FFmpegLibraries Include="$(VcpkgOverlayRoot)\installed\$(VcpkgTriplet)\lib\*.dylib" Condition="'$(OS)' == 'Unix' AND $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))" /> |
| 87 | + <!-- Linux --> |
| 88 | + <FFmpegLibraries Include="$(VcpkgOverlayRoot)\installed\$(VcpkgTriplet)\lib\*.so" Condition="'$(OS)' == 'Unix' AND $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))" /> |
| 89 | + </ItemGroup> |
| 90 | + <Copy SourceFiles="@(FFmpegLibraries)" DestinationFolder="$(OutputPath)\ffmpeg" /> |
| 91 | + </Target> |
59 | 92 | </Project> |
0 commit comments