mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
feature: add -p:EnablePortable=true
option for dotnet publish
command to store app data portable (#834)
Some checks are pending
Some checks are pending
This commit is contained in:
parent
7028e08390
commit
f53b71bfe7
3 changed files with 21 additions and 3 deletions
|
@ -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": {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
<DefineConstants>$(DefineConstants);DISABLE_UPDATE_DETECTION</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(EnablePortable)' == 'true'">
|
||||
<DefineConstants>$(DefineConstants);ENABLE_PORTABLE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="App.ico" />
|
||||
<AvaloniaResource Include="Resources/Fonts/*" />
|
||||
|
|
Loading…
Reference in a new issue