Skip to content

Commit 5a18e52

Browse files
authored
Merge pull request AzureCosmosDB#11 from AzureCosmosDB/develop
Build config changes to support platform builds
2 parents e72d8a2 + 2e55d00 commit 5a18e52

File tree

5 files changed

+323
-5
lines changed

5 files changed

+323
-5
lines changed
+284
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
name: Build desktop binaries
2+
on:
3+
push:
4+
branches: [ "main" ]
5+
pull_request:
6+
branches: [ "main" ]
7+
workflow_dispatch:
8+
jobs:
9+
build-package:
10+
name: Build self-contained executables
11+
runs-on: ubuntu-latest
12+
container: mcr.microsoft.com/dotnet/sdk:6.0
13+
steps:
14+
- name: Check .NET version
15+
run: dotnet --version
16+
- name: Checkout source code
17+
uses: actions/checkout@v3
18+
- name: Build Windows x64 package
19+
run: |
20+
dotnet publish \
21+
Core/Microsoft.DataTransfer.Core/Microsoft.DataTransfer.Core.csproj \
22+
--configuration release \
23+
--output win \
24+
--self-contained true \
25+
--runtime win-x64 \
26+
-p:PublishSingleFile=true \
27+
-p:DebugType=embedded \
28+
-p:EnableCompressionInSingleFile=true \
29+
-p:PublishReadyToRun=false \
30+
-p:PublishTrimmed=false \
31+
-p:Version=0.0.${{ github.run_number }}
32+
- name: Build Windows x64 Cosmos Extension
33+
run: |
34+
dotnet publish \
35+
Extensions/Cosmos/Microsoft.DataTransfer.CosmosExtension/Microsoft.DataTransfer.CosmosExtension.csproj \
36+
--configuration release \
37+
--output win/Extensions \
38+
--self-contained false \
39+
--runtime win-x64 \
40+
-p:PublishSingleFile=false \
41+
-p:DebugType=embedded \
42+
-p:EnableCompressionInSingleFile=true \
43+
-p:PublishReadyToRun=false \
44+
-p:PublishTrimmed=false \
45+
-p:Version=0.0.${{ github.run_number }}
46+
- name: Build Windows x64 JSON Extension
47+
run: |
48+
dotnet publish \
49+
Extensions/Json/Microsoft.DataTransfer.JsonExtension/Microsoft.DataTransfer.JsonExtension.csproj \
50+
--configuration release \
51+
--output win/Extensions \
52+
--self-contained false \
53+
--runtime win-x64 \
54+
-p:PublishSingleFile=false \
55+
-p:DebugType=embedded \
56+
-p:EnableCompressionInSingleFile=true \
57+
-p:PublishReadyToRun=false \
58+
-p:PublishTrimmed=false \
59+
-p:Version=0.0.${{ github.run_number }}
60+
- name: Build Windows x64 Azure Table Extension
61+
run: |
62+
dotnet publish \
63+
Extensions/AzureTableAPI/Microsoft.DataTransfer.AzureTableAPIExtension/Microsoft.DataTransfer.AzureTableAPIExtension.csproj \
64+
--configuration release \
65+
--output win/Extensions \
66+
--self-contained false \
67+
--runtime win-x64 \
68+
-p:PublishSingleFile=false \
69+
-p:DebugType=embedded \
70+
-p:EnableCompressionInSingleFile=true \
71+
-p:PublishReadyToRun=false \
72+
-p:PublishTrimmed=false \
73+
-p:Version=0.0.${{ github.run_number }}
74+
- name: Build Windows x64 Mongo Extension
75+
run: |
76+
dotnet publish \
77+
Extensions/Mongo/Microsoft.DataTransfer.MongoExtension/Microsoft.DataTransfer.MongoExtension.csproj \
78+
--configuration release \
79+
--output win/Extensions \
80+
--self-contained false \
81+
--runtime win-x64 \
82+
-p:PublishSingleFile=false \
83+
-p:DebugType=embedded \
84+
-p:EnableCompressionInSingleFile=true \
85+
-p:PublishReadyToRun=false \
86+
-p:PublishTrimmed=false \
87+
-p:Version=0.0.${{ github.run_number }}
88+
- name: Build Windows x64 SQL Server Extension
89+
run: |
90+
dotnet publish \
91+
Extensions/SqlServer/Microsoft.DataTransfer.SqlServerExtension/Microsoft.DataTransfer.SqlServerExtension.csproj \
92+
--configuration release \
93+
--output win/Extensions \
94+
--self-contained false \
95+
--runtime win-x64 \
96+
-p:PublishSingleFile=false \
97+
-p:DebugType=embedded \
98+
-p:EnableCompressionInSingleFile=true \
99+
-p:PublishReadyToRun=false \
100+
-p:PublishTrimmed=false \
101+
-p:Version=0.0.${{ github.run_number }}
102+
- name: Upload Windows package
103+
uses: actions/upload-artifact@v3
104+
with:
105+
name: windows-package
106+
path: win/
107+
- name: Build macOS x64 package
108+
run: |
109+
dotnet publish \
110+
Core/Microsoft.DataTransfer.Core/Microsoft.DataTransfer.Core.csproj \
111+
--configuration release \
112+
--output mac \
113+
--self-contained true \
114+
--runtime osx-x64 \
115+
-p:PublishSingleFile=true \
116+
-p:DebugType=embedded \
117+
-p:EnableCompressionInSingleFile=true \
118+
-p:PublishReadyToRun=false \
119+
-p:PublishTrimmed=false \
120+
-p:Version=0.0.${{ github.run_number }}
121+
- name: Build macOS x64 Cosmos Extension
122+
run: |
123+
dotnet publish \
124+
Extensions/Cosmos/Microsoft.DataTransfer.CosmosExtension/Microsoft.DataTransfer.CosmosExtension.csproj \
125+
--configuration release \
126+
--output mac/Extensions \
127+
--self-contained false \
128+
--runtime osx-x64 \
129+
-p:PublishSingleFile=false \
130+
-p:DebugType=embedded \
131+
-p:EnableCompressionInSingleFile=true \
132+
-p:PublishReadyToRun=false \
133+
-p:PublishTrimmed=false \
134+
-p:Version=0.0.${{ github.run_number }}
135+
- name: Build macOS x64 JSON Extension
136+
run: |
137+
dotnet publish \
138+
Extensions/Json/Microsoft.DataTransfer.JsonExtension/Microsoft.DataTransfer.JsonExtension.csproj \
139+
--configuration release \
140+
--output mac/Extensions \
141+
--self-contained false \
142+
--runtime osx-x64 \
143+
-p:PublishSingleFile=false \
144+
-p:DebugType=embedded \
145+
-p:EnableCompressionInSingleFile=true \
146+
-p:PublishReadyToRun=false \
147+
-p:PublishTrimmed=false \
148+
-p:Version=0.0.${{ github.run_number }}
149+
- name: Build macOS x64 Azure Table Extension
150+
run: |
151+
dotnet publish \
152+
Extensions/AzureTableAPI/Microsoft.DataTransfer.AzureTableAPIExtension/Microsoft.DataTransfer.AzureTableAPIExtension.csproj \
153+
--configuration release \
154+
--output mac/Extensions \
155+
--self-contained false \
156+
--runtime osx-x64 \
157+
-p:PublishSingleFile=false \
158+
-p:DebugType=embedded \
159+
-p:EnableCompressionInSingleFile=true \
160+
-p:PublishReadyToRun=false \
161+
-p:PublishTrimmed=false \
162+
-p:Version=0.0.${{ github.run_number }}
163+
- name: Build macOS x64 Mongo Extension
164+
run: |
165+
dotnet publish \
166+
Extensions/Mongo/Microsoft.DataTransfer.MongoExtension/Microsoft.DataTransfer.MongoExtension.csproj \
167+
--configuration release \
168+
--output mac/Extensions \
169+
--self-contained false \
170+
--runtime osx-x64 \
171+
-p:PublishSingleFile=false \
172+
-p:DebugType=embedded \
173+
-p:EnableCompressionInSingleFile=true \
174+
-p:PublishReadyToRun=false \
175+
-p:PublishTrimmed=false \
176+
-p:Version=0.0.${{ github.run_number }}
177+
- name: Build macOS x64 SQL Server Extension
178+
run: |
179+
dotnet publish \
180+
Extensions/SqlServer/Microsoft.DataTransfer.SqlServerExtension/Microsoft.DataTransfer.SqlServerExtension.csproj \
181+
--configuration release \
182+
--output mac/Extensions \
183+
--self-contained false \
184+
--runtime osx-x64 \
185+
-p:PublishSingleFile=false \
186+
-p:DebugType=embedded \
187+
-p:EnableCompressionInSingleFile=true \
188+
-p:PublishReadyToRun=false \
189+
-p:PublishTrimmed=false \
190+
-p:Version=0.0.${{ github.run_number }}
191+
- name: Upload macOS package
192+
uses: actions/upload-artifact@v3
193+
with:
194+
name: mac-package
195+
path: mac/
196+
- name: Build Linux x64 package
197+
run: |
198+
dotnet publish \
199+
Core/Microsoft.DataTransfer.Core/Microsoft.DataTransfer.Core.csproj \
200+
--configuration release \
201+
--output linux \
202+
--self-contained true \
203+
--runtime linux-x64 \
204+
-p:PublishSingleFile=true \
205+
-p:DebugType=embedded \
206+
-p:EnableCompressionInSingleFile=true \
207+
-p:PublishReadyToRun=false \
208+
-p:PublishTrimmed=false \
209+
-p:Version=0.0.${{ github.run_number }}
210+
- name: Build Linux x64 Cosmos Extension
211+
run: |
212+
dotnet publish \
213+
Extensions/Cosmos/Microsoft.DataTransfer.CosmosExtension/Microsoft.DataTransfer.CosmosExtension.csproj \
214+
--configuration release \
215+
--output linux/Extensions \
216+
--self-contained false \
217+
--runtime linux-x64 \
218+
-p:PublishSingleFile=false \
219+
-p:DebugType=embedded \
220+
-p:EnableCompressionInSingleFile=true \
221+
-p:PublishReadyToRun=false \
222+
-p:PublishTrimmed=false \
223+
-p:Version=0.0.${{ github.run_number }}
224+
- name: Build Linux x64 JSON Extension
225+
run: |
226+
dotnet publish \
227+
Extensions/Json/Microsoft.DataTransfer.JsonExtension/Microsoft.DataTransfer.JsonExtension.csproj \
228+
--configuration release \
229+
--output linux/Extensions \
230+
--self-contained false \
231+
--runtime linux-x64 \
232+
-p:PublishSingleFile=false \
233+
-p:DebugType=embedded \
234+
-p:EnableCompressionInSingleFile=true \
235+
-p:PublishReadyToRun=false \
236+
-p:PublishTrimmed=false \
237+
-p:Version=0.0.${{ github.run_number }}
238+
- name: Build Linux x64 Azure Table Extension
239+
run: |
240+
dotnet publish \
241+
Extensions/AzureTableAPI/Microsoft.DataTransfer.AzureTableAPIExtension/Microsoft.DataTransfer.AzureTableAPIExtension.csproj \
242+
--configuration release \
243+
--output linux/Extensions \
244+
--self-contained false \
245+
--runtime linux-x64 \
246+
-p:PublishSingleFile=false \
247+
-p:DebugType=embedded \
248+
-p:EnableCompressionInSingleFile=true \
249+
-p:PublishReadyToRun=false \
250+
-p:PublishTrimmed=false \
251+
-p:Version=0.0.${{ github.run_number }}
252+
- name: Build Linux x64 Mongo Extension
253+
run: |
254+
dotnet publish \
255+
Extensions/Mongo/Microsoft.DataTransfer.MongoExtension/Microsoft.DataTransfer.MongoExtension.csproj \
256+
--configuration release \
257+
--output linux/Extensions \
258+
--self-contained false \
259+
--runtime linux-x64 \
260+
-p:PublishSingleFile=false \
261+
-p:DebugType=embedded \
262+
-p:EnableCompressionInSingleFile=true \
263+
-p:PublishReadyToRun=false \
264+
-p:PublishTrimmed=false \
265+
-p:Version=0.0.${{ github.run_number }}
266+
- name: Build Linux x64 SQL Server Extension
267+
run: |
268+
dotnet publish \
269+
Extensions/SqlServer/Microsoft.DataTransfer.SqlServerExtension/Microsoft.DataTransfer.SqlServerExtension.csproj \
270+
--configuration release \
271+
--output linux/Extensions \
272+
--self-contained false \
273+
--runtime linux-x64 \
274+
-p:PublishSingleFile=false \
275+
-p:DebugType=embedded \
276+
-p:EnableCompressionInSingleFile=true \
277+
-p:PublishReadyToRun=false \
278+
-p:PublishTrimmed=false \
279+
-p:Version=0.0.${{ github.run_number }}
280+
- name: Upload Linux package
281+
uses: actions/upload-artifact@v3
282+
with:
283+
name: linux-package
284+
path: linux/

Core/Microsoft.DataTransfer.Core/Microsoft.DataTransfer.Core.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<ImplicitUsings>enable</ImplicitUsings>
77
<Nullable>enable</Nullable>
88
<UserSecretsId>c7432a3a-5dc1-4e86-a1f0-b2363bf5c77f</UserSecretsId>
9+
<PackageId>datatransfer-core</PackageId>
10+
<AssemblyName>cosmos-migrate</AssemblyName>
911
</PropertyGroup>
1012

1113
<ItemGroup>

Core/Microsoft.DataTransfer.Core/Program.cs

+35-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.ComponentModel.Composition.Hosting;
2+
using System.Reflection;
23
using Microsoft.DataTransfer.Interfaces;
34
using Microsoft.Extensions.Configuration;
45
using Microsoft.Extensions.DependencyInjection;
@@ -27,11 +28,9 @@ public static async Task Main(string[] args)
2728
var hostingProcess = host.RunAsync();
2829

2930
var catalog = new AggregateCatalog();
30-
if (!Directory.Exists("Extensions"))
31-
{
32-
Directory.CreateDirectory("Extensions");
33-
}
34-
catalog.Catalogs.Add(new DirectoryCatalog("Extensions", "*Extension.dll"));
31+
string extensionsPath = GetExtensionFolderPath(configuration, log);
32+
log.LogInformation("Loading extensions from {ExtensionsPath}", extensionsPath);
33+
catalog.Catalogs.Add(new DirectoryCatalog(extensionsPath, "*Extension.dll"));
3534
var container = new CompositionContainer(catalog);
3635

3736
var sources = LoadExtensions<IDataSourceExtension>(container);
@@ -57,6 +56,37 @@ public static async Task Main(string[] args)
5756
await hostingProcess;
5857
}
5958

59+
private static string GetExtensionFolderPath(IConfiguration configuration, ILogger logger)
60+
{
61+
var configPath = configuration.GetValue<string>("ExtensionsPath");
62+
if (!string.IsNullOrWhiteSpace(configPath))
63+
{
64+
try
65+
{
66+
var fullPath = Path.GetFullPath(configPath);
67+
if (!Directory.Exists(fullPath))
68+
{
69+
Directory.CreateDirectory(fullPath);
70+
}
71+
72+
return fullPath;
73+
}
74+
catch (Exception ex)
75+
{
76+
logger.LogWarning(ex, "Configured path {ExtensionsPath} is invalid. Using default instead.", configPath);
77+
}
78+
}
79+
80+
var exeFolder = AppContext.BaseDirectory;
81+
var path = Path.Combine(exeFolder, "Extensions");
82+
var di = new DirectoryInfo(path);
83+
if (!di.Exists)
84+
{
85+
di.Create();
86+
}
87+
return di.FullName;
88+
}
89+
6090
private static List<T> LoadExtensions<T>(CompositionContainer container)
6191
where T : class, IDataTransferExtension
6292
{

Core/Microsoft.DataTransfer.Core/appsettings.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Default": "Information"
55
}
66
},
7+
"ExtensionsPath": null,
78
"JsonSourceSettings": {
89
},
910
"JsonSinkSettings": {

Interfaces/Microsoft.DataTransfer.Interfaces/Microsoft.DataTransfer.Interfaces.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<PackageId>datatransfer-interfaces</PackageId>
78
</PropertyGroup>
89

910
<ItemGroup>

0 commit comments

Comments
 (0)