Okay, the Robust API thing didn't pan out. New plan.

It apparently broke clean builds, as the dependencies aren't in the project asset list or something anymore. I tried to fix this, but it seems impossible to do without relying on .NET SDK internals, as there's no point in the NuGet graph walk process that seems cleanly extensible.

Instead let's just do the much dumber thing: a bunch of .props files for content to import. Hooray!

This also means that I have to go through and *explicitly* disable transitive dependencies everywhere in RT. This thankfully isn't too hard.
This commit is contained in:
PJB3005
2025-12-16 22:56:31 +01:00
parent 39e30531e2
commit 7f2ec17651
27 changed files with 134 additions and 86 deletions

21
Directory.Build.props Normal file
View File

@@ -0,0 +1,21 @@
<Project>
<ItemDefinitionGroup>
<PackageReference>
<!--
Make all packages used by RT default to having everything private except what's needed to run the game (runtime, native)
This is to avoid having them leak to content, as they are primarily an implementation detail.
Where necessary, this can be overriden by doing PrivateAssets="none" on the PackageReference entry.
-->
<PrivateAssets>compile;contentFiles;build;buildMultitargeting;buildTransitive;analyzers</PrivateAssets>
</PackageReference>
</ItemDefinitionGroup>
<PropertyGroup>
<!--
Disable transitive project references.
This is just to avoid venues of leaky implementation details into content.
Being strict is always good.
-->
<DisableTransitiveProjectReferences>True</DisableTransitiveProjectReferences>
</PropertyGroup>
</Project>

6
Imports/Benchmarks.props Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<!-- Include this .props file from content to get access to the APIs in these projects. -->
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Benchmarks\Robust.Benchmarks.csproj" />
</ItemGroup>
</Project>

6
Imports/Client.props Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Client\Robust.Client.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Avalonia.Base\Avalonia.Base.csproj" />
</ItemGroup>
</Project>

6
Imports/Lidgren.props Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<!-- Include this .props file from content to get access to the APIs in these projects. -->
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Lidgren.Network\Lidgren.Network.csproj" />
</ItemGroup>
</Project>

6
Imports/Packaging.props Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<!-- Include this .props file from content to get access to the APIs in these projects. -->
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Packaging\Robust.Packaging.csproj" />
</ItemGroup>
</Project>

6
Imports/Server.props Normal file
View File

@@ -0,0 +1,6 @@
<Project>
<!-- Include this .props file from content to get access to the APIs in these projects. -->
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Server\Robust.Server.csproj" />
</ItemGroup>
</Project>

8
Imports/Shared.props Normal file
View File

@@ -0,0 +1,8 @@
<Project>
<!-- Include this .props file from content to get access to the APIs in these projects. -->
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Shared\Robust.Shared.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\NetSerializer\NetSerializer\NetSerializer.csproj" />
</ItemGroup>
</Project>

9
Imports/Testing.props Normal file
View File

@@ -0,0 +1,9 @@
<Project>
<!-- Include this .props file from content to get access to the APIs in these projects. -->
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Shared.Maths.Testing\Robust.Shared.Maths.Testing.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Shared.Testing\Robust.Shared.Testing.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.Server.Testing\Robust.Server.Testing.csproj" />
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\Robust.UnitTesting\Robust.UnitTesting.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,83 +0,0 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup>
<!--
Content should define <UseRobustApi> items to declare which parts of Robust they want a C# project to depend on.
Content MUST NOT create project references to Robust directly, as these are NOT stable.
-->
<UseRobustApi>
<Visible>false</Visible>
</UseRobustApi>
<!--
The actual definition items we use to declare what <UseRobustApi> maps to what references.
Can be either a project OR a NuGet package.
-->
<RobustApiDef>
<Visible>false</Visible>
<Project />
<ProjectDir />
<PackageReference />
</RobustApiDef>
</ItemDefinitionGroup>
<ItemGroup>
<RobustApiDef Include="Lidgren" Project="Lidgren.Network" />
<RobustApiDef Include="Shared" Project="Robust.Shared.Maths" />
<RobustApiDef Include="Shared" Project="Robust.Shared" />
<RobustApiDef Include="Shared" ProjectDir="NetSerializer\" Project="NetSerializer" />
<RobustApiDef Include="Shared" PackageReference="Robust.Shared.AuthLib" />
<RobustApiDef Include="Server" Project="Robust.Server" />
<RobustApiDef Include="Packaging" Project="Robust.Packaging" />
<RobustApiDef Include="Client" Project="Robust.Client" />
<RobustApiDef Include="Client" Project="Avalonia.Base" />
<RobustApiDef Include="Testing" Project="Robust.Shared.Maths.Testing" />
<RobustApiDef Include="Testing" Project="Robust.Shared.Testing" />
<RobustApiDef Include="Testing" Project="Robust.Server.Testing" />
<RobustApiDef Include="Testing" Project="Robust.UnitTesting" />
<RobustApiDef Include="Benchmarks" Project="Robust.Benchmarks" />
</ItemGroup>
<Target Name="_RTFilterEnabledApi" Returns="@(_EnabledRobustApi)">
<JoinItems Left="@(RobustApiDef)" LeftMetadata="*"
Right="@(UseRobustApi)"
ItemSpecToUse="Left">
<Output TaskParameter="JoinResult" ItemName="_EnabledRobustApi" />
</JoinItems>
</Target>
<Target Name="_RTCheckForDirectReferences" BeforeTargets="_RTMakeProjectReferences">
<Error File="%(ProjectReference.DefiningProjectFullPath)"
Text="Direct ProjectReferences to Robust projects are not allowed, use &lt;UseRobustApi&gt;"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', 'RobustToolbox')) and !$([System.Text.RegularExpressions.Regex]::IsMatch('%(DefiningProjectDirectory)', 'RobustToolbox'))" />
</Target>
<!--
Add <ProjectReference>es for RT projects based on selected UseRobustApi.
This is *not* done before Restore, so these references do *not* contribute
to transitive dependency inclusion.
-->
<Target Name="_RTMakeProjectReferences" BeforeTargets="BeforeResolveReferences;AssignProjectConfiguration"
DependsOnTargets="_RTFilterEnabledApi" Returns="@(ProjectReference)">
<ItemGroup>
<_RTProjectReference KeepDuplicates="false"
Include="%(_EnabledRobustApi.Project)\%(_EnabledRobustApi.Project).csproj"
ProjectDir="%(_EnabledRobustApi.ProjectDir)"
Condition="'%(_EnabledRobustApi.Project)' != ''" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(MSBuildThisFileDirectory)\..\%(_RTProjectReference.ProjectDir)%(_RTProjectReference.Identity)"
Condition="'%(_RTProjectReference.Identity)' != ''" />
</ItemGroup>
</Target>
<!--
Add <PackageReference>es for RT projects based on selected UseRobustApi.
-->
<Target Name="_RTAddPackageReferences" BeforeTargets="Restore"
DependsOnTargets="_RTFilterEnabledApi" Returns="@(PackageReference)">
<ItemGroup>
<PackageReference KeepDuplicates="false" Include="%(_EnabledRobustApi.PackageReference)"
Version="" Condition="'%(_EnabledRobustApi.PackageReference)' != ''"/>
</ItemGroup>
</Target>
</Project>

View File

@@ -0,0 +1,12 @@
<Project>
<!--
Disallow content from using direct references to Robust project files.
Content should use the .props files in Imports/ instead.
-->
<Target Name="_RTCheckForDirectReferences" BeforeTargets="BeforeResolveReferences">
<Error File="%(ProjectReference.DefiningProjectFullPath)"
Text="Content may not reference %(Filename) directly"
Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(Identity)', 'RobustToolbox')) and !$([System.Text.RegularExpressions.Regex]::IsMatch('%(DefiningProjectDirectory)', 'RobustToolbox'))" />
</Target>
</Project>

View File

@@ -32,7 +32,7 @@
<Import Project="Robust.Serialization.Generator.targets" Condition="'$(SkipRobustAnalyzer)' != 'true'" />
<!-- Robust API system -->
<Import Project="Robust.Api.targets" />
<Import Project="Robust.ProjectReferences.targets" />
<!--
We don't use these features and they add a not-insignificant amount of time to build perf.

View File

@@ -11,11 +11,15 @@
<ItemGroup>
<ProjectReference Include="..\Robust.Server.Testing\Robust.Server.Testing.csproj" />
<ProjectReference Include="..\Robust.Server\Robust.Server.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
<ProjectReference Include="..\Robust.UnitTesting\Robust.UnitTesting.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="JetBrains.Annotations" />
<PackageReference Include="YamlDotNet" />
<PackageReference Include="prometheus-net" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>

View File

@@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" />
<ProjectReference Include="..\Robust.Client\Robust.Client.csproj" />
<ProjectReference Include="..\Robust.Server.Testing\Robust.Server.Testing.csproj" />
<ProjectReference Include="..\Robust.Server\Robust.Server.csproj" />

View File

@@ -6,6 +6,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet"/>
<PackageReference Include="JetBrains.Annotations"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="NUnit"/>

View File

@@ -27,6 +27,10 @@
<PackageReference Include="SpaceWizards.Sodium" PrivateAssets="compile" />
<PackageReference Include="Microsoft.NET.ILLink.Tasks" />
<PackageReference Include="TerraFX.Interop.Xlib" />
<PackageReference Include="YamlDotNet" />
<PackageReference Include="Microsoft.Extensions.ObjectPool" />
<PackageReference Include="prometheus-net" />
<PackageReference Include="Serilog" />
<!-- Needed to pin transitive dependency versions. -->
<PackageReference Include="System.Text.Json" />
@@ -42,6 +46,7 @@
<ItemGroup>
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" />
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" />
<ProjectReference Include="..\Robust.LoaderApi\Robust.LoaderApi\Robust.LoaderApi.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />

View File

@@ -15,6 +15,7 @@
<ItemGroup>
<ProjectReference Include="..\Robust.Packaging\Robust.Packaging.csproj"/>
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
</ItemGroup>
<Import Project="..\MSBuild\Robust.Properties.targets"/>

View File

@@ -6,6 +6,11 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" />
<PackageReference Include="SixLabors.ImageSharp" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
</ItemGroup>

View File

@@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Robust.Client\Robust.Client.csproj" />
<ProjectReference Include="..\Robust.Server.Testing\Robust.Server.Testing.csproj" />
<ProjectReference Include="..\Robust.Server\Robust.Server.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths.Tests\Robust.Shared.Maths.Tests.csproj" />

View File

@@ -32,6 +32,10 @@
<PackageReference Include="Robust.Natives.Zstd" />
<PackageReference Condition="'$(RobustToolsBuild)' == 'True'" Include="JetBrains.Profiler.Api" />
<PackageReference Include="Microsoft.NET.ILLink.Tasks" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" />
<PackageReference Include="YamlDotNet" />
<!-- Needed to pin transitive dependency versions. -->
<PackageReference Include="System.Text.Json" />
@@ -39,6 +43,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared.Scripting\Robust.Shared.Scripting.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />

View File

@@ -8,6 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" />
<PackageReference Include="prometheus-net" />
<PackageReference Include="JetBrains.Annotations"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="Moq" />
@@ -17,6 +19,8 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" />
<ProjectReference Include="..\Robust.Client\Robust.Client.csproj" />
<ProjectReference Include="..\Robust.Server.Testing\Robust.Server.Testing.csproj" />
<ProjectReference Include="..\Robust.Server\Robust.Server.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths.Tests\Robust.Shared.Maths.Tests.csproj" />

View File

@@ -11,12 +11,14 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" />
<PackageReference Include="JetBrains.Annotations" PrivateAssets="All" />
<PackageReference Include="YamlDotNet" />
<!-- Needed to pin transitive dependency versions. -->
<PackageReference Include="System.Text.Json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />
<ProjectReference Include="..\Robust.Shared\Robust.Shared.csproj" />
</ItemGroup>

View File

@@ -10,6 +10,7 @@
<PackageReference Include="JetBrains.Annotations"/>
<PackageReference Include="NUnit"/>
<PackageReference Include="NUnit.Analyzers"/>
<PackageReference Include="Serilog"/>
</ItemGroup>
<ItemGroup>

View File

@@ -6,6 +6,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="YamlDotNet" />
<PackageReference Include="Linguini.Bundle" />
<PackageReference Include="Pidgin" />
<PackageReference Include="JetBrains.Annotations"/>
<PackageReference Include="Microsoft.NET.Test.Sdk"/>
<PackageReference Include="Moq" />
@@ -15,6 +19,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths.Tests\Robust.Shared.Maths.Tests.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj"/>
<ProjectReference Include="..\Robust.Shared.Maths.Testing\Robust.Shared.Maths.Testing.csproj"/>

View File

@@ -16,7 +16,7 @@
<PackageReference Include="VorbisPizza" PrivateAssets="compile" />
<PackageReference Include="Pidgin" />
<PackageReference Include="prometheus-net" />
<PackageReference Include="Robust.Shared.AuthLib" />
<PackageReference Include="Robust.Shared.AuthLib" PrivateAssets="none" />
<PackageReference Include="Serilog" />
<PackageReference Include="YamlDotNet" />
<PackageReference Include="Microsoft.Win32.Registry" PrivateAssets="compile" />

View File

@@ -6,6 +6,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="YamlDotNet" />
<PackageReference Include="Serilog" />
<PackageReference Include="JetBrains.Annotations" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
@@ -15,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lidgren.Network\Lidgren.Network.csproj" />
<ProjectReference Include="..\NetSerializer\NetSerializer\NetSerializer.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths.Testing\Robust.Shared.Maths.Testing.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths.Tests\Robust.Shared.Maths.Tests.csproj" />
<ProjectReference Include="..\Robust.Shared.Maths\Robust.Shared.Maths.csproj" />

View File

@@ -8,10 +8,12 @@
<ItemGroup>
<PackageReference Include="Microsoft.Build.Framework" Version="18.0.2" />
<PackageReference Include="Mono.Cecil" Version="0.11.6" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\XamlX\src\XamlX.IL.Cecil\XamlX.IL.Cecil.csproj" />
<ProjectReference Include="..\XamlX\src\XamlX\XamlX.csproj" />
</ItemGroup>
</Project>

View File

@@ -14,9 +14,17 @@
</Properties>
</Project>
</Folder>
<Folder Name="/Imports/">
<File Path="Imports/Benchmarks.props"/>
<File Path="Imports/Client.props"/>
<File Path="Imports/Lidgren.props"/>
<File Path="Imports/Packaging.props"/>
<File Path="Imports/Server.props"/>
<File Path="Imports/Shared.props"/>
<File Path="Imports/Testing.props"/>
</Folder>
<Folder Name="/MSBuild/">
<File Path="MSBuild/Robust.Analyzers.targets"/>
<File Path="MSBuild/Robust.Api.targets"/>
<File Path="MSBuild/Robust.CompNetworkGenerator.targets"/>
<File Path="MSBuild/Robust.Configurations.props"/>
<File Path="MSBuild/Robust.DefineConstants.targets"/>
@@ -24,6 +32,7 @@
<File Path="MSBuild/Robust.Engine.targets"/>
<File Path="MSBuild/Robust.Engine.Version.props"/>
<File Path="MSBuild/Robust.Platform.props"/>
<File Path="MSBuild/Robust.ProjectReferences.targets"/>
<File Path="MSBuild/Robust.Properties.targets"/>
<File Path="MSBuild/Robust.Trimming.targets"/>
<File Path="MSBuild/XamlIL.targets"/>
@@ -35,6 +44,7 @@
</Project>
</Folder>
<Folder Name="/Project Files/">
<File Path="Directory.Build.props" />
<File Path="Directory.Packages.props" />
<File Path="README.md" />
<File Path="RELEASE-NOTES.md" />