Skip to content

Commit 5476df3

Browse files
committed
fixed issue with initial configuration
1 parent dd0fc7a commit 5476df3

File tree

6 files changed

+38
-8
lines changed

6 files changed

+38
-8
lines changed

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"Bash(timeout:*)",
1414
"Bash(ping:*)",
1515
"Bash(findstr:*)",
16-
"Bash(npx eslint:*)"
16+
"Bash(npx eslint:*)",
17+
"Read(//c/ProgramData/ThingConnect.Pulse/logs/**)"
1718
],
1819
"deny": [],
1920
"ask": []

ThingConnect.Pulse.Server/Program.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,20 @@ public static async Task Main(string[] args)
198198
Log.Information("Directory structure verified at {RootPath}", pathSvc.GetRootDirectory());
199199
}
200200

201-
// Initialize database with seed data in development
202-
if (app.Environment.IsDevelopment())
201+
// Ensure database exists and is up to date
202+
using (IServiceScope scope = app.Services.CreateScope())
203203
{
204-
using IServiceScope scope = app.Services.CreateScope();
205204
PulseDbContext context = scope.ServiceProvider.GetRequiredService<PulseDbContext>();
206-
SeedData.Initialize(context);
205+
206+
// Apply any pending migrations or create database if it doesn't exist
207+
await context.Database.MigrateAsync();
208+
Log.Information("Database migration completed");
209+
210+
// Initialize database with seed data in development only
211+
if (app.Environment.IsDevelopment())
212+
{
213+
SeedData.Initialize(context);
214+
}
207215
}
208216

209217
// Initialize sample configuration if no configuration exists

ThingConnect.Pulse.Server/Services/ConfigurationParser.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,29 @@ private ConfigurationParser(JsonSchema schema, ILogger<ConfigurationParser> logg
2626

2727
public static async Task<ConfigurationParser> CreateAsync(ILogger<ConfigurationParser> logger, IDiscoveryService discoveryService)
2828
{
29+
// Try multiple methods to determine the assembly directory
30+
string? assemblyDirectory = null;
31+
32+
// Method 1: Try GetExecutingAssembly().Location
2933
string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
30-
string? assemblyDirectory = Path.GetDirectoryName(assemblyLocation);
34+
if (!string.IsNullOrEmpty(assemblyLocation))
35+
{
36+
assemblyDirectory = Path.GetDirectoryName(assemblyLocation);
37+
}
38+
39+
// Method 2: Try AppContext.BaseDirectory if Location failed
40+
if (string.IsNullOrEmpty(assemblyDirectory))
41+
{
42+
assemblyDirectory = AppContext.BaseDirectory;
43+
logger.LogDebug("Using AppContext.BaseDirectory: {BaseDirectory}", assemblyDirectory);
44+
}
45+
46+
// Method 3: Try current directory as fallback
47+
if (string.IsNullOrEmpty(assemblyDirectory))
48+
{
49+
assemblyDirectory = Environment.CurrentDirectory;
50+
logger.LogDebug("Using current directory: {CurrentDirectory}", assemblyDirectory);
51+
}
3152

3253
if (string.IsNullOrEmpty(assemblyDirectory))
3354
{

brand/favicon.ico

108 KB
Binary file not shown.

build-installer.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ if (-not $SkipBuild) {
9393
"publish", $ProjectDir,
9494
"-c", $Configuration,
9595
"-o", $PublishDir,
96-
"--self-contained", "false",
96+
"--self-contained", "true",
9797
"--runtime", "win-x64",
98-
"/p:PublishSingleFile=false"
98+
"/p:PublishSingleFile=true"
9999
)
100100

101101
& dotnet @PublishArgs
40.1 MB
Binary file not shown.

0 commit comments

Comments
 (0)