File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ public CompilerService(Extension extension)
7373 EnvironmentHelper . SetVariable ( "Path:Configuration" , Interface . Oxide . ConfigDirectory ) ;
7474 EnvironmentHelper . SetVariable ( "Path:Data" , Interface . Oxide . DataDirectory ) ;
7575 EnvironmentHelper . SetVariable ( "Path:Libraries" , Interface . Oxide . ExtensionDirectory ) ;
76+
77+ if ( Interface . Oxide . Config . Compiler . Publicize )
78+ {
79+ EnvironmentHelper . SetVariable ( "AllowPublicize" , "true" , force : true ) ;
80+ }
7681 }
7782
7883 private void ExpireFileCache ( )
@@ -136,6 +141,12 @@ internal bool Precheck()
136141 preprocessorList . AddRange ( Interface . Oxide . Config . Compiler . PreprocessorDirectives ) ;
137142 }
138143
144+ if ( Interface . Oxide . Config . Compiler . Publicize )
145+ {
146+ EnvironmentHelper . SetVariable ( "AllowPublicize" , "true" , force : true ) ;
147+ preprocessorList . Add ( "OXIDE_PUBLICIZED" ) ;
148+ }
149+
139150 preprocessor = preprocessorList . Distinct ( ) . ToArray ( ) ;
140151
141152#if DEBUG
Original file line number Diff line number Diff line change 22
33using Oxide . CSharp . Patching . Validation ;
44using References ::Mono . Cecil ;
5+ using System ;
6+ using System . IO ;
57
68namespace Oxide . CSharp . Patching
79{
@@ -72,5 +74,31 @@ protected override bool OnMethodDefinition(MethodDefinition method)
7274 method . IsPublic = true ;
7375 return true ;
7476 }
77+
78+ protected override void OnPatchFinished ( PatchContext context )
79+ {
80+ string writePath = EnvironmentHelper . GetVariable ( "PublicizerOutput" ) ;
81+
82+ if ( ! string . IsNullOrEmpty ( writePath ) )
83+ {
84+ string name = context . Assembly . Name . Name ;
85+ if ( ! Directory . Exists ( writePath ) )
86+ {
87+ Log ( $ "Failed to write { name } because PublicizeOutput { writePath } doesn't exist", Core . Logging . LogType . Error ) ;
88+ return ;
89+ }
90+
91+ try
92+ {
93+ name = Path . Combine ( writePath , name + ".dll" ) ;
94+ context . Assembly . Write ( name ) ;
95+ Log ( $ "Wrote publicized assembly to { writePath } ") ;
96+ }
97+ catch ( Exception e )
98+ {
99+ Log ( $ "Failed to write publicized assembly to { writePath } ", Core . Logging . LogType . Error , e ) ;
100+ }
101+ }
102+ }
75103 }
76104}
Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ public void Patch(PatchContext context)
4848 TypeDefinition type = types [ t ] ;
4949 RecurseType ( type , context ) ;
5050 }
51+
52+ OnPatchFinished ( context ) ;
5153 }
5254
5355 private void RecurseType ( TypeDefinition type , PatchContext context )
@@ -201,6 +203,10 @@ protected virtual bool OnEventDefinition(EventDefinition @event)
201203 return false ;
202204 }
203205
206+ protected virtual void OnPatchFinished ( PatchContext context )
207+ {
208+ }
209+
204210 protected bool RunValidation ( IMemberDefinition member , IEnumerable < PatchValidationAttribute > validations )
205211 {
206212 if ( member == null )
You can’t perform that action at this time.
0 commit comments