Skip to content

Instantly share code, notes, and snippets.

@afruzan
Created September 26, 2024 19:16
Show Gist options
  • Save afruzan/26e1eb210d131b6a2ed1e1c58ccf63ca to your computer and use it in GitHub Desktop.
Save afruzan/26e1eb210d131b6a2ed1e1c58ccf63ca to your computer and use it in GitHub Desktop.
dotnet publish command with git semantic versioning
@echo off
for /F %%i in ('git describe --dirty --broken --tags --match v*.*') do set OUT=%%i
set "SUFFIX=%OUT:*-=%"
set "VERSION=%OUT:-="&:"%"
if "%SUFFIX%" == "%OUT%" set "SUFFIX="
set "VERSION=%VERSION:~1%"
echo "Publish directory: '%cd%\Publish\%OUT%'"
echo "Version: %VERSION% - Version-Suffix: %SUFFIX%"
echo "Publish App service..."
dotnet publish "dir\App.csproj" -c Release -o "Publish\%OUT%\App.Service" -p:BuildSpa=true -p:VersionPrefix=%VERSION% -p:VersionSuffix=%SUFFIX%
@afruzan
Copy link
Author

afruzan commented Sep 26, 2024

use git tags for versioning and everything will done with above command :)

@ma-mehralian
Copy link

ma-mehralian commented Oct 26, 2024

great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment