Skip to content

Commit 6470148

Browse files
authored
Add GitHub Actions workflow for MSBuild
1 parent a18db6c commit 6470148

File tree

1 file changed

+184
-0
lines changed

1 file changed

+184
-0
lines changed

.github/workflows/msbuild.yml

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
name: MSBuild
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
tags: ["v[0-9]**"]
7+
pull_request:
8+
branches: [ "master" ]
9+
workflow_dispatch:
10+
11+
env:
12+
# Path to the solution file relative to the root of the project.
13+
SOLUTION_FILE_PATH: .
14+
15+
# Configuration type to build.
16+
# You can convert this to a build matrix if you need coverage of multiple configuration types.
17+
# https://docs.github.com/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
18+
BUILD_CONFIGURATION: Release
19+
20+
jobs:
21+
build-utilities:
22+
name: Build submodules
23+
runs-on: windows-latest
24+
25+
permissions:
26+
contents: read
27+
28+
strategy:
29+
matrix:
30+
platform: [x86, x64, ARM64]
31+
32+
steps:
33+
- name: Checkout submodules
34+
uses: actions/checkout@v6
35+
with:
36+
submodules: recursive
37+
38+
- name: Add MSBuild to PATH
39+
uses: microsoft/setup-msbuild@v2
40+
41+
- name: Build AzureSpeechSDKShim
42+
if: matrix.platform != 'ARM64'
43+
working-directory: ${{github.workspace}}
44+
run: |
45+
nuget restore AzureSpeechSDKShim
46+
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.platform}} /p:OutDir=${{github.workspace}}\out\ AzureSpeechSDKShim
47+
48+
- name: Build TtsApplication (non Win32)
49+
if: matrix.platform != 'x86'
50+
working-directory: ${{github.workspace}}
51+
run: |
52+
nuget restore TtsApplication
53+
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.platform}} /p:OutDir=${{github.workspace}}\out\ TtsApplication\TtsApplication.sln
54+
55+
- name: Build TtsApplication (Win32)
56+
# We have to use Win32 instead of x86 for this project.
57+
if: matrix.platform == 'x86'
58+
working-directory: ${{github.workspace}}
59+
run: |
60+
nuget restore TtsApplication
61+
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=Win32 /p:OutDir=${{github.workspace}}\out\ TtsApplication\TtsApplication.sln
62+
63+
- name: Build Arm64XForwarder (ARM64 only)
64+
if: matrix.platform == 'ARM64'
65+
working-directory: ${{github.workspace}}
66+
run: |
67+
nuget restore Arm64XForwarder -SolutionDirectory .
68+
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=ARM64EC /p:OutDir=${{github.workspace}}\out\ Arm64XForwarder
69+
70+
- name: Build Installer (x86 only)
71+
if: matrix.platform == 'x86'
72+
working-directory: ${{github.workspace}}
73+
run: |
74+
nuget restore Installer -SolutionDirectory .
75+
msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.platform}} /p:OutDir=${{github.workspace}}\out\ Installer
76+
77+
- name: Upload artifact
78+
uses: actions/upload-artifact@v6
79+
with:
80+
name: utilities-${{matrix.platform}}
81+
path: out
82+
83+
build-main:
84+
name: Build NaturalVoiceSAPIAdapter
85+
runs-on: windows-latest
86+
87+
permissions:
88+
contents: read
89+
90+
strategy:
91+
matrix:
92+
platform: [x86, x64, ARM64]
93+
94+
steps:
95+
- name: Checkout
96+
uses: actions/checkout@v6
97+
98+
- name: Add MSBuild to PATH
99+
uses: microsoft/setup-msbuild@v2
100+
101+
- name: Restore NuGet packages
102+
working-directory: ${{github.workspace}}
103+
run: nuget restore NaturalVoiceSAPIAdapter -SolutionDirectory .
104+
105+
- name: Build
106+
working-directory: ${{github.workspace}}
107+
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{matrix.platform}} /p:OutDir=${{github.workspace}}\out\ . /t:NaturalVoiceSAPIAdapter
108+
109+
- name: Remove unnecessary DLLs
110+
# Remove the codec DLL because it can trigger the 'GStreamer DLL not found' error
111+
# However the codec DLL might not exist, so ignore the error code
112+
working-directory: ${{github.workspace}}\out
113+
shell: pwsh
114+
run: |
115+
$vspath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -property installationPath -latest
116+
$msvcpath = (Get-ChildItem "$vspath\VC\Tools\MSVC" | Sort-Object Name -Descending | Select-Object -First 1).FullName
117+
$dumpbinpath = "$msvcpath\bin\Hostx86\x86\dumpbin.exe"
118+
$dlls = & $dumpbinpath /dependents NaturalVoiceSAPIAdapter.dll Microsoft.CognitiveServices.*.dll `
119+
| ? { $_ -like " *.dll" } | % { $_.Trim() } | Select-Object -Unique
120+
$dlls += "NaturalVoiceSAPIAdapter.dll", "Microsoft.CognitiveServices.*.dll"
121+
Remove-Item * -Include *.dll -Exclude $dlls
122+
Remove-Item Microsoft.CognitiveServices.Speech.extension.codec.dll -ErrorAction Ignore
123+
exit 0 # This is necessary because "-ErrorAction Ignore" doesn't ensure a zero exit code
124+
125+
- name: Copy ucrtbase.dll (x64)
126+
if: matrix.platform == 'x64'
127+
working-directory: ${{github.workspace}}
128+
shell: pwsh
129+
run: Copy-Item -Path "$env:SystemRoot\System32\ucrtbase.dll" -Destination out\
130+
131+
- name: Copy ucrtbase.dll (x86)
132+
if: matrix.platform == 'x86'
133+
working-directory: ${{github.workspace}}
134+
shell: pwsh
135+
run: Copy-Item -Path "$env:SystemRoot\SysWOW64\ucrtbase.dll" -Destination out\
136+
137+
- name: Upload artifact
138+
uses: actions/upload-artifact@v6
139+
with:
140+
name: main-${{matrix.platform}}
141+
path: out
142+
143+
release:
144+
runs-on: ubuntu-latest
145+
needs: [build-utilities, build-main]
146+
if: github.ref_type == 'tag'
147+
148+
permissions:
149+
contents: write
150+
151+
steps:
152+
- uses: actions/checkout@v6
153+
154+
- name: Download all artifacts
155+
uses: actions/download-artifact@v7
156+
with:
157+
path: ${{github.workspace}}/artifacts
158+
159+
- name: Create ZIP files
160+
working-directory: ${{github.workspace}}/artifacts
161+
run: |
162+
ver="${{github.ref_name}}"
163+
ver="${ver//\//_}"
164+
mkdir x86
165+
mv utilities-x86/* x86/
166+
mv main-x86/* x86/
167+
mv x86/Installer.exe ./
168+
mkdir x64
169+
mv utilities-x64/* x64/
170+
mv main-x64/* x64/
171+
zip -r NaturalVoiceSAPIAdapter_${ver}_x86_x64.zip x86 x64 Installer.exe -i "*.exe" "*.dll"
172+
mkdir ARM64
173+
mv utilities-ARM64/* ARM64/
174+
mv main-ARM64/* ARM64/
175+
zip -r NaturalVoiceSAPIAdapter_${ver}_ARM64.zip x86 x64 ARM64 Installer.exe -i "*.exe" "*.dll"
176+
zip -r debug_symbols.zip x86 x64 ARM64 -i "*.pdb"
177+
178+
- name: Create release
179+
uses: softprops/action-gh-release@v2
180+
with:
181+
body_path: ${{github.workspace}}/release_notes.md
182+
files: |
183+
${{github.workspace}}/artifacts/*.zip
184+

0 commit comments

Comments
 (0)