Compare commits

...

11 commits
v1.0.4 ... main

Author SHA1 Message Date
Gerrit
1dd12c02a5 🐛 Fix Permission Problems when installing the Printer as user without admin privileges. 2023-08-03 11:27:26 +02:00
Gerrit
49ee9b1079 🐛 Fix Error Handling of Job Factory 2023-08-03 10:34:31 +02:00
Gerrit
a22a3b0cfd Inherit secrets 2023-07-13 08:54:47 +02:00
Gerrit
4490dd1599 Use CERTIFICATEPASSWORD for release pipeline 2023-07-13 08:41:27 +02:00
Gerrit
346a14a25a Sign msi 2023-07-12 17:55:31 +02:00
Gerrit
bbfa313804 Fix build pipeline 2023-07-12 17:44:05 +02:00
Gerrit
6cc07f5bac Merge branch 'main' of https://github.com/amagno-io/AmagnoVirtualPrinter 2023-07-12 17:38:56 +02:00
Gerrit
747b509a0c Add certificate to sign files 2023-07-12 17:38:55 +02:00
Gerrit Edzards
744062944d
Update README.md 2023-06-01 09:32:33 +02:00
Gerrit
8916b0c348 add .msi to gitignore 2023-05-31 14:22:06 +02:00
Gerrit
46c466a864 Remove msi 2023-05-31 14:20:52 +02:00
13 changed files with 84 additions and 27 deletions

View file

@ -13,6 +13,7 @@ jobs:
env:
solution: AmagnoVirtualPrinter.sln
configuration: Release
certificatepassword: ${{ secrets.CERTIFICATEPASSWORD }}
steps:
- name: Checkout
uses: actions/checkout@v3
@ -24,8 +25,14 @@ jobs:
run: msbuild $env:solution /m /t:Restore /p:Configuration=$env:configuration
- name: Build solution
run: msbuild $env:solution /m /t:Rebuild /p:Configuration=$env:configuration
- name: Create msi from PowerShell Script
- name: Sign setup files with PowerShell Script
shell: powershell
run: powershell -file .\$GITHUB_WORKSPACE\sign_files.ps1 -Path .\$GITHUB_WORKSPACE\Files -CertPath .\$GITHUB_WORKSPACE\codeSigningCert.pfx -CertPwd $env:certificatepassword
- name: Create msi with PowerShell Script
run: pwsh -command ".\$GITHUB_WORKSPACE\create_msi.ps1"
- name: Sign msi with PowerShell Script
shell: powershell
run: powershell -file .\$GITHUB_WORKSPACE\sign_setup.ps1 -CertPath .\$GITHUB_WORKSPACE\codeSigningCert.pfx -CertPwd $env:certificatepassword
- name: Upload files artifact
uses: actions/upload-artifact@v3
with:

View file

@ -8,7 +8,7 @@ on:
jobs:
call-build:
uses: ./.github/workflows/build.yml
secrets: inherit
release:
runs-on: windows-latest
needs: call-build

2
.gitignore vendored
View file

@ -17,6 +17,7 @@
mono_crash.*
# Build results
*.msi
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
@ -235,7 +236,6 @@ ClientBin/
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs

Binary file not shown.

View file

@ -147,7 +147,7 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
var machine = job.MachineName?.TrimStart('\\');
var username = job.UserName;
LogDebug($"Searching for session of {domain}\\{username} on {machine} !");
LogDebug($"Searching for session of {domain}\\{username} on {machine}!");
if (domain == null || machine == null || username == null)
{

View file

@ -30,7 +30,9 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
[NotNull]
private readonly IJobProcessor _jobProcessor;
private IDirectoryHelper _directoryHelper;
[NotNull]
private readonly IDirectoryHelper _directoryHelper;
private TcpListener _socket;
private FileSystemWatcher _watcher;
private string _outputDir;
@ -101,19 +103,20 @@ namespace AmagnoVirtualPrinter.Agent.Lib.Misc
LogDebug($"{remote} --> {local}");
job = _jobFactory.Create(printer, client.GetStream());
if (job == null)
{
LogError("Job could not be created.");
return;
}
}
LogDebug($"Temporarily printed '{job.RawDataPath}'!");
socket.BeginAcceptTcpClient(HandleClient, ar.AsyncState);
_jobService.Start(job);
RestartFileWatcherIfNeeded(job.SessionInfo.Sid);
if (job == null)
{
LogError("Job could not be created. Check your Printer Settings.");
}
else
{
LogDebug($"Temporarily printed '{job.RawDataPath}'!");
_jobService.Start(job);
RestartFileWatcherIfNeeded(job.SessionInfo.Sid);
}
}
private void RestartFileWatcherIfNeeded(string sid)

View file

@ -97,7 +97,7 @@ namespace AmagnoVirtualPrinter.Utils
}
[ContractAnnotation("key:null => void")]
private void CheckForNull(RegistryKey key, string keyName)
private static void CheckForNull(RegistryKey key, string keyName)
{
if (key == null)
{

View file

@ -63,7 +63,14 @@ namespace AmagnoVirtualPrinter.SetupDriver
try
{
Console.WriteLine(exe + " " + args);
using(var proc = Process.Start(exe, args))
var processStartInfo = new ProcessStartInfo(exe, args)
{
Verb = "runas",
UseShellExecute = true
};
using(var proc = Process.Start(processStartInfo))
{
proc?.WaitForExit();
}

View file

@ -17,22 +17,22 @@ There are two ways of using the _AmagnoVirtualPrinter_:
2. [Usage](#usage)
1. [Configure](#configure)
2. [Debugging](#debugging)
3. [License](#license)
3. [Create Release](#create-release)
## Installation
### From MSI
If you want to use the official installer, you can download it [here](https://amagno.de) or use the latest release in GitHub. Make sure to run the installer with extended rights. After installation, you may need to [configure](#configure) the _AmagnoVirtualPrinter_.
If you want to use the official installer, you can download it [here](https://amagno.de/clients) or use the latest release in GitHub. Make sure to run the installer with extended rights. After installation, you may need to [configure](#configure) the _AmagnoVirtualPrinter_.
After installation, a new printer with the name set in _Defaults.cs_ can be located under _Printer & Scanner_ in the Microsoft® Windows settings.
### From Source
#### **_Dependencies_**
#### Dependencies
To compile the installer, please make sure the Wix Toolset is installed. The [WixSharp library](https://github.com/oleg-shilo/wixsharp) is used to define the package in `AmagnoVirtualPrinter.WixSharpInstaller`.
#### **_Create MSI package_**
#### Create MSI package
To install the driver from source, build the project in release mode. When the build is run successfully, open up powershell and navigate to `C:\[Git]\AmagnoVirtualPrinter\Files`. Then run the `AmagnoPrinterInstaller.exe "/MSBUILD:C:\[Git]\AmagnoVirtualPrinter\Installer\AmagnoVirtualPrinter.WixSharpInstaller" "/p:C:\[Git]\AmagnoVirtualPrinter\"` where `/p:` is the output directory for the msi and working directory for the WixSharp project. Make sure the given working directory contains a `Files` folder with all binaries needed for _AmagnoVirtualPrinter_. This command will use WixSharp to create the msi package right next to the AmagnoPrinterInstaller.exe called **AmagnoPrinterInstaller.msi**.
@ -54,7 +54,5 @@ The output directory can be set in `Computer\HKEY_CURRENT_USER\SOFTWARE\vpd\Prin
To debug the _AmagnoVirtualPrinter_, run the msi. After installation, go to _Windows Services_ and stop the _AmagnoPrinterService_. In your IDE, select the AmagnoVirtualPrinter.Agent.Console as startup project and run in debug mode. To start a test print (and debug the solution) start PowerShell or cmd and navigate to the root folder of the repository. Go to `Files` and run `.\setupdrv.exe test`, which will create a test page and send it to the virtual printer. Or just print any document you want to.
## License
## Create Release
To create a release, you have to tag a commit. Then the release pipeline compiles the source code, builds the installation, and creates the release on GitHub.

BIN
codeSigningCert.pfx Normal file

Binary file not shown.

View file

@ -1,5 +1,5 @@
Set-Location $PSScriptRoot
$args = "/MSBUILD:$PSScriptRoot\Installer\AmagnoVirtualPrinter.WixSharpInstaller", "/p:$PSScriptRoot"
$arguments = "/MSBUILD:$PSScriptRoot\Installer\AmagnoVirtualPrinter.WixSharpInstaller", "/p:$PSScriptRoot"
Remove-Item -Path "$PSScriptRoot\Files\*" -Filter '*.pdb' -Force
Start-Process -FilePath "$PSScriptRoot\Files\AmagnoPrinterInstaller.exe" -ArgumentList $args -wait
Start-Process -FilePath "$PSScriptRoot\Files\AmagnoPrinterInstaller.exe" -ArgumentList $arguments -wait

26
sign_files.ps1 Normal file
View file

@ -0,0 +1,26 @@
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String]
$path,
[Parameter(Mandatory=$true)]
[String]
$certPath,
[Parameter(Mandatory=$true)]
[String]
$certPwd
)
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath, $certPwd)
$files = Get-ChildItem -Path $path |
Where-Object { $_.Extension -in '.dll', '.exe' } |
Select-Object -ExpandProperty FullName |
Get-AuthenticodeSignature |
Where-Object { $_.Status -eq "NotSigned" } |
Select-Object -ExpandProperty Path
foreach($file in $files){
Write-Host "Signing... $file"
Set-AuthenticodeSignature $file -Certificate $cert -TimestampServer "http://timestamp.digicert.com"
}

16
sign_setup.ps1 Normal file
View file

@ -0,0 +1,16 @@
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[String]
$certPath,
[Parameter(Mandatory=$true)]
[String]
$certPwd
)
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath, $certPwd)
$file = "AmagnoPrinterInstaller.msi"
Write-Host "Signing... $file"
Set-AuthenticodeSignature $file -Certificate $cert -TimestampServer "http://timestamp.digicert.com"