Skip to content

Commit

Permalink
PowerDesigner Add-In skeleton (#1)
Browse files Browse the repository at this point in the history
* Initial creation of empty AddIn
* Added implementation of AddIn methods and created first OData metadata reader setup.
* Setup basic workflow for building the add-in solution.
* Enabled restore during build.
* Migrated package references to proj file.
* Updated build to use msbuild.
* Set signing key stuff in comments.
* Created Setup project to build msi.
* Changed registry settings for setup project and created new msi.
* Added PowerDesigner Type libraries for x64 build.
* Added publishing of msi to workflow.
* Added DisableOutOfProcBuild step in workflow.
* Refactored workflows to have seperate workflow for feature and main and have shared action for build-assembly.
* Added badges to README.
* Updated installation instructions to reflact new situation with workflow artifact.
* Added post build event for importing registry in Debug configuration (and updated README accordingly).
* Changed product name to Add-In where AddIn was used.
  • Loading branch information
harmen-xb committed Oct 7, 2022
1 parent 6943e8b commit 3d93fd4
Show file tree
Hide file tree
Showing 18 changed files with 2,158 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/actions/build-assembly/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Build-AddIn-Assembly
runs:
using: "composite"
steps:
# Checkout the code.
- uses: actions/checkout@v3
# Add msbuild to the path so we can execute it.
- name: Add msbuild to PATH
uses: microsoft/[email protected]
# Restore the solution depencies (NuGet restore).
- name: Restore dependencies
shell: cmd
run: msbuild -t:restore
# Build the solution (without installer).
- name: Build assembly
shell: cmd
run: |
msbuild PowerDesigner_OData_AddIn.sln -property:Configuration=Release
18 changes: 18 additions & 0 deletions .github/workflows/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: feature

on:
push:
branches:
- feature/*

jobs:
build:

# Use Windows 2019 image since this one has the .NET Framework 4.7.2 pre-installed.
# https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md
runs-on: windows-2019

steps:
- uses: actions/checkout@v3
# Use the build-assembly action.
- uses: ./.github/actions/build-assembly
39 changes: 39 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: main

on:
push:
branches:
- main

jobs:
build:

# Use Windows 2019 image since this one has the .NET Framework 4.7.2 pre-installed.
# https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md
runs-on: windows-2019

env:
# Environment variable which points to the VS 2019 IDE folder.
VS_COMMON_IDE_PATH: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/IDE

steps:
- uses: actions/checkout@v3
# Use the build-assembly action.
- uses: ./.github/actions/build-assembly
# Prepare the build-container to be able to build visual studio setup projects.
- name: Prepare installer build
shell: cmd
run: |
DisableOutOfProcBuild.exe
working-directory: ${{env.VS_COMMON_IDE_PATH}}/CommonExtensions/Microsoft/VSI/DisableOutOfProcBuild
# Build the setup project using devenv.
- name: Build installer
shell: cmd
run: |
"%VS_COMMON_IDE_PATH%\devenv.com" "PowerDesigner_OData_AddIn.sln" /Build Release /project PowerDesigner_OData_AddIn_Setup
# Publish the installer as a build artifact.
- name: Publish installer
uses: actions/upload-artifact@v3
with:
name: PD_OData_AddIn_${{ github.run_number }}_${{ github.run_attempt }}
path: PowerDesigner_OData_AddIn_Setup/Release/PowerDesigner_OData_AddIn_Setup.msi
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
bin
obj
.vs
*.user

# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
**/Debug
**/Release
29 changes: 29 additions & 0 deletions PowerDesigner_OData_AddIn.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32510.428
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CrossBreeze.Tools.PowerDesigner.AddIn.OData", "PowerDesigner_OData_AddIn\CrossBreeze.Tools.PowerDesigner.AddIn.OData.csproj", "{669E7D12-509B-441B-A15C-A7B69C991413}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "PowerDesigner_OData_AddIn_Setup", "PowerDesigner_OData_AddIn_Setup\PowerDesigner_OData_AddIn_Setup.vdproj", "{1F31D4DB-3026-4739-83D7-A1228BEE9740}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{669E7D12-509B-441B-A15C-A7B69C991413}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{669E7D12-509B-441B-A15C-A7B69C991413}.Debug|Any CPU.Build.0 = Debug|Any CPU
{669E7D12-509B-441B-A15C-A7B69C991413}.Release|Any CPU.ActiveCfg = Release|Any CPU
{669E7D12-509B-441B-A15C-A7B69C991413}.Release|Any CPU.Build.0 = Release|Any CPU
{1F31D4DB-3026-4739-83D7-A1228BEE9740}.Debug|Any CPU.ActiveCfg = Debug
{1F31D4DB-3026-4739-83D7-A1228BEE9740}.Release|Any CPU.ActiveCfg = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DF6232A0-8648-486A-AEB5-61AEDA7A0CEA}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{669E7D12-509B-441B-A15C-A7B69C991413}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CrossBreeze.Tools.PowerDesigner.AddIn.OData</RootNamespace>
<AssemblyName>CrossBreeze.Tools.PowerDesigner.AddIn.OData</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RegisterForComInterop>true</RegisterForComInterop>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<!--<PropertyGroup>
<AssemblyOriginatorKeyFile>PowerDesigner_OData_AddIn_SigningKey.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>-->
<ItemGroup>
<Reference Include="Interop.PdAddInTypLib">
<HintPath>lib\\Interop.PdAddInTypLib.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Interop.PdCommon">
<HintPath>lib\Interop.PdCommon.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Interop.PdPDM">
<HintPath>lib\Interop.PdPDM.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="PdLogger.cs" />
<Compile Include="PdODataAddIn.cs" />
<Compile Include="PdODataModelUpdater.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="PowerDesigner_OData_AddIn_SigningKey.pfx" />
<!--<None Include="PowerDesigner_OData_AddIn_SigningKey.pfx" />-->
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.OData.Edm">
<Version>7.12.3</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Debug (
echo Registering Debug version of Add-In for PowerDesigner in Windows Registry...
reg import $(ProjectDir)Register_Debug_AddIn.reg
)</PostBuildEvent>
</PropertyGroup>
</Project>
72 changes: 72 additions & 0 deletions PowerDesigner_OData_AddIn/PdLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;

namespace CrossBreeze.Tools.PowerDesigner.AddIn.OData
{
public class PdLogger
{
// A reference to the PowerDesigner Application object.
private PdCommon.Application _app;

public PdLogger(PdCommon.Application app)
{
this._app = app;
}

/// <summary>
/// Helper method to write a debug message in the PowerDesigner output window with a PowerDesigner object class name.
/// </summary>
/// <param name="message">The debug message to write in the PowerDesigner output window</param>
public string PDObjectToString(object pObject)
{
PdCommon.BaseObject pdBaseObject = (PdCommon.BaseObject)pObject;
if (pdBaseObject is PdCommon.NamedObject pdNamedObject)
{
return String.Format("PDObject[ClassName='{0}'; Code='{1}'; Name='{1}'; ObjectLocation='{3}']", pdNamedObject.ClassName, pdNamedObject.Code, pdNamedObject.name, pdNamedObject.ObjectLocation);
}
else
{
return String.Format("PDObject[ClassName='{0}']", pdBaseObject.ClassName);
}
}

/// <summary>
/// Helper method to write a info message in the PowerDesigner output window.
/// </summary>
/// <param name="message">The info message to write in the PowerDesigner output window</param>
public void Info(String message)
{
this.Log(message, "INFO");
}

/// <summary>
/// Helper method to write a error message in the PowerDesigner output window.
/// </summary>
/// <param name="message">The error message to write in the PowerDesigner output window</param>
public void Error(String message)
{
this.Log(message, "ERROR");
}

/// <summary>
/// Helper method to write a debug message in the PowerDesigner output window.
/// </summary>
/// <param name="message">The debug message to write in the PowerDesigner output window</param>
public void Debug(String message)
{
this.Log(message, "DEBUG");
}

/// <summary>
/// Helper method to write a log message in the PowerDesigner output window.
/// </summary>
/// <param name="message">The message to write in the PowerDesigner output window</param>
private void Log(String message, String level)
{
// Only write to the Output if we have a handle on the PowerDesigner application.
if (this._app != null)
this._app.Output(String.Format("[OData-AddIn {0}] {1}", level, message));
else
Console.WriteLine(String.Format("[OData-AddIn {0}] {1}", level, message));
}
}
}
Loading

0 comments on commit 3d93fd4

Please sign in to comment.