-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABChapterize.csproj
More file actions
173 lines (163 loc) · 11.1 KB
/
Copy pathABChapterize.csproj
File metadata and controls
173 lines (163 loc) · 11.1 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>ABChapterize</RootNamespace>
<AssemblyName>abchapterize</AssemblyName>
<Version>0.10.1</Version>
<!-- Keep the informational version (shown by the version option and in the usage
note) a plain version number instead of appending "+<git commit hash>". -->
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<InvariantGlobalization>true</InvariantGlobalization>
<!-- Generate (but do not ship) the XML documentation file: the point is not the file,
it is that the compiler then validates every <see cref="..."/> in the doc comments
and warns about <param> tags that no longer match a signature. Doc comments are the
primary developer-facing documentation of this codebase, so letting them rot
silently is not an option; PublishDocumentationFile keeps the .xml out of the
release folders, where nothing would read it. -->
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PublishDocumentationFile>false</PublishDocumentationFile>
<!-- win-x64 by default; publish for Linux with: dotnet publish -c Release -r linux-x64 -->
<RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == ''">win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<!-- Single-file publish for the managed code. The native Whisper libraries must stay
in the "runtimes" folder next to the exe: Whisper.net probes that folder structure
at run time to pick the best backend (CUDA/Vulkan/CPU variants even share file
names, so they cannot be embedded into the bundle). -->
<!-- Publish per platform into the deployed locations; the win-x64 one also holds the
"models" folder. -->
<PublishDir>bin\publish\$(RuntimeIdentifier)\</PublishDir>
<PublishSingleFile>true</PublishSingleFile>
<IncludeNativeLibrariesForSelfExtract>false</IncludeNativeLibrariesForSelfExtract>
<EnableCompressionInSingleFile>true</EnableCompressionInSingleFile>
</PropertyGroup>
<!-- The unit test project under tests\ and the throwaway vadprobe diagnostic tool under
tools\ each have their own csproj; keep their sources out of the default compile globs
of this project. -->
<ItemGroup>
<Compile Remove="tests/**" />
<Compile Remove="tools/**" />
</ItemGroup>
<!-- Auto-incrementing build number, baked in as assembly metadata read by CliOptions and
surfaced only by the version-info command line option (never in the plain
Version-based banner/usage text). The counter lives in BuildNumber.txt, tracked in git
so it keeps counting up across clones instead of resetting. Only an actual publish of
win-x64 (the default RuntimeIdentifier, see above) bumps it - _IsPublishing is set by
"dotnet publish" and nothing else, which keeps IDE design-time/background builds (which
also evaluate with the default RID) from silently racing the counter upward, an effect
actually observed with VS Code's C# extension. Plain builds and linux-x64 publishes
just read the current value without writing it back, so publishing both platforms for
the same release embeds the same build number in each: publish win-x64 first, then
linux-x64 picks up the same, freshly bumped number. -->
<PropertyGroup>
<BuildNumberFile>$(MSBuildProjectDirectory)\BuildNumber.txt</BuildNumberFile>
</PropertyGroup>
<!-- Hooked onto GetAssemblyAttributes specifically, not the outer GenerateAssemblyInfo: the
SDK resolves GenerateAssemblyInfo's own DependsOnTargets chain - which is what actually
populates and hashes @(AssemblyAttribute) and writes the generated file - before a
BeforeTargets="GenerateAssemblyInfo" hook gets to run, so items added there arrive too
late to be picked up. GetAssemblyAttributes is the actual target that builds up
@(AssemblyAttribute) (by appending to it, so our items added here survive), and running
before it lands our items in time for the hash/file-write that follows.
Guarded on TargetFramework being set so this only fires for an actual compile, not the
outer dispatch pass; the increment itself is further guarded on _IsPublishing (see the
comment above). -->
<Target Name="IncrementBuildNumber" BeforeTargets="GetAssemblyAttributes" Condition="'$(TargetFramework)' != ''">
<ReadLinesFromFile File="$(BuildNumberFile)" Condition="Exists('$(BuildNumberFile)')">
<Output TaskParameter="Lines" ItemName="_PreviousBuildNumberLine" />
</ReadLinesFromFile>
<PropertyGroup>
<_PreviousBuildNumber Condition="'@(_PreviousBuildNumberLine)' != ''">@(_PreviousBuildNumberLine)</_PreviousBuildNumber>
<_PreviousBuildNumber Condition="'$(_PreviousBuildNumber)' == ''">0</_PreviousBuildNumber>
<_BumpBuildNumber>false</_BumpBuildNumber>
<_BumpBuildNumber Condition="'$(_IsPublishing)' == 'true' and '$(RuntimeIdentifier)' == 'win-x64'">true</_BumpBuildNumber>
<BuildNumber Condition="'$(_BumpBuildNumber)' == 'true'">$([MSBuild]::Add($(_PreviousBuildNumber), 1))</BuildNumber>
<BuildNumber Condition="'$(_BumpBuildNumber)' != 'true'">$(_PreviousBuildNumber)</BuildNumber>
<BuildTimestamp>$([System.DateTime]::UtcNow.ToString('yyyy-MM-dd HH:mm:ss')) UTC</BuildTimestamp>
</PropertyGroup>
<WriteLinesToFile File="$(BuildNumberFile)" Lines="$(BuildNumber)" Overwrite="true"
Condition="'$(_BumpBuildNumber)' == 'true'" />
<ItemGroup>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>BuildNumber</_Parameter1>
<_Parameter2>$(BuildNumber)</_Parameter2>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
<_Parameter1>BuildTimestamp</_Parameter1>
<_Parameter2>$(BuildTimestamp)</_Parameter2>
</AssemblyAttribute>
</ItemGroup>
</Target>
<ItemGroup>
<PackageReference Include="Whisper.net" Version="1.9.1" />
<PackageReference Include="Whisper.net.Runtime" Version="1.9.1" />
<PackageReference Include="Whisper.net.Runtime.Cuda" Version="1.9.1" />
<PackageReference Include="Whisper.net.Runtime.Vulkan" Version="1.9.1" />
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.27.1" />
</ItemGroup>
<!-- Silero VAD model, bundled (MIT-licensed, see THIRD-PARTY-NOTICES.md) rather than
downloaded: small enough (~2.2 MB) to embed directly into the assembly, avoiding a
first-run download step entirely. Loaded from assembly resources by SileroWorker. -->
<ItemGroup>
<EmbeddedResource Include="assets\silero_vad.onnx" LogicalName="ABChapterize.silero_vad.onnx" />
</ItemGroup>
<!-- Ship the docs, third-party notices/license texts, and readme alongside the executable:
LICENSE plus the licenses/ glob satisfy the "include the copyright notice" redistribution
condition of ABChapterize's own MIT license and of every bundled MIT component, and
doc/+README.md+CHANGELOG.md keep the manual and the release history available in every
release.
Globs so new files dropped into these folders are picked up automatically. -->
<ItemGroup>
<None Include="LICENSE" CopyToPublishDirectory="PreserveNewest" />
<None Include="THIRD-PARTY-NOTICES.md" CopyToPublishDirectory="PreserveNewest" />
<None Include="README.md" CopyToPublishDirectory="PreserveNewest" />
<None Include="CHANGELOG.md" CopyToPublishDirectory="PreserveNewest" />
<None Include="doc\**\*" CopyToPublishDirectory="PreserveNewest" Link="doc\%(RecursiveDir)%(Filename)%(Extension)" />
<None Include="licenses\**\*" CopyToPublishDirectory="PreserveNewest" Link="licenses\%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<!-- Whisper.net copies native libraries for all platforms; only the ones matching the
published runtime identifier are needed, so prune the foreign ones. -->
<Target Name="PruneForeignRuntimes" AfterTargets="Publish">
<ItemGroup>
<_ForeignRuntimeDir Include="$(PublishDir)runtimes\linux-arm" />
<_ForeignRuntimeDir Include="$(PublishDir)runtimes\linux-arm64" />
<_ForeignRuntimeDir Include="$(PublishDir)runtimes\macos-arm64" />
<_ForeignRuntimeDir Include="$(PublishDir)runtimes\macos-x64" />
<_ForeignRuntimeDir Include="$(PublishDir)runtimes\win-arm64" />
<_ForeignRuntimeDir Include="$(PublishDir)runtimes\win-x86" />
<_ForeignRuntimeDir Condition="'$(RuntimeIdentifier)' == 'win-x64'"
Include="$(PublishDir)runtimes\linux-x64;$(PublishDir)runtimes\cuda\linux-x64;$(PublishDir)runtimes\vulkan\linux-x64" />
<_ForeignRuntimeDir Condition="'$(RuntimeIdentifier)' == 'linux-x64'"
Include="$(PublishDir)runtimes\win-x64;$(PublishDir)runtimes\cuda\win-x64;$(PublishDir)runtimes\vulkan\win-x64" />
</ItemGroup>
<RemoveDir Directories="@(_ForeignRuntimeDir)" />
<ItemGroup>
<_ForeignPublishFile Include="$(PublishDir)ggml-metal.metal;$(PublishDir)abchapterize.pdb" />
<!-- Unlike Whisper.net's runtimes\<rid>\ layout above, Microsoft.ML.OnnxRuntime copies
its native libraries flat into the publish root for every platform it supports,
not just the target RuntimeIdentifier (confirmed by publishing both targets: the
linux-x64 output also carried onnxruntime.dll/onnxruntime_providers_shared.dll).
The *.lib import libraries are Windows build-time-only artifacts, never needed at
run time, so they are always pruned regardless of target. -->
<_ForeignPublishFile Include="$(PublishDir)onnxruntime.lib;$(PublishDir)onnxruntime_providers_shared.lib" />
<_ForeignPublishFile Condition="'$(RuntimeIdentifier)' == 'win-x64'"
Include="$(PublishDir)libonnxruntime.so;$(PublishDir)libonnxruntime_providers_shared.so" />
<_ForeignPublishFile Condition="'$(RuntimeIdentifier)' == 'linux-x64'"
Include="$(PublishDir)onnxruntime.dll;$(PublishDir)onnxruntime_providers_shared.dll" />
</ItemGroup>
<Delete Files="@(_ForeignPublishFile)" />
<!-- Move the correct-platform OnnxRuntime natives out of the publish root and into
runtimes\<rid>\ alongside the Whisper natives, instead of leaving them loose next to
the exe. SileroWorker registers a DllImportResolver that loads "onnxruntime" from
this exact location, so the two must be kept in sync. -->
<ItemGroup>
<_OnnxRuntimeNativeFile Condition="'$(RuntimeIdentifier)' == 'win-x64'"
Include="$(PublishDir)onnxruntime.dll;$(PublishDir)onnxruntime_providers_shared.dll" />
<_OnnxRuntimeNativeFile Condition="'$(RuntimeIdentifier)' == 'linux-x64'"
Include="$(PublishDir)libonnxruntime.so;$(PublishDir)libonnxruntime_providers_shared.so" />
</ItemGroup>
<Move SourceFiles="@(_OnnxRuntimeNativeFile)" DestinationFolder="$(PublishDir)runtimes\$(RuntimeIdentifier)\" />
</Target>
</Project>