Skip to content

Commit

Permalink
Add --noruntimeinfo and BeautyNoRuntimeInfo option
Browse files Browse the repository at this point in the history
related issues: #48, #50, #56
  • Loading branch information
liesauer committed Mar 2, 2024
1 parent 9bc0f80 commit e9df68b
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Common/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackageOutputPath>.nupkg</PackageOutputPath>
<Version>2.1.4.3</Version>
<Version>2.1.4.4</Version>

<Company>nulastudio</Company>
<Authors>LiesAuer</Authors>
Expand Down
6 changes: 4 additions & 2 deletions NetBeauty/src/main/beauty.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var libsDir = "libraries"
var excludes = ""
var hiddens = ""
var sharedRuntimeMode = false
var noRuntimeInfo = false
var enableDebug = false
var usePatch = false
var isNetFx = false
Expand Down Expand Up @@ -159,7 +160,7 @@ func main() {

usePatch = SCDMode && usePatch

allDeps, _useWPF, _ := manager.FixDeps(deps.deps, deps.main, SCDMode, usePatch, enableDebug, sharedRuntimeMode)
allDeps, _useWPF, _ := manager.FixDeps(deps.deps, deps.main, SCDMode, noRuntimeInfo, usePatch, enableDebug, sharedRuntimeMode)

useWPF = _useWPF

Expand Down Expand Up @@ -402,6 +403,7 @@ Detail: Log useful infos.
Info: Log everything.
`)
flag.BoolVar(&sharedRuntimeMode, "srmode", false, `[.NET Core App Only] share the runtime between apps`)
flag.BoolVar(&noRuntimeInfo, "noruntimeinfo", false, `[.NET Core App Only] keep the runtime info in deps.json or not`)
flag.BoolVar(&enableDebug, "enabledebug", false, `[.NET Core App Only] allow 3rd debuggers(like dnSpy) debugs the app`)
flag.BoolVar(&usePatch, "usepatch", false, `[.NET Core App Only] use the patched hostfxr to reduce files`)
flag.StringVar(&hiddens, "hiddens", "", `dlls that end users never needed, so hide them.`)
Expand Down Expand Up @@ -525,7 +527,7 @@ func exit() {

func usage() {
fmt.Println("Usage:")
fmt.Println("nbeauty [--loglevel=(Error|Detail|Info)] [--srmode] [--enabledebug] [--usepatch] [--hiddens=hiddenFiles] [--roll-forward=<rollForward>] [--apphostentry=<appHostEntry>] [--apphostdir=<appHostDir>] <beautyDir> [<libsDir> [<excludes>]]")
fmt.Println("nbeauty [--loglevel=(Error|Detail|Info)] [--srmode] [--enabledebug] [--usepatch] [--hiddens=hiddenFiles] [--noruntimeinfo] [--roll-forward=<rollForward>] [--apphostentry=<appHostEntry>] [--apphostdir=<appHostDir>] <beautyDir> [<libsDir> [<excludes>]]")
fmt.Println("")
fmt.Println("Arguments")
fmt.Println(" <excludes> dlls that no need to be moved, multi-dlls separated with \";\". Example: dll1.dll;lib*;...")
Expand Down
4 changes: 2 additions & 2 deletions NetBeauty/src/main/bindata.go

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions NetBeauty/src/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ func FindFXRVersion(deps string) (string, string) {
}

// FixDeps 分析deps.json中的依赖项
func FixDeps(deps string, entry string, SCDMode bool, usePatch bool, enableDebug bool, sharedRuntimeMode bool) ([]Deps, bool, bool) {
func FixDeps(deps string, entry string, SCDMode bool, noRuntimeInfo bool, usePatch bool, enableDebug bool, sharedRuntimeMode bool) ([]Deps, bool, bool) {
var isAspNetCore = false
var useWPF = false
var verifyWpfDllSet = false
Expand Down Expand Up @@ -759,7 +759,7 @@ func FixDeps(deps string, entry string, SCDMode bool, usePatch bool, enableDebug
}

// nbloader dependencies
if SCDMode && !usePatch {
if (SCDMode || noRuntimeInfo) && !usePatch {
if fileName == "System.Collections.dll" ||
fileName == "System.Memory.dll" ||
fileName == "System.Private.CoreLib.dll" ||
Expand Down Expand Up @@ -983,7 +983,7 @@ func FixDeps(deps string, entry string, SCDMode bool, usePatch bool, enableDebug
}
}

if SCDMode && !strings.HasPrefix(analyzed.ItemKey, "./") {
if (SCDMode || noRuntimeInfo) && !strings.HasPrefix(analyzed.ItemKey, "./") {
delete(analyzed.Category, analyzed.ItemKey)
}
}
Expand Down
Binary file modified NetBeauty/src/nbloader/nbloader.dll
Binary file not shown.
12 changes: 7 additions & 5 deletions NetBeautyNuget/Beauty.targets
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
<BeautyEnableDebugging Condition="$(BeautyEnableDebugging) == 'True'">--enabledebug</BeautyEnableDebugging>
<BeautyUsePatch Condition="$(BeautyUsePatch) != 'True'"></BeautyUsePatch>
<BeautyUsePatch Condition="$(BeautyUsePatch) == 'True'">--usepatch</BeautyUsePatch>
<BeautyNoRuntimeInfo Condition="$(BeautyNoRuntimeInfo) != 'True'"></BeautyNoRuntimeInfo>
<BeautyNoRuntimeInfo Condition="$(BeautyNoRuntimeInfo) == 'True'">--noruntimeinfo</BeautyNoRuntimeInfo>
<BeautyAppHostEntry Condition="$(BeautyAppHostEntry) != ''">--apphostentry "$(BeautyAppHostEntry)"</BeautyAppHostEntry>
<BeautyAppHostDir Condition="$(BeautyAppHostDir) != ''">--apphostdir "$(BeautyAppHostDir)"</BeautyAppHostDir>
<_BeautyDependsOnForBuild_NetFx Condition="'$(MSBuildRuntimeType)' == 'Full'">AfterBuild;$(BeautyAfterTasks)</_BeautyDependsOnForBuild_NetFx>
Expand Down Expand Up @@ -113,7 +115,7 @@ Args = string.Join(" ", CommandLineArgs);
<BeautyDir>"%(_BeautyPublishDir.FullPath)/."</BeautyDir>
</PropertyGroup>

<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />
<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyNoRuntimeInfo) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />
</Target>

<Target Name="NetBeautyOnPublish_Fx" AfterTargets="$(_BeautyDependsOnForPublish_NetFx)" Condition="$(DisableBeauty) != 'True' And '$(_BeautyOnBuild)' != 'True'">
Expand All @@ -127,17 +129,17 @@ Args = string.Join(" ", CommandLineArgs);
<BeautyDir2>"%(_BeautyPublishDir2.FullPath)/."</BeautyDir2>
</PropertyGroup>

<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />
<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyNoRuntimeInfo) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />

<Exec Condition="'$(BeautyDir2)' != '$(BeautyDir)'" Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir2) $(BeautyLibsDir) $(BeautyExcludes)" />
<Exec Condition="'$(BeautyDir2)' != '$(BeautyDir)'" Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyNoRuntimeInfo) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir2) $(BeautyLibsDir) $(BeautyExcludes)" />
</Target>

<Target Name="NetBeautyOnBuild" AfterTargets="$(_BeautyDependsOnForBuild_Core)" Condition="$(DisableBeauty) != 'True' And '$(_BeautyOnBuild)' == 'True'">
<PropertyGroup>
<BeautyDir>"$(TargetDir)/."</BeautyDir>
</PropertyGroup>

<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />
<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyNoRuntimeInfo) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />
</Target>

<Target Name="NetBeautyOnPublish" AfterTargets="$(_BeautyDependsOnForPublish_Core)" Condition="$(DisableBeauty) != 'True' And '$(_BeautyOnBuild)' != 'True'">
Expand All @@ -149,6 +151,6 @@ Args = string.Join(" ", CommandLineArgs);
<BeautyDir>"%(_BeautyPublishDir.FullPath)/."</BeautyDir>
</PropertyGroup>

<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />
<Exec Command="$(BeautyBin) $(BeautyGitCDN) $(BeautyGitTree) $(BeautyLogLevel) $(BeautySharedRuntimeMode) $(BeautyEnableDebugging) $(BeautyUsePatch) $(BeautyHiddens) $(BeautyNoRuntimeInfo) $(BeautyAppHostEntry) $(BeautyAppHostDir) $(BeautyDir) $(BeautyLibsDir) $(BeautyExcludes)" />
</Target>
</Project>
4 changes: 3 additions & 1 deletion NetBeautyTest/AvaloniaTest/AvaloniaTest/AvaloniaTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand All @@ -49,7 +51,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion NetBeautyTest/ChromelyTest/ChromelyTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand All @@ -77,7 +79,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion NetBeautyTest/NetFxTest/NetFxTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand Down Expand Up @@ -154,7 +156,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
<PackageReference Include="SixLabors.ImageSharp">
<Version>2.1.3</Version>
</PackageReference>
Expand Down
4 changes: 3 additions & 1 deletion NetBeautyTest/SharedRuntimeTest/WsClient/WsClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand All @@ -47,7 +49,7 @@

<ItemGroup>
<PackageReference Include="WatsonWebsocket" Version="2.3.2.5" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion NetBeautyTest/SharedRuntimeTest/WsServer/WsServer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand All @@ -47,7 +49,7 @@

<ItemGroup>
<PackageReference Include="WatsonWebsocket" Version="2.3.2.5" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion NetBeautyTest/WPFTest/WPFTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand All @@ -97,7 +99,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
</ItemGroup>

Expand Down
4 changes: 3 additions & 1 deletion NetBeautyTest/WebAppTest/WebAppTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand All @@ -42,7 +44,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
</ItemGroup>

</Project>
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Your `*.csproj` should be like:
<DisableBeauty>False</DisableBeauty>
<!-- set to False if you want to beauty on build -->
<BeautyOnPublishOnly>False</BeautyOnPublishOnly>
<!-- DO NOT TOUCH THIS OPTION -->
<BeautyNoRuntimeInfo>False</BeautyNoRuntimeInfo>
<!-- set to True if you want to allow 3rd debuggers(like dnSpy) debugs the app -->
<BeautyEnableDebugging>False</BeautyEnableDebugging>
<!-- the patch can reduce the file count -->
Expand All @@ -84,7 +86,7 @@ Your `*.csproj` should be like:
</PropertyGroup>

<ItemGroup>
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.3" />
<PackageReference Include="nulastudio.NetBeauty" Version="2.1.4.4" />
</ItemGroup>

</Project>
Expand All @@ -94,7 +96,7 @@ When you run `dotnet build` or `dotnet publish`, everything will be done automat
### Use the binary application if your project has already been published.
```
Usage:
nbeauty2 [--loglevel=(Error|Detail|Info)] [--srmode] [--enabledebug] [--usepatch] [--hiddens=hiddenFiles] [--roll-forward=<rollForward>] [--apphostentry=<appHostEntry>] [--apphostdir=<appHostDir>] <beautyDir> [<libsDir> [<excludes>]]
nbeauty2 [--loglevel=(Error|Detail|Info)] [--srmode] [--enabledebug] [--usepatch] [--hiddens=hiddenFiles] [--noruntimeinfo] [--roll-forward=<rollForward>] [--apphostentry=<appHostEntry>] [--apphostdir=<appHostDir>] <beautyDir> [<libsDir> [<excludes>]]
```

for example
Expand Down

0 comments on commit e9df68b

Please sign in to comment.