Changed project names

This commit is contained in:
Marco Batzinger 2021-01-22 10:55:33 +01:00
parent b4c4aa4010
commit a29e57e66d
130 changed files with 501 additions and 504 deletions

View file

@ -0,0 +1,72 @@
<?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>{A668846E-54C7-483D-9CF7-48F77EA398CA}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AmagnoVirtualPrinter.WixSharpInstaller</RootNamespace>
<AssemblyName>AmagnoPrinterInstaller</AssemblyName>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Files\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>AmagnoVirtualPrinter.WixSharpInstaller.Script</StartupObject>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<Compile Include="Script.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<None Include="wix\$(ProjectName).g.wxs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0" />
<PackageReference Include="WixSharp.bin" Version="1.14.8" />
<PackageReference Include="WixSharp.wix.bin" Version="3.11.2" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Common\AmagnoVirtualPrinter.Utils\AmagnoVirtualPrinter.Utils.csproj">
<Project>{cd1c8e9d-5335-41ac-b0c0-88fd7c7c55f3}</Project>
<Name>AmagnoVirtualPrinter.Utils</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- <Import Project="..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets" Condition="Exists('..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets')" />-->
<!-- <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">-->
<!-- <PropertyGroup>-->
<!-- <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>-->
<!-- </PropertyGroup>-->
<!-- <Error Condition="!Exists('..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixSharp.bin\1.14.8\build\WixSharp.bin.targets'))" />-->
<!-- <Error Condition="!Exists('..\..\packages\WixSharp\1.14.8\build\WixSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\WixSharp\1.14.8\build\WixSharp.targets'))" />-->
<!-- </Target>-->
</Project>

View file

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AmagnoVirtualPrinter.WixSharpInstaller")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Amagno")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("a668846e-54c7-483d-9cf7-48f77ea398ca")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,219 @@
using System;
using System.Collections.Generic;
// ReSharper disable once RedundantUsingDirective
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using AmagnoVirtualPrinter.Utils;
using JetBrains.Annotations;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Win32;
using WixSharp;
using Action = WixSharp.Action;
using File = WixSharp.File;
using Files = AmagnoVirtualPrinter.Utils.Files;
using Keys = AmagnoVirtualPrinter.Utils.Keys;
using RegistryHive = WixSharp.RegistryHive;
namespace AmagnoVirtualPrinter.WixSharpInstaller
{
public class Script
{
private static string _filesDir;
const string SetupDriverId = "setupdrv_exe";
public static void Main([NotNull]string[] args)
{
var workingDir = "";
if (args.Length > 0)
{
foreach(var cmd in args)
{
if (cmd.Contains(@"/p:"))
{
workingDir = cmd.Remove(0, 3);
Console.WriteLine(workingDir);
}
}
}
if (workingDir.IsNullOrEmpty())
{
throw new ArgumentException("Argument for working directory (/p) not set.");
}
_filesDir = Path.Combine(workingDir, Utils.Files.FILES);
var feature = new Feature("AmagnoPrinter");
var printerServiceFile = new File(feature, Path.Combine(_filesDir, Utils.Files.PRINTER_SERVICE_EXE))
{
ServiceInstaller = new ServiceInstaller
{
Name = "AmagnoPrinterService",
StartOn = SvcEvent.Install_Wait,
StopOn = SvcEvent.InstallUninstall_Wait,
RemoveOn = SvcEvent.Uninstall_Wait,
ErrorControl = SvcErrorControl.normal,
ConfigureServiceTrigger = ConfigureServiceTrigger.None
}
};
var project = new ManagedProject("AmagnoPrinterInstaller")
{
Name = "Amagno Printer",
GUID = new Guid("8712D2CD-A9F6-456F-99C8-92C2BB070596"),
UpgradeCode = new Guid("0B37A935-EDEC-4ACA-9307-6D8299496C1D"),
UI = WUI.WixUI_InstallDir,
Version = Version.Parse(FileVersionInfo.GetVersionInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).FileVersion),
LicenceFile = Path.Combine(workingDir, Utils.Files.LICENCE_FILE),
Dirs = CreateProjectDirs(feature, printerServiceFile),
Actions = CreateActions(),
RegValues = CreateRegValues(feature).ToArray(),
InstallPrivileges = InstallPrivileges.elevated
};
project.BeforeInstall += ProjectOnBeforeInstall;
project.BuildMsi();
}
private static void ProjectOnBeforeInstall(SetupEventArgs e)
{
const string gsNotFound = "Ghostscript not found!\n" +
"Please install Ghostscript version 9.52 or higher.\n" +
"You can find the installer on the official website:\n" +
"https://www.ghostscript.com/download/gsdnld.html";
var registryView = Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32;
var gsKey = RegistryKey
.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, registryView)
.OpenSubKey(@"SOFTWARE\GPL Ghostscript\9.52");
if (gsKey == null)
{
MessageBox.Show(gsNotFound);
e.Result = ActionResult.Failure;
return;
}
var gsAssembly = (string)gsKey.GetValue("GS_DLL");
if (System.IO.File.Exists(gsAssembly))
{
e.Result = ActionResult.Success;
return;
}
MessageBox.Show(gsNotFound);
e.Result = ActionResult.Failure;
}
[NotNull, ItemNotNull]
private static Dir[] CreateProjectDirs
(
Feature feature,
File printerServiceFile
)
{
return new[]
{
new Dir
(
@"%ProgramFiles%\MyPrinterDriver\",
new DirFiles(feature, _filesDir + @"\*", s => !s.EndsWith(".exe")),
new File(new Id(SetupDriverId), feature, Path.Combine(_filesDir, Utils.Files.SETUP_DRIVER_EXE)),
new File(feature, Path.Combine(_filesDir, Utils.Files.DILIVERY_EXE)),
new File(feature, Path.Combine(_filesDir, Utils.Files.AGENT_PROGRESS_EXE)),
printerServiceFile
)
};
}
[NotNull, ItemNotNull]
private static Action[] CreateActions()
{
return new Action[]
{
new InstalledFileAction(SetupDriverId, "install ps", Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed),
new InstalledFileAction(SetupDriverId, "uninstall", Return.check, When.Before, Step.RemoveFiles, Condition.BeingUninstalled)
};
}
[NotNull]
private static IEnumerable<RegValue> CreateRegValues(Feature feature)
{
var converterKey = $@"{Utils.Keys.PRINTER_DRIVER_KEY32}\{Utils.Keys.CONVERTER_KEY}";
var regValues = new List<RegValue>();
regValues.AddRange(CreateLocalMachineValues(feature, converterKey));
regValues.AddRange(CreateCurrentUserValues(feature, converterKey));
return regValues;
}
[NotNull]
private static IEnumerable<RegValue> CreateLocalMachineValues(Feature feature, string converterKey)
{
var postConverterKey = $@"{Utils.Keys.PRINTER_DRIVER_KEY32}\{Utils.Keys.POSTCONVERTER_KEY}";
var preConverterKey = $@"{Utils.Keys.PRINTER_DRIVER_KEY32}\{Utils.Keys.PRECONVERTER_KEY}";
var converterPdfKey = $@"{Utils.Keys.PRINTER_DRIVER_KEY32}\{Utils.Keys.CONVERTER_PDF_KEY}";
var converterTiffKey = $@"{Utils.Keys.PRINTER_DRIVER_KEY32}\{Utils.Keys.CONVERTER_TIFF_KEY}";
var registryHive = RegistryHive.LocalMachine;
var result = new List<RegValue>
{
new RegValue(feature, registryHive, Utils.Keys.PRINTER_DRIVER_KEY32, KeyNames.INSTALLATION_DIR, "[INSTALLDIR]"),
new RegValue(feature, registryHive, converterKey, KeyNames.SERVER_PORT, 9101) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterKey, KeyNames.THREADS, 2),
new RegValue(feature, registryHive, converterKey, KeyNames.SHOW_PROGRESS, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterKey, KeyNames.PAGES_PER_SHEET, 1),
new RegValue(feature, registryHive, converterKey, KeyNames.FILE_NAME_MASK, "{yyyy}{MM}{DD}{hh}{mm}{ss}{job05}{page03}"),
new RegValue(feature, registryHive, converterKey, KeyNames.OUTPUT_DIR, string.Empty),
new RegValue(feature, registryHive, converterKey, KeyNames.FORMAT, "ps"),
new RegValue(feature, registryHive, converterPdfKey, KeyNames.ENABLED, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterPdfKey, KeyNames.MULTIPAGE, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterPdfKey, KeyNames.PRODUCE_PDFA, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterPdfKey, KeyNames.ALLOW_COPYING, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterPdfKey, KeyNames.ALLOW_PRINTING, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterPdfKey, KeyNames.SUBSETTING, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterPdfKey,KeyNames.QUALITY , 80),
new RegValue(feature, registryHive, converterTiffKey, KeyNames.ENABLED, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterTiffKey, KeyNames.BITS_PIXEL, 24),
new RegValue(feature, registryHive, converterTiffKey, KeyNames.MULTIPAGE, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, converterTiffKey, KeyNames.COMPRESSION, 8)
};
var registryView = Environment.Is64BitOperatingSystem ? RegistryView.Registry64 : RegistryView.Registry32;
var addPostConverterKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, registryView).OpenSubKey(postConverterKey) == null;
var addPreConverterKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, registryView).OpenSubKey(preConverterKey) == null;
if (addPostConverterKey)
{
result.Add(new RegValue(feature, registryHive, postConverterKey, KeyNames.EXECUTABLE_FILE, Files.POST_CONVERTER));
}
if (addPreConverterKey)
{
result.Add(new RegValue(feature, registryHive, preConverterKey, KeyNames.EXECUTABLE_FILE, Files.PRE_CONVERTER));
}
return result;
}
[NotNull]
private static IEnumerable<RegValue> CreateCurrentUserValues(Feature feature, string converterKey)
{
var redirectKey = $@"{Keys.PRINTER_DRIVER_KEY32}\{Keys.CONVERTER_REDIRECT_KEY}";
var registryHive = RegistryHive.CurrentUser;
return new List<RegValue>
{
new RegValue(feature, registryHive, converterKey, KeyNames.PRINT_FORMAT, "PDF"),
new RegValue(feature, registryHive, converterKey, KeyNames.RENDER_DPI, 300) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, redirectKey, KeyNames.ENABLED, 1) {AttributesDefinition = "Type=integer"},
new RegValue(feature, registryHive, redirectKey, KeyNames.PRINTER, "")
};
}
}
}

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>