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 failed
Some checks failed
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` |
|
| macOS | `${HOME}/Library/Application Support/SourceGit` |
|
||||||
|
|
||||||
> [!TIP]
|
> [!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:
|
For **Windows** users:
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ For **Windows** users:
|
||||||
scoop bucket add extras
|
scoop bucket add extras
|
||||||
scoop install sourcegit
|
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:
|
For **macOS** users:
|
||||||
|
|
||||||
|
@ -159,7 +160,7 @@ This app supports open repository in external tools listed in the table below.
|
||||||
|
|
||||||
> [!NOTE]
|
> [!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.
|
> 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
|
```json
|
||||||
{
|
{
|
||||||
"tools": {
|
"tools": {
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
#if ENABLE_PORTABLE
|
||||||
|
using System.Diagnostics;
|
||||||
|
#endif
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
@ -55,6 +58,16 @@ namespace SourceGit.Native
|
||||||
|
|
||||||
public static void SetupDataDir()
|
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);
|
var osAppDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||||
if (string.IsNullOrEmpty(osAppDataDir))
|
if (string.IsNullOrEmpty(osAppDataDir))
|
||||||
DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".sourcegit");
|
DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".sourcegit");
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
<DefineConstants>$(DefineConstants);DISABLE_UPDATE_DETECTION</DefineConstants>
|
<DefineConstants>$(DefineConstants);DISABLE_UPDATE_DETECTION</DefineConstants>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(EnablePortable)' == 'true'">
|
||||||
|
<DefineConstants>$(DefineConstants);ENABLE_PORTABLE</DefineConstants>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AvaloniaResource Include="App.ico" />
|
<AvaloniaResource Include="App.ico" />
|
||||||
<AvaloniaResource Include="Resources/Fonts/*" />
|
<AvaloniaResource Include="Resources/Fonts/*" />
|
||||||
|
|
Loading…
Reference in a new issue