diff --git a/.gitignore b/.gitignore
index 7313eb4..5e9ad8b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,9 +20,6 @@ callgrind.*
 # GDB temp files
 .gdb_history
 
-# Git hash file
-githash.txt
-
 # Test results
 tests/tc*/actual*.txt
 stderr.txt
diff --git a/build.bat b/build.bat
index 4021b01..e036dcc 100644
--- a/build.bat
+++ b/build.bat
@@ -1,6 +1,20 @@
 IF "%DC%"=="" SET DC="dmd"
 IF "%MFLAGS%"=="" SET MFLAGS="-m32"
 
+
+:: git might not be installed, so we provide 0.0.0 as a fallback or use
+:: the existing githash file if existent
+if not exist "bin" mkdir bin
+git describe --tags > bin\githash_.txt
+for /f %%i in ("bin\githash_.txt") do set githashsize=%%~zi
+if %githashsize% == 0 (
+	if not exist "bin\githash.txt" (
+		echo v0.0.0 > bin\githash.txt
+	)
+) else (
+	move /y bin\githash_.txt bin\githash.txt
+)
+
 set containers_modules=
 for /r "containers/src" %%F in (*.d) do call set containers_modules=%%containers_modules%% "%%F"
 
@@ -49,6 +63,7 @@ set server_name=bin\dcd-server
  -Ilibdparse/src^
  -Istdx-allocator/source^
  -wi -O -release^
+ -Jbin^
  %MFLAGS%^
  -of%server_name%
 
diff --git a/dub.json b/dub.json
index 7bce7f8..c3a99a4 100644
--- a/dub.json
+++ b/dub.json
@@ -12,6 +12,9 @@
     "msgpack-d": "~>1.0.0-beta.3",
     "stdx-allocator": "~>2.77.2"
   },
+  "stringImportPaths" : [
+    "bin"
+  ],
   "versions": ["built_with_dub"],
   "configurations": [
     {
@@ -40,5 +43,8 @@
         "src/dcd/client/*"
       ]
     }
+  ],
+  "preGenerateCommands" : [
+    "rdmd --eval=\"auto dir=environment.get(\\\"DUB_PACKAGE_DIR\\\"); dir.buildPath(\\\"bin\\\").mkdirRecurse; auto gitVer = (\\\"git -C \\\"~dir~\\\" describe --tags\\\").executeShell; (gitVer.status == 0 ? gitVer.output.strip : \\\"v\\\" ~ dir.dirName.baseName.findSplitAfter(environment.get(\\\"DUB_ROOT_PACKAGE\\\")~\\\"-\\\")[1]).ifThrown(\\\"0.0.0\\\").chain(newline).toFile(dir.buildPath(\\\"bin\\\", \\\"dubhash.txt\\\"));\""
   ]
 }
diff --git a/makefile b/makefile
index a7f41e4..6b3999e 100644
--- a/makefile
+++ b/makefile
@@ -17,7 +17,8 @@ STDXALLOC_DIR := stdx-allocator
 SHELL:=/bin/bash
 
 githash:
-	git log -1 --format="%H" > githash.txt
+	@mkdir -p bin
+	git describe --tags > bin/githash.txt
 
 report:
 	dscanner --report src > dscanner-report.json
@@ -36,21 +37,21 @@ CLIENT_SRC := \
 
 DMD_CLIENT_FLAGS := -Imsgpack-d/src\
 	-Imsgpack-d/src\
-	-J.\
+	-Jbin\
 	-inline\
 	-O\
 	-wi\
 	-ofbin/dcd-client
 
 GDC_CLIENT_FLAGS := -Imsgpack-d/src\
-	-J.\
+	-Jbin\
 	-O3\
 	-frelease\
 	-obin/dcd-client
 
 LDC_CLIENT_FLAGS := -Imsgpack-d/src\
 	-Imsgpack-d/src\
-	-J=.\
+	-J=bin\
 	-release\
 	-O5\
 	-oq\
@@ -87,7 +88,7 @@ DMD_SERVER_FLAGS := -Icontainers/src\
 	-I${DPARSE_DIR}/src\
 	-I${DSYMBOL_DIR}/src\
 	-I${STDXALLOC_DIR}/source\
-	-J.\
+	-Jbin\
 	-wi\
 	-O\
 	-release\
@@ -101,13 +102,13 @@ DEBUG_SERVER_FLAGS := -Icontainers/src\
 	-wi\
 	-g\
 	-ofbin/dcd-server\
-	-J.
+	-Jbin
 
 GDC_SERVER_FLAGS := -Icontainers/src\
 	-Imsgpack-d/src\
 	-I${DPARSE_DIR}/src\
 	-I${DSYMBOL_DIR}/src\
-	-J.\
+	-Jbin\
 	-O3\
 	-frelease\
 	-obin/dcd-server
@@ -117,7 +118,7 @@ LDC_SERVER_FLAGS := -Icontainers/src\
 	-I${DPARSE_DIR}/src\
 	-I${DSYMBOL_DIR}/src\
 	-Isrc\
-	-J=.\
+	-J=bin\
 	-O5\
 	-release
 
diff --git a/release-windows.sh b/release-windows.sh
index e9ac622..82ef505 100755
--- a/release-windows.sh
+++ b/release-windows.sh
@@ -26,6 +26,7 @@ fi
 archiveName="dcd-$VERSION-$OS-$ARCH_SUFFIX.zip"
 echo "Building $archiveName"
 mkdir -p bin
+git describe --tags > bin/githash.txt # no git installed under Wine
 DC="$DIR/dmd2/windows/bin/dmd.exe" wine cmd /C build.bat
 
 cd bin
diff --git a/src/dcd/client/client.d b/src/dcd/client/client.d
index 2ebfe44..b3f4f3d 100644
--- a/src/dcd/client/client.d
+++ b/src/dcd/client/client.d
@@ -92,12 +92,7 @@ int main(string[] args)
 
 	if (printVersion)
 	{
-		version (Windows)
-			writeln(DCD_VERSION);
-		else version(built_with_dub)
-			writeln(DCD_VERSION);
-		else
-			write(DCD_VERSION, " ", GIT_HASH);
+		writeln(DCD_VERSION);
 		return 0;
 	}
 
diff --git a/src/dcd/common/dcd_version.d b/src/dcd/common/dcd_version.d
index 5a9756e..2d4cccb 100644
--- a/src/dcd/common/dcd_version.d
+++ b/src/dcd/common/dcd_version.d
@@ -18,17 +18,20 @@
 
 module dcd.common.dcd_version;
 
+import std.string : strip;
+
 /**
  * Human-readable version number
  */
-enum DCD_VERSION = "v0.9.8";
 
-version (Windows) {}
-else version (built_with_dub) {}
+version (built_with_dub)
+{
+	enum DCD_VERSION = import("dubhash.txt").strip;
+}
 else
 {
 	/**
 	 * Current build's Git commit hash
 	 */
-	enum GIT_HASH = import("githash.txt");
+	enum DCD_VERSION = import("githash.txt").strip;
 }
diff --git a/src/dcd/server/main.d b/src/dcd/server/main.d
index edad504..9e19c3e 100644
--- a/src/dcd/server/main.d
+++ b/src/dcd/server/main.d
@@ -81,12 +81,7 @@ int main(string[] args)
 
 	if (printVersion)
 	{
-		version (Windows)
-			writeln(DCD_VERSION);
-		else version (built_with_dub)
-			writeln(DCD_VERSION);
-		else
-			write(DCD_VERSION, " ", GIT_HASH);
+		writeln(DCD_VERSION);
 		return 0;
 	}