The .extracted marker now includes the raylib package name, so bumping TargetRaylibTag re-extracts the new archive instead of silently keeping (and packing/copying) the previous version's files. _PrepareNativeLibrary and _StageWasmNative now depend directly on _DownloadAndExtractInternal instead of CallTarget-ing it; dependency targets run in the same project instance, so the resolved properties (RaylibPackageName etc.) propagate naturally.
165 lines
No EOL
9.1 KiB
XML
165 lines
No EOL
9.1 KiB
XML
<Project Sdk="Microsoft.NET.Sdk">
|
|
<PropertyGroup>
|
|
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
|
|
<AssemblyName>Raylib-cs</AssemblyName>
|
|
<RootNamespace>Raylib_cs</RootNamespace>
|
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
|
<LangVersion>12</LangVersion>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<NoWarn>$(NoWarn);1591</NoWarn> <!-- missing XML comment on public member -->
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<PackageId>Raylib-cs</PackageId>
|
|
<Description>C# bindings for raylib</Description>
|
|
<RepositoryUrl>https://github.com/raylib-cs/raylib-cs/</RepositoryUrl>
|
|
<Authors>raylib-cs</Authors>
|
|
<PackageLicenseExpression>Zlib</PackageLicenseExpression>
|
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
|
<PackageIcon>raylib-cs_64x64.png</PackageIcon>
|
|
<PackageTags>raylib csharp gamedev</PackageTags>
|
|
|
|
<IncludeSymbols>true</IncludeSymbols>
|
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
|
</PropertyGroup>
|
|
|
|
<ItemGroup>
|
|
<!-- Use explicit PackagePath for these to prevent ambiguity -->
|
|
<None Include="logo/raylib-cs_64x64.png" Pack="true" PackagePath="raylib-cs_64x64.png"/>
|
|
<None Include="../README.md" Pack="true" PackagePath="README.md"/>
|
|
<None Include="Raylib-cs.targets" Pack="true" PackagePath="buildTransitive\Raylib-cs.targets"/>
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
|
|
</ItemGroup>
|
|
|
|
<!-- Import Build Props -->
|
|
<Import Project="./Build.props" Condition="Exists('./Build.props')"/>
|
|
<PropertyGroup Condition="'$(TargetRaylibTag)' == ''">
|
|
<TargetRaylibTag>6.0</TargetRaylibTag>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<NativesRoot>$(BaseIntermediateOutputPath)natives/</NativesRoot>
|
|
</PropertyGroup>
|
|
|
|
<!-- Single source of truth: RID -> raylib release archive + library file.
|
|
Pkg/Ext name the upstream release asset; Lib is the download-time copy glob
|
|
(libraylib.so* catches the versioned .so); Pack is the exact file name packed
|
|
into the nupkg; PackAs renames it inside the package (wasm: libraylib.web.a -> raylib.a).
|
|
Drives PackageRids, the per-RID resolve below, and the pack file list. -->
|
|
<ItemGroup>
|
|
<RaylibRid Include="win-x64" Pkg="raylib-$(TargetRaylibTag)_win64_msvc16" Ext=".zip" Lib="raylib.dll" Pack="raylib.dll"/>
|
|
<RaylibRid Include="win-x86" Pkg="raylib-$(TargetRaylibTag)_win32_msvc16" Ext=".zip" Lib="raylib.dll" Pack="raylib.dll"/>
|
|
<RaylibRid Include="linux-x64" Pkg="raylib-$(TargetRaylibTag)_linux_amd64" Ext=".tar.gz" Lib="libraylib.so*" Pack="libraylib.so"/>
|
|
<RaylibRid Include="osx-x64" Pkg="raylib-$(TargetRaylibTag)_macos" Ext=".tar.gz" Lib="libraylib.dylib" Pack="libraylib.dylib"/>
|
|
<RaylibRid Include="osx-arm64" Pkg="raylib-$(TargetRaylibTag)_macos" Ext=".tar.gz" Lib="libraylib.dylib" Pack="libraylib.dylib"/>
|
|
<RaylibRid Include="browser-wasm" Pkg="raylib-$(TargetRaylibTag)_webassembly" Ext=".zip" Lib="libraylib.web.a" Pack="libraylib.web.a" PackAs="raylib.a"/>
|
|
</ItemGroup>
|
|
|
|
<!-- Resolve the active RID's archive metadata from the table. Runs as a dependency
|
|
(execution phase) because properties can't read items during evaluation. -->
|
|
<Target Name="_ResolveRaylibNative">
|
|
<PropertyGroup>
|
|
<RaylibPackageName>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Pkg)')</RaylibPackageName>
|
|
<ArchiveExt>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Ext)')</ArchiveExt>
|
|
<LibPattern>@(RaylibRid->WithMetadataValue('Identity','$(RuntimeIdentifier)')->'%(Lib)')</LibPattern>
|
|
</PropertyGroup>
|
|
</Target>
|
|
|
|
<!-- ================================================================== -->
|
|
<!-- TARGET: PACKING -->
|
|
<!-- ================================================================== -->
|
|
<Target Name="PrepareNativesForPack" BeforeTargets="_GetPackageFiles">
|
|
<MSBuild Projects="$(MSBuildThisFileFullPath)"
|
|
Targets="_DownloadAndExtractInternal"
|
|
Properties="RuntimeIdentifier=%(RaylibRid.Identity);TargetFramework=$(TargetFramework);TargetRaylibTag=$(TargetRaylibTag)"
|
|
BuildInParallel="false"/>
|
|
|
|
<!-- Direct injection into _PackageFiles, derived from the RID table.
|
|
RIDs without PackAs keep their file name in runtimes/<rid>/native/;
|
|
RIDs with PackAs (wasm) are renamed via an explicit file path. -->
|
|
<ItemGroup>
|
|
<_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')"
|
|
Condition="'%(RaylibRid.PackAs)' == ''">
|
|
<PackagePath>runtimes/%(RaylibRid.Identity)/native/</PackagePath>
|
|
<BuildAction>None</BuildAction>
|
|
</_PackageFiles>
|
|
<_PackageFiles Include="@(RaylibRid->'$(NativesRoot)%(Identity)/%(Pkg)/lib/%(Pack)')"
|
|
Condition="'%(RaylibRid.PackAs)' != ''">
|
|
<PackagePath>runtimes/%(RaylibRid.Identity)/native/%(RaylibRid.PackAs)</PackagePath>
|
|
<BuildAction>None</BuildAction>
|
|
</_PackageFiles>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!-- ================================================================== -->
|
|
<!-- TARGET: LOCAL DEVELOPMENT -->
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- Resolve and download the native library for a given RID (used by ProjectReference consumers). -->
|
|
<Target Name="_PrepareNativeLibrary" DependsOnTargets="_DownloadAndExtractInternal" Outputs="@(_RaylibNativeLibraryItem)">
|
|
<PropertyGroup>
|
|
<_RaylibNativesDir>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)/$(NativesRoot)'))</_RaylibNativesDir>
|
|
</PropertyGroup>
|
|
<ItemGroup>
|
|
<_NativeCandidate Include="$(_RaylibNativesDir)$(RuntimeIdentifier)/**/$(LibPattern)"/>
|
|
<_RaylibNativeLibraryItem Include="@(_NativeCandidate)"/>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<!-- Stage libraylib.web.a as raylib.a for wasm linking (pinvoke module name must match LibraryImport). -->
|
|
<Target Name="_StageWasmNative" DependsOnTargets="_DownloadAndExtractInternal"
|
|
Condition="'$(RuntimeIdentifier)' == 'browser-wasm'">
|
|
<PropertyGroup>
|
|
<_WasmNativeSrc>$(NativesRoot)browser-wasm/$(RaylibPackageName)/lib/libraylib.web.a</_WasmNativeSrc>
|
|
<_WasmNativeDst>$(MSBuildThisFileDirectory)obj/browser-wasm/raylib.a</_WasmNativeDst>
|
|
</PropertyGroup>
|
|
<MakeDir Directories="$(MSBuildThisFileDirectory)obj/browser-wasm"/>
|
|
<Copy SourceFiles="$(_WasmNativeSrc)" DestinationFiles="$(_WasmNativeDst)" SkipUnchangedFiles="true"/>
|
|
</Target>
|
|
|
|
<!-- ================================================================== -->
|
|
<!-- WORKER: DOWNLOADER -->
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- Resolves the archive metadata first (properties can't read items at eval time, so the
|
|
RID -> package mapping must be applied here in the execution phase via DependsOnTargets).
|
|
Tasks are guarded on RaylibPackageName so an unknown RID is a no-op. -->
|
|
<Target Name="_DownloadAndExtractInternal" DependsOnTargets="_ResolveRaylibNative">
|
|
<PropertyGroup>
|
|
<_WorkDir>$(NativesRoot)$(RuntimeIdentifier)/</_WorkDir>
|
|
<_ArchiveFile>$(_WorkDir)$(RaylibPackageName)$(ArchiveExt)</_ArchiveFile>
|
|
<!-- Marker includes the package name so bumping TargetRaylibTag re-extracts
|
|
instead of silently keeping the old version's files. -->
|
|
<_ExtractMarker>$(_WorkDir)$(RaylibPackageName).extracted</_ExtractMarker>
|
|
</PropertyGroup>
|
|
|
|
<Message Text="Downloading raylib $(TargetRaylibTag) native for $(RuntimeIdentifier)"
|
|
Importance="normal" Condition="'$(RaylibPackageName)' != ''"/>
|
|
|
|
<MakeDir Directories="$(_WorkDir)" Condition="'$(RaylibPackageName)' != ''"/>
|
|
|
|
<DownloadFile
|
|
SourceUrl="https://github.com/raysan5/raylib/releases/download/$(TargetRaylibTag)/$(RaylibPackageName)$(ArchiveExt)"
|
|
DestinationFolder="$(_WorkDir)"
|
|
DestinationFileName="$(RaylibPackageName)$(ArchiveExt)"
|
|
Condition="'$(RaylibPackageName)' != '' AND !Exists('$(_ArchiveFile)')"
|
|
Retries="3"/>
|
|
|
|
<Unzip SourceFiles="$(_ArchiveFile)"
|
|
DestinationFolder="$(_WorkDir)"
|
|
OverwriteReadOnlyFiles="true"
|
|
Condition="'$(ArchiveExt)' == '.zip' AND !Exists('$(_ExtractMarker)')"/>
|
|
|
|
<Exec Command="tar -xzf "$(RaylibPackageName)$(ArchiveExt)""
|
|
WorkingDirectory="$(_WorkDir)"
|
|
Condition="'$(ArchiveExt)' == '.tar.gz' AND !Exists('$(_ExtractMarker)')"/>
|
|
|
|
<Touch Files="$(_ExtractMarker)" AlwaysCreate="true" Condition="'$(RaylibPackageName)' != ''"/>
|
|
</Target>
|
|
</Project> |