Obfuscar final working :D #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Release | |
| on: | |
| push: | |
| branches: [ "main", "master" ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Inject API Key into Form1.cs | |
| env: | |
| API_KEY: ${{ secrets.RMU9283DURM9UF }} | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| shell: pwsh | |
| run: | | |
| $path = "r6random/Form1.cs" | |
| $content = Get-Content -Path $path -Raw | |
| if ($content -notmatch "ftm04857ht08745htjf") { | |
| Write-Error "CRITICAL ERROR: Could not find 'ftm04857ht08745htjf' in Form1.cs! Did you push the placeholder to GitHub?" | |
| exit 1 | |
| } | |
| $content = $content.Replace("ftm04857ht08745htjf", $env:API_KEY) | |
| Set-Content -Path $path -Value $content -Encoding UTF8 | |
| $check = Get-Content -Path $path -Raw | |
| if ($check -match "ftm04857ht08745htjf") { | |
| Write-Error "CRITICAL ERROR: Replacement failed to save!" | |
| exit 1 | |
| } | |
| Write-Host "Success: Key was perfectly injected into Form1.cs!" | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v1.1 | |
| - name: Restore NuGet Packages | |
| run: nuget restore r6random.sln | |
| - name: Build the App | |
| run: msbuild r6random.sln /p:Configuration=Release | |
| - name: Install Obfuscar | |
| run: dotnet tool install --global Obfuscar.GlobalTool | |
| - name: Create Obfuscar Config | |
| shell: pwsh | |
| run: | | |
| # Target the exact 4.7.2 Reference Assembly folder | |
| $netFrameworkPath = "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2" | |
| # Verify the path exists | |
| if (-not (Test-Path "$netFrameworkPath\System.Windows.Forms.dll")) { | |
| Write-Error "Could not find System.Windows.Forms.dll at $netFrameworkPath" | |
| exit 1 | |
| } | |
| $xml = @" | |
| <?xml version='1.0'?> | |
| <Obfuscator> | |
| <Var name='InPath' value='r6random\bin\Release' /> | |
| <Var name='OutPath' value='r6random\bin\Release\Obfuscated' /> | |
| <Var name='CopyDependencies' value='true' /> | |
| <AssemblySearchPath path='$netFrameworkPath' /> | |
| <AssemblySearchPath path='r6random\bin\Release' /> | |
| <Var name='KeepPublicApi' value='false' /> | |
| <Var name='HidePrivateApi' value='true' /> | |
| <Var name='HideStrings' value='true' /> | |
| <Var name='OptimizeMethods' value='true' /> | |
| <Var name='SuppressIldasm' value='true' /> | |
| <Module file='`$(InPath)\r6random.exe' /> | |
| </Obfuscator> | |
| "@ | |
| Set-Content -Path obfuscar.xml -Value $xml -Encoding UTF8 | |
| Write-Host "Success: Pointed Obfuscar to .NET 4.7.2 Reference Assemblies." | |
| - name: Run Obfuscation | |
| run: obfuscar.console obfuscar.xml | |
| # ----------------------------- | |
| - name: Upload Build Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: R6Random-Release | |
| path: | | |
| r6random/bin/Release/Obfuscated/ | |
| !r6random/bin/Release/Obfuscated/*.xml | |
| !r6random/bin/Release/Obfuscated/*.pdb |