@@ -33,12 +33,22 @@ public class BuildContext : FrostingContext
3333 public DirectoryPath PatcherProjectDirectory => RootDirectory . Combine ( "NetcodePatcher" ) ;
3434 public FilePath PatcherProjectFile => PatcherProjectDirectory . CombineWithFilePath ( "NetcodePatcher.csproj" ) ;
3535
36+ public DirectoryPath NetcodeRuntimeProjectDirectory => RootDirectory . Combine ( "Unity.Netcode.Runtime" ) ;
37+ public FilePath NetcodeRuntimeProjectFile => NetcodeRuntimeProjectDirectory . CombineWithFilePath ( "Unity.Netcode.Runtime.csproj" ) ;
38+
3639 public Version UnityVersion { get ; }
3740 public Version UnityNetcodeVersion { get ; }
3841 public Version UnityTransportVersion { get ; }
3942 public bool UnityNetcodeNativeCollectionSupport { get ; }
4043
41- public string PatcherAssemblyName => $ "NetcodePatcher.uv{ UnityVersion . Major } .{ UnityVersion . Minor } .nv{ UnityNetcodeVersion } .tv{ UnityTransportVersion } .{ ( UnityNetcodeNativeCollectionSupport ? "withNativeCollectionSupport" : "withoutNativeCollectionSupport" ) } ";
44+ public DirectoryPath PatcherCommonOutputDirectory => PatcherProjectDirectory
45+ . Combine ( "dist" )
46+ . Combine ( $ "unity-v{ UnityVersion . Major } .{ UnityVersion . Minor } ")
47+ . Combine ( $ "unity-transport-v{ UnityTransportVersion } ") ;
48+
49+ public DirectoryPath PatcherSpecificOutputDirectory => PatcherCommonOutputDirectory
50+ . Combine ( $ "netcode-v{ UnityNetcodeVersion } ")
51+ . Combine ( UnityNetcodeNativeCollectionSupport ? "with-native-collection-support" : "without-native-collection-support" ) ;
4252
4353 public DirectoryPath ? UnityEditorDir { get ; }
4454
@@ -116,8 +126,16 @@ public sealed class CleanTask : FrostingTask<BuildContext>
116126{
117127 public override void Run ( BuildContext context )
118128 {
119- context . CleanDirectories ( context . RootDirectory . Combine ( "NetcodePatcher/bin" ) . FullPath ) ;
120- context . CleanDirectories ( context . RootDirectory . Combine ( "NetcodePatcher/obj" ) . FullPath ) ;
129+ CleanProject ( context . PatcherProjectDirectory ) ;
130+ CleanProject ( context . NetcodeRuntimeProjectDirectory ) ;
131+ return ;
132+
133+ void CleanProject ( DirectoryPath projectDirectory )
134+ {
135+ context . CleanDirectories ( projectDirectory . Combine ( "bin" ) . FullPath ) ;
136+ context . CleanDirectories ( projectDirectory . Combine ( "obj" ) . FullPath ) ;
137+ context . CleanDirectories ( projectDirectory . Combine ( "dist" ) . FullPath ) ;
138+ }
121139 }
122140}
123141
@@ -139,21 +157,43 @@ public override void Run(BuildContext context)
139157 {
140158 var buildSettings = new DotNetPublishSettings {
141159 Configuration = "Release" ,
142- OutputDirectory = context . PatcherProjectDirectory . Combine ( $ "dist/uv { context . UnityVersion . Major } . { context . UnityVersion . Minor } /tv { context . UnityTransportVersion } " ) ,
160+ OutputDirectory = context . PatcherCommonOutputDirectory ,
143161 MSBuildSettings = new ( ) {
144162 Properties = {
145163 { "DefineConstants" , [ string . Join ( "%3B" , context . ComputeAllMSBuildConstants ( ) . ToArray ( ) ) ] } ,
146- { "AssemblyName" , [ context . PatcherAssemblyName ] }
147164 } ,
148165 } ,
149166 } ;
150167
151- if ( context . UnityEditorDir is not null ) {
168+ if ( context . UnityEditorDir is not null )
169+ {
152170 buildSettings . MSBuildSettings = buildSettings . MSBuildSettings
153171 . WithProperty ( "UnityEditorDir" , context . UnityEditorDir . FullPath ) ;
154172 }
155173
156174 context . DotNetPublish ( context . PatcherProjectFile . FullPath , buildSettings ) ;
175+
176+ context . EnsureDirectoryExists ( context . PatcherSpecificOutputDirectory ) ;
177+ MoveFileToSpecificOutputDirectory ( CommonOutputFilePath ( "NetcodePatcher.deps.json" ) ) ;
178+ MoveAssemblyToSpecificOutputDirectory ( "NetcodePatcher" ) ;
179+ MoveAssemblyToSpecificOutputDirectory ( "Unity.Netcode.Runtime" ) ;
180+ return ;
181+
182+ void MoveAssemblyToSpecificOutputDirectory ( string assemblyName )
183+ {
184+ MoveFileToSpecificOutputDirectory ( CommonOutputFilePath ( $ "{ assemblyName } .dll") ) ;
185+ MoveFileToSpecificOutputDirectory ( CommonOutputFilePath ( $ "{ assemblyName } .pdb") ) ;
186+ }
187+
188+ void MoveFileToSpecificOutputDirectory ( FilePath file )
189+ {
190+ context . MoveFileToDirectory ( file , context . PatcherSpecificOutputDirectory ) ;
191+ }
192+
193+ FilePath CommonOutputFilePath ( string outputFileName )
194+ {
195+ return context . PatcherCommonOutputDirectory . CombineWithFilePath ( outputFileName ) ;
196+ }
157197 }
158198}
159199
0 commit comments