jhj0411jhj
Newcomer
Hello, I'm new to Stardew Valley modding and C#.
I've written a batch script that uses Docker to build plugins (on Windows), making it easier for users who don't use Visual Studio or prefer not to install .NET directly. The script is based on the `mcr.microsoft.com/dotnet/sdk:6.0` Docker image. macOS and Linux users can adapt it for their systems with some modifications.
For me, using AI coding tools along with this zero-cost build script has made it possible to quickly modify existing mods, even though I'm not very familiar with C# syntax or modding in detail. I hope this script can be helpful to others. I'm also wondering if it could be added to any modding tutorial to help more modding beginners get started.
Core command:
Usage:
1. Create a `build.bat` file outside the project directory, and copy the following code (Full content of `build.bat`) into it.
2. Modify the `GAME_PATH` variable to point to your Stardew Valley installation directory.
3. Modify the `PROJECT_NAME` variable to match the project directory.
4. Run `build.bat` to build the mod.
5. The mod will be deployed in the `Mods-deploy` directory. The release files will be in the `bin\Release\net6.0` directory.
Full content of `build.bat`:
I've written a batch script that uses Docker to build plugins (on Windows), making it easier for users who don't use Visual Studio or prefer not to install .NET directly. The script is based on the `mcr.microsoft.com/dotnet/sdk:6.0` Docker image. macOS and Linux users can adapt it for their systems with some modifications.
For me, using AI coding tools along with this zero-cost build script has made it possible to quickly modify existing mods, even though I'm not very familiar with C# syntax or modding in detail. I hope this script can be helpful to others. I'm also wondering if it could be added to any modding tutorial to help more modding beginners get started.
Core command:
Code:
docker run --rm ^
-v "%cd%:/workspace" ^
-v "%GAME_PATH%:/game:ro" ^
-v "%CACHE_DIR%:/root/.nuget/packages" ^
-v "%DEPLOY_DIR%:/game/Mods" ^
-w /workspace/%PROJECT_NAME% ^
-e NUGET_PACKAGES=/root/.nuget/packages ^
mcr.microsoft.com/dotnet/sdk:6.0 ^
sh -c "echo '<Project><PropertyGroup><GamePath>/game</GamePath></PropertyGroup></Project>' > ~/stardewvalley.targets && dotnet build --configuration Release"
1. Create a `build.bat` file outside the project directory, and copy the following code (Full content of `build.bat`) into it.
2. Modify the `GAME_PATH` variable to point to your Stardew Valley installation directory.
3. Modify the `PROJECT_NAME` variable to match the project directory.
4. Run `build.bat` to build the mod.
5. The mod will be deployed in the `Mods-deploy` directory. The release files will be in the `bin\Release\net6.0` directory.
Full content of `build.bat`:
Code:
@echo off
set PROJECT_NAME=Your-Project-Dir
set GAME_PATH=C:\Steam\steamapps\common\Stardew Valley
set CACHE_DIR=%cd%\nuget-cache
set DEPLOY_DIR=%cd%\Mods-deploy
if not exist "%CACHE_DIR%" (
echo Creating NuGet cache directory: %CACHE_DIR%
mkdir "%CACHE_DIR%"
)
if not exist "%DEPLOY_DIR%" (
echo Creating deploy directory: %DEPLOY_DIR%
mkdir "%DEPLOY_DIR%"
)
echo Building %PROJECT_NAME% mod using official .NET 6.0 SDK image...
echo Game path: %GAME_PATH%
echo NuGet cache: %CACHE_DIR%
echo Deploy directory: %DEPLOY_DIR%
echo.
docker run --rm ^
-v "%cd%:/workspace" ^
-v "%GAME_PATH%:/game:ro" ^
-v "%CACHE_DIR%:/root/.nuget/packages" ^
-v "%DEPLOY_DIR%:/game/Mods" ^
-w /workspace/%PROJECT_NAME% ^
-e NUGET_PACKAGES=/root/.nuget/packages ^
mcr.microsoft.com/dotnet/sdk:6.0 ^
sh -c "echo '<Project><PropertyGroup><GamePath>/game</GamePath></PropertyGroup></Project>' > ~/stardewvalley.targets && dotnet build --configuration Release"
if %ERRORLEVEL% EQU 0 (
echo.
echo Build successful!
echo Release location: %cd%\%PROJECT_NAME%\bin\Release\net6.0\
echo Deployed files location: %DEPLOY_DIR%\
echo You can copy the mod folder from %DEPLOY_DIR% to your Stardew Valley Mods folder.
) else (
echo.
echo Build failed. Please check the error messages above.
)
pause