@@ -69,6 +69,7 @@ public OptionsObfuscationNeedsFactory(string[] args)
6969 var fileBaseDirectory = Path . GetDirectoryName ( filePath ) ;
7070
7171 ProtectionSettings ? protectionSettings = null ;
72+ string ? protectionsFile = options . ProtectionsFile ;
7273 if ( options . Protections . Any ( ) )
7374 {
7475 protectionSettings = new ProtectionSettings
@@ -80,6 +81,27 @@ public OptionsObfuscationNeedsFactory(string[] args)
8081 } ) . ToList ( )
8182 } ;
8283 }
84+ else
85+ {
86+ // Try to find protections.json for fallback
87+ if ( protectionsFile != null && File . Exists ( protectionsFile ) )
88+ {
89+ // Use specified file
90+ }
91+ else if ( File . Exists ( KnownConfigNames . Protections ) )
92+ {
93+ protectionsFile = KnownConfigNames . Protections ;
94+ }
95+ else
96+ {
97+ // Fallback to application base directory
98+ var baseProtectionsFile = Path . Combine ( AppContext . BaseDirectory , KnownConfigNames . Protections ) ;
99+ if ( File . Exists ( baseProtectionsFile ) )
100+ {
101+ protectionsFile = baseProtectionsFile ;
102+ }
103+ }
104+ }
83105
84106 ObfuscationNeeds needs ;
85107 if ( obfuscationSettings ? . ForceObfuscation == true )
@@ -96,7 +118,7 @@ public OptionsObfuscationNeedsFactory(string[] args)
96118 CriticalsFile = options . CriticalsFile ,
97119 LoggingFile = options . LoggingFile ,
98120 ObfuscationFile = options . ObfuscationFile ,
99- ProtectionsFile = options . ProtectionsFile ,
121+ ProtectionsFile = protectionsFile ,
100122 ObfuscationSettings = obfuscationSettings
101123 } ;
102124 }
@@ -118,7 +140,7 @@ public OptionsObfuscationNeedsFactory(string[] args)
118140 CriticalsFile = options . CriticalsFile ,
119141 LoggingFile = options . LoggingFile ,
120142 ObfuscationFile = options . ObfuscationFile ,
121- ProtectionsFile = options . ProtectionsFile ,
143+ ProtectionsFile = protectionsFile ,
122144 ObfuscationSettings = obfuscationSettings
123145 } ;
124146 }
0 commit comments