-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathHostsFileEditor.WinForm.csproj
More file actions
157 lines (153 loc) · 9.88 KB
/
Copy pathHostsFileEditor.WinForm.csproj
File metadata and controls
157 lines (153 loc) · 9.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<OutputType>WinExe</OutputType>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<!-- High-DPI: opt into PerMonitorV2 so the UI stays crisp on 4K/scaled displays and
re-scales correctly across monitors with different scaling. Consumed by the
source-generated ApplicationConfiguration.Initialize() call in Program.cs.
ApplicationVisualStyles/UseCompatibleTextRendering match the previous manual
EnableVisualStyles() / SetCompatibleTextRenderingDefault(false) startup calls. -->
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
<ApplicationVisualStyles>true</ApplicationVisualStyles>
<ApplicationUseCompatibleTextRendering>false</ApplicationUseCompatibleTextRendering>
<StartupObject>HostsFileEditor.Program</StartupObject>
<ApplicationIcon>HostsFileEditor.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AssemblyTitle>Hosts File Editor</AssemblyTitle>
<AssemblyName>HostsFileEditor</AssemblyName>
<ProductName>Hosts File Editor</ProductName>
<Product>Hosts File Editor</Product>
<!-- Single version source for this app: drives AssemblyVersion, FileVersion, the exe's
ProductVersion resource, and (stamped in Directory.Build.targets) the MSIX manifest
Identity/@Version. ProductVersion is not an SDK-recognized property and was ignored. -->
<Version>1.5.2.0</Version>
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
<!-- Native AOT isn't working yet with WinForms, specifically Binding is explicitly not supported throwing NotSupportedException -->
<!--<PublishAot>true</PublishAot>-->
<PublishSingleFile>true</PublishSingleFile>
<!-- Compress the bundled runtime/assemblies inside the single-file exe. Cuts the on-disk
exe size substantially at a small one-time startup cost (content is decompressed on
first run). -->
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
<!-- Self-contained for Store compatibility: bundle the .NET runtime so the MSIX needs no
external runtime framework package (there is no reliable .NET runtime MSIX dependency). -->
<SelfContained>true</SelfContained>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">win-x64</RuntimeIdentifier>
<StripSymbols>true</StripSymbols>
<InvariantGlobalization>true</InvariantGlobalization>
<!-- Need to suppress trim warnings since WinForms with Native AOT isn't officially supported -->
<NoWarn>NU1701;IL2026;IL3000;IL3050;IL3053</NoWarn>
<_SuppressWinFormsTrimError>true</_SuppressWinFormsTrimError>
<!-- Reflection based JSON serialization is required for WinForms designer -->
<JsonSerializerIsReflectionEnabledByDefault Condition="'$(Configuration)' == 'Debug'">true</JsonSerializerIsReflectionEnabledByDefault>
<CustomResourceTypesSupport>true</CustomResourceTypesSupport>
<PackagingFlavor>classic</PackagingFlavor>
<OutputPackagingDir>$(MSBuildProjectDirectory)\..\artifacts\classic\</OutputPackagingDir>
<CreatePublishZip>true</CreatePublishZip>
<!-- Generate a resources.pri during packaging so the shell resolves the qualified logo
assets (scale-*, targetsize-*, altform-unplated) and the taskbar/Alt+Tab render the
icon unplated instead of on the accent-color plate. See Directory.Build.targets. -->
<GenerateResourcesPri>true</GenerateResourcesPri>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="7ZipCLI" Version="9.20.0" GeneratePathProperty="true" />
<PackageReference Include="Equin.ApplicationFramework.BindingListView" Version="1.4.5222.35545" />
<!-- Taskbar JumpList support (issue #10). -->
<PackageReference Include="WindowsAPICodePackCore" Version="8.0.15.2" />
<PackageReference Include="WindowsAPICodePackShell" Version="8.0.15.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HostsFileEditor.Core\HostsFileEditor.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="AppxManifest.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Assets\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="HostsFileEditor.ico" />
</ItemGroup>
<!-- Build the elevation helper and copy its output next to the app exe so the app can
launch it on demand (see PrivilegedFileOperations.UseElevationHelper). -->
<Target Name="CopyElevateHelper" AfterTargets="Build">
<MSBuild Projects="$(MSBuildThisFileDirectory)..\HostsFileEditor.Elevate\HostsFileEditor.Elevate.csproj"
Targets="Build"
Properties="Configuration=$(Configuration);Platform=AnyCPU"
RemoveProperties="RuntimeIdentifier">
<Output TaskParameter="TargetOutputs" ItemName="_ElevateHelperPrimaryOutput" />
</MSBuild>
<PropertyGroup>
<_ElevateHelperDir>%(_ElevateHelperPrimaryOutput.RootDir)%(_ElevateHelperPrimaryOutput.Directory)</_ElevateHelperDir>
</PropertyGroup>
<ItemGroup>
<_ElevateHelperFiles Include="$(_ElevateHelperDir)*.*" />
</ItemGroup>
<Copy SourceFiles="@(_ElevateHelperFiles)" DestinationFolder="$(OutDir)Elevate" SkipUnchangedFiles="true" />
<Message Importance="high" Text="Copied elevation helper to $(OutDir)Elevate" />
</Target>
<!-- Publish the elevation helper (AOT, self-contained native exe) for this app's RID and
bundle it under Elevate\ in the publish output so the MSIX package includes it. -->
<Target Name="PublishElevateHelper" AfterTargets="Publish" BeforeTargets="SignAndPackage">
<PropertyGroup>
<_ElevateRid Condition="'$(_ElevateRid)' == ''">$(RuntimeIdentifier)</_ElevateRid>
<_ElevateRid Condition="'$(_ElevateRid)' == ''">win-x64</_ElevateRid>
<_ElevateStaging>$(MSBuildProjectDirectory)\obj\elevate\$(Configuration)\$(_ElevateRid)\</_ElevateStaging>
</PropertyGroup>
<MSBuild Projects="$(MSBuildThisFileDirectory)..\HostsFileEditor.Elevate\HostsFileEditor.Elevate.csproj"
Targets="Publish"
Properties="Configuration=$(Configuration);RuntimeIdentifier=$(_ElevateRid);PublishDir=$(_ElevateStaging)" />
<Copy SourceFiles="$(_ElevateStaging)HostsFileEditor.Elevate.exe" DestinationFolder="$(PublishDir)Elevate" SkipUnchangedFiles="true" />
<Message Importance="high" Text="Bundled elevation helper into $(PublishDir)Elevate" />
</Target>
<!-- Strip the WPF native libraries the .NET Windows Desktop runtime bundles. This is a WinForms app
(UseWindowsForms, never UseWPF) and never initializes WPF, so wpfgfx / PresentationNative / PenImc
/ D3DCompiler and their vcruntime dependency are ~9 MB of dead weight — verified the app launches
and runs with all of them removed. Single-file leaves native libs loose next to the exe
(IncludeNativeLibrariesForSelfExtract isn't set), so delete them from the publish output before
the ZIP/MSIX is built. Same approach the modern app uses for its unused Windows App SDK libs. -->
<Target Name="_StripUnusedWpfNativeLibs" AfterTargets="Publish" BeforeTargets="SignAndPackage">
<ItemGroup>
<_UnusedWpfLib Include="$(PublishDir)wpfgfx_cor3.dll" />
<_UnusedWpfLib Include="$(PublishDir)PresentationNative_cor3.dll" />
<_UnusedWpfLib Include="$(PublishDir)PenImc_cor3.dll" />
<_UnusedWpfLib Include="$(PublishDir)D3DCompiler_47_cor3.dll" />
<_UnusedWpfLib Include="$(PublishDir)vcruntime140_cor3.dll" />
</ItemGroup>
<!-- Warn (don't fail) if one is missing: a future runtime bump that renames/relocates one would
otherwise silently stop stripping and the ~9 MB creeps back with no signal. -->
<Warning Condition="!Exists('%(_UnusedWpfLib.Identity)')"
Text="Expected unused WPF native lib not found (runtime layout may have changed): %(_UnusedWpfLib.Identity)" />
<Delete Files="@(_UnusedWpfLib)" />
<Message Importance="high" Text="Stripped unused WPF native libraries from the classic publish output." />
</Target>
<!-- Publish the console launcher (AOT, self-contained single native exe) for this app's RID and drop
hfe.exe into the publish root so the ZIP / MSIX package ships it (and the MSIX alias resolves). -->
<Target Name="PublishCliLauncher" AfterTargets="Publish" BeforeTargets="SignAndPackage">
<PropertyGroup>
<_CliRid Condition="'$(_CliRid)' == ''">$(RuntimeIdentifier)</_CliRid>
<_CliRid Condition="'$(_CliRid)' == ''">win-x64</_CliRid>
<_CliStaging>$(MSBuildProjectDirectory)\obj\cli\$(Configuration)\$(_CliRid)\</_CliStaging>
</PropertyGroup>
<MSBuild Projects="$(MSBuildThisFileDirectory)..\HostsFileEditor.Cli\HostsFileEditor.Cli.csproj"
Targets="Publish"
Properties="Configuration=$(Configuration);RuntimeIdentifier=$(_CliRid);PublishDir=$(_CliStaging)" />
<Copy SourceFiles="$(_CliStaging)hfe.exe" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="true" />
<Message Importance="high" Text="Bundled hfe.exe launcher into $(PublishDir)" />
</Target>
<Target Name="CreateBuildDirectories" BeforeTargets="BeforeBuild">
<MakeDir Directories="$(MSBuildProjectDirectory)\..\artifacts" Condition="!Exists('$(MSBuildProjectDirectory)\..\artifacts')" />
</Target>
<Target Name="CleanCustomDirectories" AfterTargets="Clean">
<ItemGroup>
<BinFiles Include="$(MSBuildProjectDirectory)\..\artifacts\*.*" />
</ItemGroup>
<Delete Files="@(BinFiles)" />
<RemoveDir Directories="$(MSBuildProjectDirectory)\..\artifacts" Condition="Exists('$(MSBuildProjectDirectory)\..\artifacts')" />
<Message Text="Cleaned all build artifacts directory" Importance="high" />
</Target>
</Project>