Skip to content

Commit

Permalink
打包时支持配置使用 版本号文件夹 替换 bin文件夹;
Browse files Browse the repository at this point in the history
  • Loading branch information
Handsome08 committed Nov 12, 2024
1 parent c0a1d74 commit 19c3ed9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
10 changes: 10 additions & 0 deletions DebUOS/Packaging.DebUOS.NuGet/Build/package.targets
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@
<DebUOSPackingWriteArgLine Include="$([MSBuild]::Escape($(DesktopMimeType)))"/>
<DebUOSPackingWriteArgLine Include=">"/>

<DebUOSPackingWriteArgLine Include=">"/>
<DebUOSPackingWriteArgLine Include="CopyDesktopFileToUsrShareApplications" Condition="$(CopyDesktopFileToUsrShareApplications)!=''"/>
<DebUOSPackingWriteArgLine Include="$([MSBuild]::Escape($(CopyDesktopFileToUsrShareApplications)))"/>
<DebUOSPackingWriteArgLine Include=">"/>

<DebUOSPackingWriteArgLine Include=">"/>
<DebUOSPackingWriteArgLine Include="PackingFolder" Condition="$(PackingFolder)!=''"/>
<DebUOSPackingWriteArgLine Include="$(PackingFolder)"/>
Expand Down Expand Up @@ -294,6 +299,11 @@
<DebUOSPackingWriteArgLine Include="$([MSBuild]::Escape($(ExcludePackingDebFileExtensions)))"/>
<DebUOSPackingWriteArgLine Include=">"/>

<DebUOSPackingWriteArgLine Include=">"/>
<DebUOSPackingWriteArgLine Include="ReplaceBinWithAppVersion" Condition="$(ReplaceBinWithAppVersion)!=''"/>
<DebUOSPackingWriteArgLine Include="$([MSBuild]::Escape($(ReplaceBinWithAppVersion)))"/>
<DebUOSPackingWriteArgLine Include=">"/>

</ItemGroup>
<WriteLinesToFile File="$(DebUOSPackingArgsFile)" Lines="@(DebUOSPackingWriteArgLine)" Overwrite="True" />
<Exec Command="dotnet &quot;$(MSBuildThisFileDirectory)..\tools\Packaging.DebUOS.Tool.dll&quot; -p $(DebUOSPackingArgsFile)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,15 @@ public string? ExcludePackingDebFileExtensions
set => SetValue(value);
get => GetString() ?? ".pdb;.dbg;.md";
}

/// <summary>
/// 打包时是否将 bin 文件夹替换为应用版本号,默认不替换
/// </summary>
public bool ReplaceBinWithAppVersion
{
set => SetValue(value);
get => GetBoolean() ?? false;
}

#endregion
}
12 changes: 7 additions & 5 deletions DebUOS/Packaging.DebUOS/DebUOSPackageFileStructCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ public void CreatePackagingFolder(DebUOSConfiguration configuration)
var appIdFolder = Path.Join(packingFolder, "opt", "apps", appId);
var filesFolder = Path.Join(appIdFolder, "files");
Directory.CreateDirectory(filesFolder);
var applicationBin = Path.Join(filesFolder, "bin");
if (!FolderUtils.CreateSymbolLinkOrCopyFolder(projectPublishFolder, applicationBin))
var applicationFolder = configuration.ReplaceBinWithAppVersion ? Path.Join(filesFolder, configuration.UOSDebVersion) : Path.Join(filesFolder, "bin");
if (!FolderUtils.CreateSymbolLinkOrCopyFolder(projectPublishFolder, applicationFolder))
{
throw new PackagingException($"将发布输出文件拷贝到安装包打包文件夹失败,从 '{projectPublishFolder}' 复制到 '{applicationBin}' 失败");
throw new PackagingException($"将发布输出文件拷贝到安装包打包文件夹失败,从 '{projectPublishFolder}' 复制到 '{applicationFolder}' 失败");
}

// opt\apps\AppId\entries
// opt\apps\AppId\entries\applications
var entriesFolder = Path.Join(appIdFolder, "entries");
Expand Down Expand Up @@ -153,7 +153,9 @@ public void CreatePackagingFolder(DebUOSConfiguration configuration)
{
// 这里不能使用 Path.Join 方法,因为如果在 Windows 上进行打包,会将 \ 替换为 /,导致打包失败
//var exec = Path.Join("/opt/apps", appId, "files", "bin", configuration.AssemblyName);
var exec = $"/opt/apps/{appId}/files/bin/{configuration.AssemblyName}";
var exec = configuration.ReplaceBinWithAppVersion
? $"/opt/apps/{appId}/files/{configuration.UOSDebVersion}/{configuration.AssemblyName}"
: $"/opt/apps/{appId}/files/bin/{configuration.AssemblyName}";
stringBuilder.Append($"Exec={exec}\n");
}

Expand Down

0 comments on commit 19c3ed9

Please sign in to comment.