diff --git a/README.md b/README.md index 2172c1f7..f0e6b563 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ This software creates a folder `$"{System.Environment.SpecialFolder.ApplicationD | macOS | `${HOME}/Library/Application Support/SourceGit` | > [!TIP] -> You can open the app data dir from the main menu. +> You can open this data storage directory from the main menu. For **Windows** users: @@ -80,7 +80,8 @@ For **Windows** users: scoop bucket add extras scoop install sourcegit ``` -* Portable versions can be found in [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest) +* Pre-built binaries can be found in [Releases](https://github.com/sourcegit-scm/sourcegit/releases/latest) +* You can run `dotnet publish -c Release -r win-x64 -p:EnablePortable=true -o $YOUR_PUBLISH_DIR .\src\SourceGit.csproj` to build a portable version. For **macOS** users: @@ -159,7 +160,7 @@ This app supports open repository in external tools listed in the table below. > [!NOTE] > This app will try to find those tools based on some pre-defined or expected locations automatically. If you are using one portable version of these tools, it will not be detected by this app. -> To solve this problem you can add a file named `external_editors.json` in app data dir and provide the path directly. For example: +> To solve this problem you can add a file named `external_editors.json` in app data storage directory and provide the path directly. For example: ```json { "tools": { diff --git a/src/Native/OS.cs b/src/Native/OS.cs index b53f81d9..ca56cdac 100644 --- a/src/Native/OS.cs +++ b/src/Native/OS.cs @@ -1,5 +1,8 @@ using System; using System.Collections.Generic; +#if ENABLE_PORTABLE +using System.Diagnostics; +#endif using System.IO; using Avalonia; @@ -55,6 +58,16 @@ namespace SourceGit.Native public static void SetupDataDir() { +#if ENABLE_PORTABLE + if (OperatingSystem.IsWindows()) + { + var execFile = Process.GetCurrentProcess().MainModule!.FileName; + DataDir = Path.Combine(Path.GetDirectoryName(execFile), "data"); + if (!Directory.Exists(DataDir)) + Directory.CreateDirectory(DataDir); + return; + } +#endif var osAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (string.IsNullOrEmpty(osAppDataDir)) DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".sourcegit"); diff --git a/src/SourceGit.csproj b/src/SourceGit.csproj index 497a518f..8e8c2b3f 100644 --- a/src/SourceGit.csproj +++ b/src/SourceGit.csproj @@ -30,6 +30,10 @@ $(DefineConstants);DISABLE_UPDATE_DETECTION + + $(DefineConstants);ENABLE_PORTABLE + +