├── .github └── workflows │ └── main.yml ├── .gitignore ├── README.md ├── package ├── GameLibs.nuspec └── lib │ └── .dlls-here ├── strip-assembiles.bat └── tools ├── NStrip-LICENSE └── NStrip.exe /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Pack and publish nuget 2 | 3 | on: 4 | push: 5 | branches: [main] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | build: 10 | runs-on: windows-2019 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: NuGet/setup-nuget@v1.0.5 14 | - name: Pack nuget 15 | run: nuget pack package -OutputFileNamesWithoutVersion -OutputDirectory build -Properties "git=https://github.com/${{ github.repository }}.git;name=${{ github.event.repository.name }};author=${{ github.repository_owner }};description=${{ github.event.repository.description }}" 16 | - name: Publish nuget 17 | run: | 18 | nuget push "build/${{ github.event.repository.name }}.nupkg" -ApiKey ${{ secrets.NUGET_KEY }} -Source https://api.nuget.org/v3/index.json 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Game Libs Nuget Creator 2 | 3 | Creates nugets with stripped and publicized libraries for Unity game modding. 4 | 5 | If the game gets updated, this package needs to get updated too. 6 | 7 | `strip-assembiles.bat` does two things: 8 | 9 | - Strips game assembiles using [NStrip](https://github.com/BepInEx/NStrip). This removes game code and leaves only API definitions. 10 | - Publicizes `Assembly.CSharp.dll` and `AAssembly-CSharp-firstpass.dll`. This makes all types, methods, properties and fields public, to make modding easier. 11 | 12 | ## Usage 13 | 14 | ### Nuget account 15 | 16 | - Go to [nuget.org](https://nuget.org/). 17 | - Either log in, or create a new account. 18 | - [Create a new API key](https://www.nuget.org/account/apikeys) with permissions to push new packages. 19 | 20 | ### Prepare your repository 21 | 22 | - [Create a new repository based on this template](https://github.com/Raicuparta/unity-libs-nuget/generate). 23 | - Add a secret called `NUGET_KEY` to this repository. Give it the value of the API key you created earlier. 24 | - Update the repository's name. This will be used as your Nuget ID, so it can't clash with another nuget package on [nuget.org](https://nuget.org/). 25 | - Update the repository's description. This will be used as the nuget's description too. 26 | 27 | ### Generate the stripped libraries 28 | 29 | - Make sure you start off with a clean version of the game files, with no extra/modified dlls. 30 | - Drag the game's exe and drop it on `strip-assembiles.bat`. 31 | - Dlls are stripped, publicized, and placed in `package\lib`. 32 | 33 | ### Updating the Nuget 34 | 35 | - Edit the `.nuspec` file, make `` match the game version where these assemblies come from. 36 | - Push to the default branch. 37 | - Updating the default branch will trigger a workflow that will pack the dlls and update the NuGet package. 38 | 39 | ### Publicized assemblies 40 | 41 | By default, only `Assembly-CSharp.dll` and `Assembly-CSharp-firstpass.dll` are publicized. All other dlls are stripped only. To publicize other dlls, edit `strip-assemblies.bat` and add the dll names to the `toPublicize` variable. 42 | 43 | ### Untouched assemblies 44 | 45 | By default, every game assembly gets stripped. If there's any assembly you wish to keep in the package in their original state, add the dll names to the `dontTouch` variable. 46 | -------------------------------------------------------------------------------- /package/GameLibs.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | 7 | 1.0.0 8 | 9 | 10 | $name$ 11 | $name$ 12 | $author$ 13 | $description$ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /package/lib/.dlls-here: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raicuparta/unity-libs-nuget/e9bed9c8211a2423ce44cb3d47b0ff3de1f51d9b/package/lib/.dlls-here -------------------------------------------------------------------------------- /strip-assembiles.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | @REM Add all the assemblies you want to publicize in this list 4 | set toPublicize=Assembly-CSharp.dll Assembly-CSharp-firstpass.dll 5 | 6 | @REM Add all the assemblies you want to copy as-is to the package in this list 7 | set dontTouch= 8 | 9 | set exePath=%1 10 | echo exePath: %exePath% 11 | 12 | @REM Remove quotes 13 | set exePath=%exePath:"=% 14 | 15 | set managedPath=%exePath:.exe=_Data\Managed% 16 | echo managedPath: %managedPath% 17 | 18 | set outPath=%~dp0\package\lib 19 | 20 | @REM Strip all assembiles, but keep them private. 21 | %~dp0\tools\NStrip.exe "%managedPath%" -o %outPath% 22 | 23 | @REM Strip and publicize assemblies from toPublicize. 24 | (for %%a in (%toPublicize%) do ( 25 | echo a: %%a 26 | 27 | %~dp0\tools\NStrip.exe "%managedPath%\%%a" -o "%outPath%\%%a" -cg -p --cg-exclude-events 28 | )) 29 | 30 | @REM Copy over original assemblies for ones we don't want to touch. 31 | (for %%a in (%dontTouch%) do ( 32 | echo a: %%a 33 | 34 | xcopy "%managedPath%\%%a" "%outPath%\%%a" /y /v 35 | )) 36 | 37 | pause 38 | -------------------------------------------------------------------------------- /tools/NStrip-LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 BepInEx 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tools/NStrip.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raicuparta/unity-libs-nuget/e9bed9c8211a2423ce44cb3d47b0ff3de1f51d9b/tools/NStrip.exe --------------------------------------------------------------------------------