TShock/TShockLauncher/TShockLauncher.csproj
Sakura Akeno Isayeki 69b98980f1
feat(db): add Postgres support to configuration
Extends database configuration to support Postgres in addition to existing SQLite and MySQL options.

Includes new settings for Postgres host, database name, username, and password.

Implements a connection builder for Postgres, ensuring proper error handling when connecting.

Updates dependency to include Npgsql for Postgres connectivity.
2025-04-28 15:51:27 +02:00

101 lines
4.9 KiB
XML

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>TShock.Server</AssemblyName> <!-- TShock was initially decided on by a community poll, however tshock already exists as a folder and will clash -->
<RunPostBuildEvent>Always</RunPostBuildEvent>
<DebugType>embedded</DebugType>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract> <!-- needed for sqlite native libs -->
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj" ExcludeFromSingleFile="true" />
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj" ExcludeFromSingleFile="true" ReferenceOutputAssembly="false" /> <!-- allow api to rebuilt with this project, so ServerPlugins are refreshed -->
<ProjectReference Include="..\TShockPluginManager\TShockPluginManager.csproj"/>
<Reference Include="HttpServer" ExcludeFromSingleFile="true">
<HintPath>..\prebuilts\HttpServer.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="..\prebuilts\GeoIP.dat">
<Link>GeoIP.dat</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="MySql.Data" Version="8.4.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="6.0.11" />
<PackageReference Include="ModFramework" Version="1.1.7" GeneratePathProperty="true" /> <!-- only used to extract out to ./bin. -->
<PackageReference Include="GetText.NET" Version="1.7.14" />
<PackageReference Include="Npgsql" Version="6.0.13" /> <!-- only used to extract out to ./bin. -->
<!-- the launcher doesnt need the direct OTAPI reference, but since PackageReference[ExcludeFromSingleFile] doesnt work, exclude the assets and copy manually -->
<PackageReference Include="OTAPI.Upcoming" Version="3.1.20" ExcludeAssets="all" GeneratePathProperty="true" />
<None Include="$(PkgOTAPI_Upcoming)\lib\net6.0\OTAPI.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
<None Include="$(PkgOTAPI_Upcoming)\lib\net6.0\OTAPI.Runtime.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
<None Include="$(PkgModFramework)\lib\net6.0\ModFramework.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>
<Target Name="CheckMsgfmtCallable">
<Exec Command="msgfmt --help > NUL" IgnoreExitCode="True" Condition=" '$(OS)' == 'Windows_NT' ">
<Output TaskParameter="ExitCode" PropertyName="MsgfmtExitCode" />
</Exec>
<Exec Command="msgfmt --help 2>/dev/null >/dev/null" IgnoreExitCode="True" Condition=" '$(OS)' != 'Windows_NT' ">
<Output TaskParameter="ExitCode" PropertyName="MsgfmtExitCode" />
</Exec>
</Target>
<!-- The condition for a Target can't come from the values of another target, so instead we have to put the same condition on all three of the items inside. -->
<Target
Name="GenerateMOFiles"
DependsOnTargets="CheckMsgfmtCallable"
AfterTargets="PostBuildEvent;Publish"
Inputs="..\i18n\**\*.po"
Outputs="$(OutDir)i18n\**\*.mo">
<ItemGroup Condition="'$(MsgfmtExitCode)' == '0'">
<POFiles Include="..\i18n\**\*.po" />
</ItemGroup>
<MakeDir Directories="$(OutDir)i18n/%(POFiles.RecursiveDir)" Condition="'$(MsgfmtExitCode)' == '0'" />
<Exec Command="msgfmt -o $(OutDir)i18n/%(RecursiveDir)%(Filename).mo @(POFiles)" Outputs="$(OutDir)i18n\**\*.mo" Condition="'$(MsgfmtExitCode)' == '0'">
<Output ItemName="Generated" TaskParameter="Outputs"/>
</Exec>
</Target>
<Target Name="CreateServerPlugins" AfterTargets="PostBuildEvent;Publish">
<MakeDir Directories="$(OutDir)ServerPlugins" />
<MakeDir Directories="$(PublishDir)ServerPlugins" />
<ItemGroup>
<ApiFiles Include="$(ProjectDir)../TShockAPI/bin/$(Configuration)/$(TargetFramework)/TShockAPI*" />
</ItemGroup>
<Copy SourceFiles="@(ApiFiles)" DestinationFolder="$(OutDir)ServerPlugins" ContinueOnError="true" />
<Copy SourceFiles="@(ApiFiles)" DestinationFolder="$(PublishDir)ServerPlugins" ContinueOnError="true" />
</Target>
<Target Name="CopyI18n" AfterTargets="Publish">
<ItemGroup>
<MOFiles Include="$(OutDir)**/*.mo"/>
</ItemGroup>
<Copy SourceFiles="@(MOFiles)" DestinationFolder="$(PublishDir)%(RecursiveDir)" />
</Target>
<Target Name="MoveBin" AfterTargets="Publish">
<ItemGroup>
<MoveBinaries Include="$(PublishDir)*" Exclude="$(PublishDir)\TShock.Server*;$(PublishDir)\GeoIP.dat" />
</ItemGroup>
<Move SourceFiles="@(MoveBinaries)" DestinationFolder="$(PublishDir)bin" ContinueOnError="true" />
</Target>
</Project>