Skip to content

Commit 1e31f30

Browse files
committedAug 8, 2024
Create dotnet-desktop.yml
1 parent d9de91d commit 1e31f30

File tree

4 files changed

+90
-9
lines changed

4 files changed

+90
-9
lines changed
 

‎.github/workflows/dotnet-desktop.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
# This workflow will build, test, sign and package a WPF or Windows Forms desktop application
7+
# built on .NET Core.
8+
# To learn how to migrate your existing application to .NET Core,
9+
# refer to https://docs.microsoft.com/en-us/dotnet/desktop-wpf/migration/convert-project-from-net-framework
10+
#
11+
# To configure this workflow:
12+
#
13+
# 1. Configure environment variables
14+
# GitHub sets default environment variables for every workflow run.
15+
# Replace the variables relative to your project in the "env" section below.
16+
#
17+
# 2. Signing
18+
# Generate a signing certificate in the Windows Application
19+
# Packaging Project or add an existing signing certificate to the project.
20+
# Next, use PowerShell to encode the .pfx file using Base64 encoding
21+
# by running the following Powershell script to generate the output string:
22+
#
23+
# $pfx_cert = Get-Content '.\SigningCertificate.pfx' -Encoding Byte
24+
# [System.Convert]::ToBase64String($pfx_cert) | Out-File 'SigningCertificate_Encoded.txt'
25+
#
26+
# Open the output file, SigningCertificate_Encoded.txt, and copy the
27+
# string inside. Then, add the string to the repo as a GitHub secret
28+
# and name it "Base64_Encoded_Pfx."
29+
# For more information on how to configure your signing certificate for
30+
# this workflow, refer to https://github.com/microsoft/github-actions-for-desktop-apps#signing
31+
#
32+
# Finally, add the signing certificate password to the repo as a secret and name it "Pfx_Key".
33+
# See "Build the Windows Application Packaging project" below to see how the secret is used.
34+
#
35+
# For more information on GitHub Actions, refer to https://github.com/features/actions
36+
# For a complete CI/CD sample to get started with GitHub Action workflows for Desktop Applications,
37+
# refer to https://github.com/microsoft/github-actions-for-desktop-apps
38+
39+
name: .NET Core Desktop
40+
41+
on:
42+
push:
43+
branches: [ "main" ]
44+
pull_request:
45+
branches: [ "main" ]
46+
47+
jobs:
48+
49+
build:
50+
51+
strategy:
52+
matrix:
53+
configuration: [Release]
54+
55+
runs-on: windows-latest # For a list of available runner types, refer to
56+
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
57+
58+
env:
59+
Solution_Name: CodeGenerator.sln # Replace with your solution name, i.e. MyWpfApp.sln.
60+
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
67+
# Install the .NET Core workload
68+
- name: Install .NET Core
69+
uses: actions/setup-dotnet@v4
70+
with:
71+
dotnet-version: 8.0.x
72+
73+
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
74+
- name: Setup MSBuild.exe
75+
uses: microsoft/setup-msbuild@v2
76+
77+
# Restore the application to populate the obj folder with RuntimeIdentifiers
78+
- name: Restore the application
79+
run: msbuild $env:Solution_Name /t:Restore /p:Configuration=$env:Configuration
80+
env:
81+
Configuration: ${{ matrix.configuration }}

‎CodeGenerator/MainWindow.xaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
HorizontalAlignment="Center"
4141
VerticalAlignment="Center">
4242
<TextBox Name="EntityName"
43-
Width="250"
43+
Width="300"
4444
Height="25"
4545
VerticalContentAlignment="Center"
4646
Margin="0,0,10,0"
@@ -58,7 +58,7 @@
5858
HorizontalAlignment="Center"
5959
VerticalAlignment="Center">
6060
<TextBox Name="ModelPath"
61-
Width="250"
61+
Width="300"
6262
Height="25"
6363
VerticalContentAlignment="Center"
6464
ToolTip="Namespace to use when creating model files. Namespace Folder will be picked up from the Entity Name"
@@ -77,7 +77,7 @@
7777
HorizontalAlignment="Center"
7878
VerticalAlignment="Center">
7979
<TextBox Name="ServiceName"
80-
Width="250"
80+
Width="300"
8181
Height="25"
8282
VerticalContentAlignment="Center"
8383
Margin="0,0,10,0"
@@ -95,8 +95,8 @@
9595
HorizontalAlignment="Center"
9696
VerticalAlignment="Center">
9797
<TextBox Name="EndpointImports"
98-
Width="250"
99-
Height="75"
98+
Width="300"
99+
Height="90"
100100
VerticalContentAlignment="Center"
101101
TextWrapping="Wrap"
102102
AcceptsReturn="True"

‎CodeGenerator/MainWindow.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public async void Generate_Click(object sender, RoutedEventArgs e)
4545
{ "ModelPath", ModelPath.Text },
4646
{ "ModelNamespace", modelNamespace }
4747
};
48-
var parsedEndpointImportsTemplate = string.IsNullOrEmpty(EndpointImports.Text) ? await GetParsedTemplate(Path.Combine(TemplatePath, "EndpointImports.txt"), Placeholders) : EndpointImports.Text;
48+
var parsedEndpointImportsTemplate = await GetParsedTemplate(string.IsNullOrEmpty(EndpointImports.Text) ? Path.Combine(TemplatePath, "EndpointImports.txt") : EndpointImports.Text, Placeholders, string.IsNullOrEmpty(EndpointImports.Text));
4949
Placeholders.Add("EndpointImports", parsedEndpointImportsTemplate);
5050

5151
CreateFolder(Path.Combine(DesktopPath), EntityName.Text, out var rootFolder);
@@ -128,10 +128,10 @@ public async Task GenerateFromTemplate(string templatePath, string folderPath, s
128128
}
129129
}
130130

131-
public async Task<string?> GetParsedTemplate(string templatePath, object model)
131+
public async Task<string?> GetParsedTemplate(string templateStr, object model, bool isTemplate = true)
132132
{
133133
var parser = new FluidParser();
134-
if (parser.TryParse(await File.ReadAllTextAsync(templatePath), out var template, out var error))
134+
if (parser.TryParse(isTemplate ? await File.ReadAllTextAsync(templateStr) : templateStr, out var template, out var error))
135135
{
136136
var options = new TemplateOptions();
137137
options.Filters.AddFilter("LowerFirstChar", Utils.LowerFirstChar);

‎CodeGenerator/SourceFiles/AutoMapper.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using AutoMapper;
22

3-
namespace SAMP.Application.Models.{{ EntityName }};
3+
namespace {{ ModelPath }}.{{ EntityName }};
44

55
public class MapperProfile : Profile
66
{

0 commit comments

Comments
 (0)