batch script for .net build project only updated directory in github

24 Views Asked by At

I just want to create batch script for which can get the latest commit updated files and directory of .NET project from GitHub and build only updated files and directory of micro-service

@echo off

set repoUrl=https://github.com/yourusername/yourrepository.git
set localPath=C:\Path\To\Your\Local\Directory

echo Cloning repository...
git clone %repoUrl% %localPath%
if %errorlevel% neq 0 (
    echo Error: Failed to clone the repository.
    exit /b %errorlevel%
)

cd %localPath%

echo Fetching updates...
git fetch
if %errorlevel% neq 0 (
    echo Error: Failed to fetch updates.
    exit /b %errorlevel%
)

echo Checking for updated files...
git diff --name-only origin/master..HEAD > updated_files.txt

if %errorlevel% neq 0 (
    echo Error: Failed to check for updated files.
    exit /b %errorlevel%
)

echo Building project...

for /f "tokens=*" %%f in (updated_files.txt) do (
    echo Building %%f...
    dotnet build "%%f"
    if %errorlevel% neq 0 (
        echo Error: Failed to build %%f.
        exit /b %errorlevel%
    )
)

echo Build completed successfully.
exit /b
0

There are 0 best solutions below