Skip to content

Commit

Permalink
添加 --force 选项以及BUG修复
Browse files Browse the repository at this point in the history
## 新增
1. `--force`以及`ForceBeauty`选项

## 修复
1. Nuget包`DisablePatch`选项无法正确计算的问题
2. Nuget包`BeautyLogLevel`选项`Info`错写成`Log`的问题

## 更新
1. 类库xml文件跟随程序集移动

## 优化
1. Nuget使用示例镜像库改为gitee镜像
2. 移除`BeautyDir`选项多余的路径兼容性拼接
  • Loading branch information
liesauer committed Dec 23, 2019
1 parent 4865398 commit b3195e7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion NetCoreBeautyGlobalTool/NetCoreBeautyGlobalTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ToolCommandName>ncbeauty</ToolCommandName>
<PackageOutputPath>.nupkg</PackageOutputPath>

<Version>1.1.7</Version>
<Version>1.1.8</Version>

<Authors>LiesAuer</Authors>
<Description>Move a .NET Core app runtime components and dependencies into a sub-directory and make it beauty.</Description>
Expand Down
8 changes: 5 additions & 3 deletions NetCoreBeautyNuget/Beauty.targets
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
<BeautyAfterTasks>Publish;$(BeautyAfterTasks)</BeautyAfterTasks>
<GitCDN Condition="$(GitCDN) != ''">--gitcdn $(GitCDN)</GitCDN>
<BeautyLogLevel Condition="$(BeautyLogLevel) != ''">--loglevel $(BeautyLogLevel)</BeautyLogLevel>
<DisablePatch Condition="$(DisablePatch) == 'True'">--nopatch</DisablePatch>
<DisablePatch Condition="$(DisablePatch) != 'True'"></DisablePatch>
<DisablePatch Condition="$(DisablePatch) == 'True'">--nopatch</DisablePatch>
<ForceBeauty Condition="$(ForceBeauty) != 'True'"></ForceBeauty>
<ForceBeauty Condition="$(ForceBeauty) == 'True'">--force</ForceBeauty>
</PropertyGroup>

<Target Name="NetCoreBeauty" AfterTargets="$(BeautyAfterTasks)" Condition="$(DisableBeauty) != 'True' And $(RuntimeIdentifier) != ''">
Expand All @@ -22,9 +24,9 @@
</ItemGroup>

<PropertyGroup>
<BeautyDir>"%(PublishDir.FullPath)/.HERE/.."</BeautyDir>
<BeautyDir>"%(PublishDir.FullPath)"</BeautyDir>
</PropertyGroup>

<Exec Command="$(BeautyBin) $(GitCDN) $(BeautyLogLevel) $(DisablePatch) $(BeautyDir) $(BeautyLibsDir)" />
<Exec Command="$(BeautyBin) $(GitCDN) $(BeautyLogLevel) $(DisablePatch) $(ForceBeauty) $(BeautyDir) $(BeautyLibsDir)" />
</Target>
</Project>
2 changes: 1 addition & 1 deletion NetCoreBeautyNuget/NetCoreBeauty.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<metadata>
<id>nulastudio.NetCoreBeauty</id>
<description>Move a .NET Core app runtime components and dependencies into a sub-directory and make it beauty.</description>
<version>1.1.7</version>
<version>1.1.8</version>
<authors>LiesAuer</authors>
<owners>nulastudio</owners>
<projectUrl>https://github.com/nulastudio/NetCoreBeauty</projectUrl>
Expand Down
5 changes: 3 additions & 2 deletions NetCoreBeautyNugetTest/NetCoreBeautyTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
<BeautyLibsDir>runtimes</BeautyLibsDir>
<!-- set to True if you want to disable -->
<DisableBeauty>False</DisableBeauty>
<ForceBeauty>False</ForceBeauty>
<!-- <BeautyAfterTasks></BeautyAfterTasks> -->
<!-- set to True if you want to disable -->
<DisablePatch>False</DisablePatch>
<!-- valid values: Error|Detail|Log -->
<!-- valid values: Error|Detail|Info -->
<BeautyLogLevel>Error</BeautyLogLevel>
<!-- set to a repo mirror if you have troble in connecting github -->
<!-- <GitCDN>https://github-like.com/someone/HostFXRPatcherMirror</GitCDN> -->
<!-- <GitCDN>https://gitee.com/liesauer/HostFXRPatcher</GitCDN> -->
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ your `*.csproj` should be similar like this
<BeautyLibsDir>runtimes</BeautyLibsDir>
<!-- set to True if you want to disable -->
<DisableBeauty>False</DisableBeauty>
<ForceBeauty>False</ForceBeauty>
<!-- <BeautyAfterTasks></BeautyAfterTasks> -->
<!-- set to True if you want to disable -->
<DisablePatch>False</DisablePatch>
<!-- valid values: Error|Detail|Info -->
<BeautyLogLevel>Error</BeautyLogLevel>
<!-- set to a repo mirror if you have troble in connecting github -->
<!-- <GitCDN>https://github-like.com/someone/HostFXRPatcherMirror</GitCDN> -->
<!-- <GitCDN>https://gitee.com/liesauer/HostFXRPatcher</GitCDN> -->
</PropertyGroup>

<ItemGroup>
Expand Down
19 changes: 12 additions & 7 deletions src/main/beauty.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var runtimeSupportedJSON *simplejson.Json

var gitcdn string
var nopatch bool
var force bool
var loglevel string
var beautyDir string
var libsDir = "runtimes"
Expand All @@ -55,8 +56,11 @@ func main() {

// 检查是否已beauty
if util.PathExists(beautyCheck) {
log.LogDetail("already beauty. Enjoy it!")
return
if !force {
log.LogDetail("already beauty. Enjoy it!")
return
}
log.LogDetail("already beauty but you are in force mode, continuing...")
}

// 必须检查
Expand Down Expand Up @@ -129,6 +133,7 @@ Info: Log everything.
flag.BoolVar(&nopatch, "nopatch", false, `disable hostfxr patch.
DO NOT DISABLE!!!
hostfxr patch fixes https://github.com/nulastudio/NetCoreBeauty/issues/1`)
flag.BoolVar(&force, "force", false, `disable beauty checking and force beauty again.`)

flag.Parse()

Expand Down Expand Up @@ -169,7 +174,7 @@ hostfxr patch fixes https://github.com/nulastudio/NetCoreBeauty/issues/1`)

func usage() {
fmt.Println("Usage:")
fmt.Println("ncbeauty [--<gitcdn>] [--<loglevel=Error|Detail|Info>] [--<nopatch=True|False>] <beautyDir> [<libsDir>]")
fmt.Println("ncbeauty [--<force=True|False>] [--<gitcdn>] [--<loglevel=Error|Detail|Info>] [--<nopatch=True|False>] <beautyDir> [<libsDir>]")
flag.PrintDefaults()
}

Expand Down Expand Up @@ -197,7 +202,7 @@ func patch(fxrVersion string, rid string) bool {
absFxrBakName := absFxrName + ".bak"
log.LogInfo(fmt.Sprintf("backuping fxr to %s\n", absFxrBakName))

if util.PathExists(absFxrBakName) {
if util.PathExists(absFxrBakName) && !force {
log.LogDetail("fxr backup found, skipped")
} else {
if _, err := util.CopyFile(absFxrName, absFxrBakName); err != nil {
Expand All @@ -223,7 +228,7 @@ func moveDeps(depsFiles []string, mainProgram string) int {
strings.Contains(depsFile, "apphost") ||
strings.Contains(depsFile, "hostfxr") ||
strings.Contains(depsFile, "hostpolicy") {
// 将其加一,不然每次看到日志的文件移动数少3会造成疑惑
// NOTE: 计数加一,不然每次看到日志的文件移动数少3会造成疑惑
moved++
continue
}
Expand All @@ -240,10 +245,10 @@ func moveDeps(depsFiles []string, mainProgram string) int {
moved++
}

// NOTE: pdb跟随程序集、xml按照用户习惯做法跟随程序根目录
// NOTE: pdb、xml跟随程序集
// TODO: 提供一个选项,自由选择xml:跟随主程序、跟随程序集、跟随两者
fileName := strings.TrimSuffix(path.Base(depsFile), path.Ext(depsFile))
extFiles := []string{".pdb" /*, ".xml"*/}
extFiles := []string{".pdb", ".xml"}
for _, extFile := range extFiles {
oldFile := path.Join(oldPath, fileName+extFile)
newFile := path.Join(newPath, fileName+extFile)
Expand Down

0 comments on commit b3195e7

Please sign in to comment.