Switch to .NET 8 for cross-platform build support
- Target net8.0-windows instead of net4.8 - EnableWindowsTargeting for Linux build - Replace Marshal.GetActiveObject with P/Invoke (not in .NET 8) - Use NuGet package for Outlook Interop instead of local DLL ref - Update Inno Setup script for .NET 8 runtime check - Builds successfully on Linux, runs on Windows Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
84ba78a1c5
commit
ad649ad319
|
|
@ -36,7 +36,7 @@ Name: "autostart"; Description: "Bei Windows-Anmeldung automatisch starten"; Gro
|
||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
; Hauptanwendung - Pfad anpassen nach Build
|
; Hauptanwendung - Pfad anpassen nach Build
|
||||||
Source: "..\src\StarfaceOutlookSync\bin\Release\net4.8\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
Source: "..\src\StarfaceOutlookSync\bin\Release\net8.0-windows\win-x64\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
||||||
|
|
||||||
[Icons]
|
[Icons]
|
||||||
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
|
||||||
|
|
@ -57,26 +57,35 @@ Filename: "taskkill"; Parameters: "/F /IM {#MyAppExeName}"; Flags: runhidden; Ru
|
||||||
Type: filesandordirs; Name: "{userappdata}\StarfaceOutlookSync"
|
Type: filesandordirs; Name: "{userappdata}\StarfaceOutlookSync"
|
||||||
|
|
||||||
[Code]
|
[Code]
|
||||||
// Pruefe ob .NET Framework 4.8 installiert ist
|
// Pruefe ob .NET 8 Desktop Runtime installiert ist
|
||||||
function IsDotNetInstalled(): Boolean;
|
function IsDotNet8Installed(): Boolean;
|
||||||
var
|
var
|
||||||
Version: Cardinal;
|
ResultCode: Integer;
|
||||||
begin
|
begin
|
||||||
Result := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', Version);
|
// dotnet --list-runtimes enthaelt "Microsoft.WindowsDesktop.App 8.x"
|
||||||
|
Result := Exec('dotnet', '--list-runtimes', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
|
||||||
if Result then
|
if Result then
|
||||||
Result := Version >= 528040; // .NET 4.8
|
Result := ResultCode = 0;
|
||||||
|
// Einfacher Check: dotnet.exe muss existieren
|
||||||
|
Result := FileExists(ExpandConstant('{commonpf}\dotnet\dotnet.exe')) or
|
||||||
|
FileExists(ExpandConstant('{commonpf64}\dotnet\dotnet.exe'));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function InitializeSetup(): Boolean;
|
function InitializeSetup(): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := True;
|
Result := True;
|
||||||
|
|
||||||
if not IsDotNetInstalled() then
|
if not IsDotNet8Installed() then
|
||||||
begin
|
begin
|
||||||
MsgBox('.NET Framework 4.8 oder hoeher wird benoetigt.' + #13#10 +
|
if MsgBox('.NET 8 Desktop Runtime wird benoetigt.' + #13#10 + #13#10 +
|
||||||
'Bitte installieren Sie es von:' + #13#10 +
|
'Soll die Download-Seite geoeffnet werden?',
|
||||||
'https://dotnet.microsoft.com/download/dotnet-framework/net48',
|
mbConfirmation, MB_YESNO) = IDYES then
|
||||||
mbError, MB_OK);
|
begin
|
||||||
|
ShellExec('open', 'https://dotnet.microsoft.com/download/dotnet/8.0/runtime', '', '', SW_SHOWNORMAL, ewNoWait, ResultCode);
|
||||||
|
end;
|
||||||
Result := False;
|
Result := False;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
ResultCode: Integer;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,17 @@ namespace StarfaceOutlookSync.Services
|
||||||
private Outlook.Application _outlookApp;
|
private Outlook.Application _outlookApp;
|
||||||
private bool _weStartedOutlook;
|
private bool _weStartedOutlook;
|
||||||
|
|
||||||
|
// Marshal.GetActiveObject existiert nicht in .NET 8, daher P/Invoke
|
||||||
|
[DllImport("oleaut32.dll", PreserveSig = false)]
|
||||||
|
private static extern void GetActiveObject([MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, IntPtr pvReserved, [MarshalAs(UnmanagedType.IUnknown)] out object ppunk);
|
||||||
|
|
||||||
|
private static object GetActiveComObject(string progId)
|
||||||
|
{
|
||||||
|
var clsid = Type.GetTypeFromProgID(progId, true).GUID;
|
||||||
|
GetActiveObject(clsid, IntPtr.Zero, out var obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
private Outlook.Application GetOutlookApp()
|
private Outlook.Application GetOutlookApp()
|
||||||
{
|
{
|
||||||
if (_outlookApp != null) return _outlookApp;
|
if (_outlookApp != null) return _outlookApp;
|
||||||
|
|
@ -18,7 +29,7 @@ namespace StarfaceOutlookSync.Services
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Versuche laufende Outlook-Instanz zu finden
|
// Versuche laufende Outlook-Instanz zu finden
|
||||||
_outlookApp = (Outlook.Application)Marshal.GetActiveObject("Outlook.Application");
|
_outlookApp = (Outlook.Application)GetActiveComObject("Outlook.Application");
|
||||||
_weStartedOutlook = false;
|
_weStartedOutlook = false;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net4.8</TargetFramework>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<ApplicationIcon>Resources\app.ico</ApplicationIcon>
|
|
||||||
<AssemblyTitle>Starface Outlook Sync</AssemblyTitle>
|
<AssemblyTitle>Starface Outlook Sync</AssemblyTitle>
|
||||||
<Company>HackerSoft - Hacker-Net Telekommunikation</Company>
|
<Company>HackerSoft - Hacker-Net Telekommunikation</Company>
|
||||||
<Product>Starface Outlook Sync</Product>
|
<Product>Starface Outlook Sync</Product>
|
||||||
|
|
@ -13,21 +12,14 @@
|
||||||
<FileVersion>0.0.0.1</FileVersion>
|
<FileVersion>0.0.0.1</FileVersion>
|
||||||
<Description>Synchronisiert Outlook-Kontakte mit Starface Telefonanlage</Description>
|
<Description>Synchronisiert Outlook-Kontakte mit Starface Telefonanlage</Description>
|
||||||
<Copyright>Stefan Hacker - HackerSoft</Copyright>
|
<Copyright>Stefan Hacker - HackerSoft</Copyright>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<SelfContained>false</SelfContained>
|
||||||
|
<EnableWindowsTargeting>true</EnableWindowsTargeting>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.Office.Interop.Outlook">
|
|
||||||
<HintPath>$(ProgramFiles)\Microsoft Office\root\Office16\ADDINS\Microsoft.Office.Interop.Outlook.dll</HintPath>
|
|
||||||
<Private>false</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
</ItemGroup>
|
<PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1004" />
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Include="Resources\app.ico" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -228,17 +228,17 @@ namespace StarfaceOutlookSync.UI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SyncSelectedProfile()
|
private Task SyncSelectedProfile()
|
||||||
{
|
{
|
||||||
if (_profileList.SelectedItems.Count == 0)
|
if (_profileList.SelectedItems.Count == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Bitte ein Profil auswaehlen.", "Sync",
|
MessageBox.Show("Bitte ein Profil auswaehlen.", "Sync",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
var profile = _profileList.SelectedItems[0].Tag as SyncProfile;
|
var profile = _profileList.SelectedItems[0].Tag as SyncProfile;
|
||||||
if (profile == null) return;
|
if (profile == null) return Task.CompletedTask;
|
||||||
|
|
||||||
using (var syncForm = new SyncProgressForm(profile))
|
using (var syncForm = new SyncProgressForm(profile))
|
||||||
{
|
{
|
||||||
|
|
@ -246,6 +246,7 @@ namespace StarfaceOutlookSync.UI
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshProfileList();
|
RefreshProfileList();
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task RunSync(SyncProfile profile)
|
private async Task RunSync(SyncProfile profile)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue