55using Microsoft . Extensions . Logging ;
66using Packaging . DebUOS . Contexts ;
77using Packaging . DebUOS . Contexts . Configurations ;
8+ using Packaging . DebUOS . Exceptions ;
89using Walterlv . IO . PackageManagement ;
910
1011namespace Packaging . DebUOS ;
@@ -28,8 +29,7 @@ public void CreatePackagingFolder(DebUOSConfiguration configuration)
2829 var projectPublishFolder = configuration . ProjectPublishFolder ;
2930 if ( ! Directory . Exists ( projectPublishFolder ) )
3031 {
31- Logger . LogError ( $ "Project publish folder '{ projectPublishFolder } ' not exist") ;
32- return ;
32+ throw new PackagingException ( $ "Project publish folder '{ projectPublishFolder } ' not exist") ;
3333 }
3434
3535 var workingFolder = configuration . WorkingFolder ;
@@ -60,16 +60,13 @@ public void CreatePackagingFolder(DebUOSConfiguration configuration)
6060 var appId = configuration . UOSAppId ;
6161 if ( string . IsNullOrEmpty ( appId ) )
6262 {
63- Logger . LogError ( $ "找不到 UOS 的 AppId 内容,请确保已经配置 UOSAppId 属性") ;
64- return ;
63+ throw new PackagingException ( $ "找不到 UOS 的 AppId 内容,请确保已经配置 UOSAppId 属性") ;
6564 }
6665
6766 var match = Regex . Match ( appId , @"[a-z\.]+" ) ;
6867 if ( ! match . Success || match . Value != appId )
6968 {
70- Logger . LogError (
71- $ "UOS 的 AppId 内容不符合规范,请确保配置的 UOSAppId 属性符合规范。请务必使用厂商的倒置域名+产品名作为应用包名,如 `com.example.demo` 格式,且只允许使用小写字母") ;
72- return ;
69+ throw new PackagingException ( $ "UOS 的 AppId 内容不符合规范,请确保配置的 UOSAppId 属性符合规范。请务必使用厂商的倒置域名+产品名作为应用包名,如 `com.example.demo` 格式,且只允许使用小写字母。UOSAppId={ appId } ") ;
7370 }
7471
7572 // opt\apps\AppId\
@@ -82,8 +79,7 @@ public void CreatePackagingFolder(DebUOSConfiguration configuration)
8279 var symbol = Directory . CreateSymbolicLink ( applicationBin , projectPublishFolder ) ;
8380 if ( ! symbol . Exists )
8481 {
85- Logger . LogError ( $ "创建符号链接失败,从 '{ projectPublishFolder } ' 到 '{ applicationBin } '") ;
86- return ;
82+ throw new PackagingException ( $ "创建符号链接失败,从 '{ projectPublishFolder } ' 到 '{ applicationBin } '") ;
8783 }
8884
8985 // opt\apps\AppId\entries
@@ -166,8 +162,7 @@ public void CreatePackagingFolder(DebUOSConfiguration configuration)
166162 // 如果开发者配置了自定义的图标文件夹,则使用开发者的文件夹
167163 if ( ! Directory . Exists ( configuration . UOSDebIconFolder ) )
168164 {
169- Logger . LogError ( $ "配置了 Icon 文件夹的 UOSDebIconFolder 属性,但文件夹不存在 UOSDebIconFolder={ configuration . UOSDebIconFolder } FullPath={ Path . GetFullPath ( configuration . UOSDebIconFolder ) } ") ;
170- return ;
165+ throw new PackagingException ( $ "配置了 Icon 文件夹的 UOSDebIconFolder 属性,但文件夹不存在 UOSDebIconFolder={ configuration . UOSDebIconFolder } FullPath={ Path . GetFullPath ( configuration . UOSDebIconFolder ) } ") ;
171166 }
172167
173168 PackageDirectory . Copy ( configuration . UOSDebIconFolder , iconsFolder ) ;
0 commit comments