-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from ix-ax/4-Discover_and_copy_Openness_dll
Discover and copy Openness dll
- Loading branch information
Showing
6 changed files
with
81 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
using System; | ||
using System.Resources; | ||
using Tia2Ax.Utils; | ||
using System.Reflection; | ||
|
||
namespace tia2ax | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,47 @@ | ||
using System.Diagnostics; | ||
using Microsoft.Win32; | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
using System.Security.AccessControl; | ||
|
||
namespace tia2axtool | ||
{ | ||
internal class Program | ||
{ | ||
private const string LibraryKey = "SOFTWARE\\Siemens\\Automation\\Openness\\18.0\\PublicAPI\\18.0.0.0"; | ||
private const string LibraryName = "Siemens.Engineering"; | ||
|
||
static void Main(string[] args) | ||
{ | ||
// This is a workaround to make a .net48 assembly work as dotnet tool | ||
var entry = new FileInfo(Assembly.GetEntryAssembly().Location); | ||
var folder = entry.Directory.FullName; | ||
string libraryPath = GetLibraryFilePath(); | ||
if (!string.IsNullOrEmpty(libraryPath)) | ||
{ | ||
// This is a workaround to get the local dll for the Openness | ||
var entry = new FileInfo(Assembly.GetEntryAssembly().Location); | ||
var folder = entry.Directory.FullName; | ||
File.Copy(libraryPath, Path.Combine(folder, LibraryName + ".dll"), true); | ||
File.Copy(libraryPath.Replace("dll", "xml"), Path.Combine(folder, LibraryName + ".xml"), true); | ||
|
||
// This is a workaround to make a .net48 assembly work as dotnet tool | ||
|
||
var exePath = Path.Combine(folder, "V18_0_tia2ax.exe"); | ||
Process.Start(new ProcessStartInfo(exePath) { Arguments = string.Join(" ", args) }); | ||
var exePath = Path.Combine(folder, "V18_0_tia2ax.exe"); | ||
Process.Start(new ProcessStartInfo(exePath) { Arguments = string.Join(" ", args) }); | ||
} | ||
} | ||
|
||
private static string GetLibraryFilePath() | ||
{ | ||
using (var baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64)) | ||
{ | ||
using (var registryKey = baseKey.OpenSubKey(LibraryKey, RegistryKeyPermissionCheck.ReadSubTree, RegistryRights.ReadKey)) | ||
{ | ||
var libraryFilePath = registryKey?.GetValue(LibraryName) as string; | ||
if (!string.IsNullOrWhiteSpace(libraryFilePath) && File.Exists(libraryFilePath)) | ||
{ | ||
return libraryFilePath; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,6 @@ | |
<ItemGroup> | ||
<ProjectReference Include="..\tia2ax\V18_0\V18_0_tia2ax.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> | ||
|
||
|