From 47eddeb53f5ec69f4fba18b2dc68e675a4f23811 Mon Sep 17 00:00:00 2001 From: Tommy Parnell Date: Wed, 27 Apr 2016 10:46:08 -0400 Subject: [PATCH] init --- QuikPak.sln | 22 ++++++ QuikPak/App.config | 6 ++ QuikPak/Config.cs | 24 +++++++ QuikPak/Config.json | 13 ++++ QuikPak/Options.cs | 17 +++++ QuikPak/Program.cs | 84 +++++++++++++++++++++++ QuikPak/Properties/AssemblyInfo.cs | 36 ++++++++++ QuikPak/QuikPak.csproj | 104 +++++++++++++++++++++++++++++ QuikPak/choco/quikpak.nuspec | 33 +++++++++ QuikPak/choco/tools/ReadMe.md | 91 +++++++++++++++++++++++++ QuikPak/packages.config | 7 ++ QuikPak/readme.md | 1 + Readme.md | 26 ++++++++ build.cmd | 2 + 14 files changed, 466 insertions(+) create mode 100644 QuikPak.sln create mode 100644 QuikPak/App.config create mode 100644 QuikPak/Config.cs create mode 100644 QuikPak/Config.json create mode 100644 QuikPak/Options.cs create mode 100644 QuikPak/Program.cs create mode 100644 QuikPak/Properties/AssemblyInfo.cs create mode 100644 QuikPak/QuikPak.csproj create mode 100644 QuikPak/choco/quikpak.nuspec create mode 100644 QuikPak/choco/tools/ReadMe.md create mode 100644 QuikPak/packages.config create mode 100644 QuikPak/readme.md create mode 100644 Readme.md create mode 100644 build.cmd diff --git a/QuikPak.sln b/QuikPak.sln new file mode 100644 index 0000000..351d533 --- /dev/null +++ b/QuikPak.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuikPak", "QuikPak\QuikPak.csproj", "{906448E0-73EA-4283-BAB1-4C81EEFC4EFA}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {906448E0-73EA-4283-BAB1-4C81EEFC4EFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {906448E0-73EA-4283-BAB1-4C81EEFC4EFA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {906448E0-73EA-4283-BAB1-4C81EEFC4EFA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {906448E0-73EA-4283-BAB1-4C81EEFC4EFA}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/QuikPak/App.config b/QuikPak/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/QuikPak/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/QuikPak/Config.cs b/QuikPak/Config.cs new file mode 100644 index 0000000..49daf93 --- /dev/null +++ b/QuikPak/Config.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace QuikPak +{ + public class Config + { + public string Id { get; set; } + public string UpgradeCode { get; set; } + public string Name { get; set; } + public string Version { get; set; } + public ICollection Endpoints { get; set; } + } + + public class Endpoint + { + public string Port { get; set; } + public string DnsName { get; set; } + public bool Secure { get; set; } = false; + } +} diff --git a/QuikPak/Config.json b/QuikPak/Config.json new file mode 100644 index 0000000..3e224ca --- /dev/null +++ b/QuikPak/Config.json @@ -0,0 +1,13 @@ +{ + "Id": "d372b142-ea42-4cc9-8dd6-cb4ba2b0c0f3", + "UpgradeCode": "317e4313-2314-46e9-ae7e-6cdfee60c05d", + "Name": "MyWebsite", + "Version": "1.0.0.0", + "Endpoints": [ + { + "port": 80, + "DnsName": "mywebsite.com", + "Secure": false + } + ] +} \ No newline at end of file diff --git a/QuikPak/Options.cs b/QuikPak/Options.cs new file mode 100644 index 0000000..7c865d3 --- /dev/null +++ b/QuikPak/Options.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CommandLine; + +namespace QuikPak +{ + public class Options + { + [Option('x', "path", Required = true, HelpText = "path to files")] + public string Path { get; set; } + [Option('c', "config", Required = true, HelpText = "path to a config")] + public string Config { get; set; } + } +} diff --git a/QuikPak/Program.cs b/QuikPak/Program.cs new file mode 100644 index 0000000..ace9933 --- /dev/null +++ b/QuikPak/Program.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CommandLine; +using Newtonsoft.Json; +using WixSharp; + +namespace QuikPak +{ + class Program + { + public static void Main(string[] args) + { + var options = new Options(); + var result = Parser.Default.ParseArguments(args, options); + if(!result) return; + if(!System.IO.File.Exists(options.Config)) + { + Console.Error.WriteLine("Error Config.json does not exist"); + } + if(!System.IO.Directory.Exists(options.Path)) + { + Console.Error.WriteLine("path to pack does not exist"); + } + var config = JsonConvert.DeserializeObject(System.IO.File.ReadAllText(options.Config)); + var addresses = new List(); + + foreach(var Endpoint in config.Endpoints) + { + addresses.Add(new WebSite.WebAddress() { + Attributes = new Attributes() + { + { "Port", Endpoint.Port }, + {"Header", Endpoint.DnsName }, + { "Secure", Endpoint.Secure? "yes": "no" } + } + }); + } + + var project = new Project(config.Name) + { + Dirs = new[] + { + new Dir(new Id("IISMain"), config.Name + "_" +config.Version.ToString() +"_Web", + new Files(System.IO.Path.Combine(options.Path, "**")), + new File(options.Config, + new IISVirtualDir + { + Name = config.Name + "_Web_VDIR", + WebSite = new WebSite(config.Name) + { + InstallWebSite = true, + Description = config.Name, + Addresses = addresses.ToArray(), + }, + WebAppPool = new WebAppPool(config.Name) + }) + ) + + }, + Version = new Version(config.Version) { }, + GUID = new Guid(config.Id), + UI = WUI.WixUI_ProgressOnly, + OutFileName = config.Name, + PreserveTempFiles = true, + UpgradeCode = new Guid(config.UpgradeCode), + + }; + project.Properties.Add(new Property("REINSTALLMODE", "dmus")); + project.MajorUpgrade = new MajorUpgrade() { AllowDowngrades = true}; + project.MajorUpgradeStrategy = new MajorUpgradeStrategy() { + + UpgradeVersions = new VersionRange() { + IncludeMinimum = true, + IncludeMaximum = false, + Minimum = "0.0.0.1", + Maximum = "99.0.0.0" + } }; + Compiler.BuildMsi(project); + } + } +} diff --git a/QuikPak/Properties/AssemblyInfo.cs b/QuikPak/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e3df4b4 --- /dev/null +++ b/QuikPak/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +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("QuikPak")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("QuikPak")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[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("906448e0-73ea-4283-bab1-4c81eefc4efa")] + +// 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")] diff --git a/QuikPak/QuikPak.csproj b/QuikPak/QuikPak.csproj new file mode 100644 index 0000000..6533355 --- /dev/null +++ b/QuikPak/QuikPak.csproj @@ -0,0 +1,104 @@ + + + + + Debug + AnyCPU + {906448E0-73EA-4283-BAB1-4C81EEFC4EFA} + Exe + Properties + QuikPak + QuikPak + v4.5 + 512 + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\WixSharp.bin.1.0.35.3\lib\BootstrapperCore.dll + True + + + ..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll + True + + + ..\packages\WixSharp.bin.1.0.35.3\lib\Microsoft.Deployment.WindowsInstaller.dll + True + + + ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll + True + + + + + + + + + + + ..\packages\WixSharp.bin.1.0.35.3\lib\WixSharp.dll + True + + + ..\packages\WixSharp.bin.1.0.35.3\lib\WixSharp.Msi.dll + True + + + ..\packages\WixSharp.bin.1.0.35.3\lib\WixSharp.UI.dll + True + + + + + + + + + + + + + + Always + + + + + + + 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}. + + + + + + \ No newline at end of file diff --git a/QuikPak/choco/quikpak.nuspec b/QuikPak/choco/quikpak.nuspec new file mode 100644 index 0000000..3c6adeb --- /dev/null +++ b/QuikPak/choco/quikpak.nuspec @@ -0,0 +1,33 @@ + + + + + + quikpak + QuikPak (Install) + 0.2.0 + Tommy Parnell + Tommy Parnell + quickly pack directory's as IIS websites + quickly pack directory's as IIS websites + + https://github.com/tparnell8/QuikPak + https://github.com/tparnell8/QuikPak + + MSI creation IIS + + https://github.com/tparnell8/QuikPak + false + + + + + + + + + + diff --git a/QuikPak/choco/tools/ReadMe.md b/QuikPak/choco/tools/ReadMe.md new file mode 100644 index 0000000..1c90512 --- /dev/null +++ b/QuikPak/choco/tools/ReadMe.md @@ -0,0 +1,91 @@ +## Summary +How do I create packages? See https://github.com/chocolatey/choco/wiki/CreatePackages + +If you are submitting packages to the community feed (https://chocolatey.org) +always try to ensure you have read, understood and adhere to the create +packages wiki link above. + +## Automatic Packages? +Consider making this package an automatic package, for the best +maintainability over time. Read up at https://github.com/chocolatey/choco/wiki/AutomaticPackages + +## Shim Generation +Any executables you include in the package or download (but don't call +install against using the built-in functions) will be automatically shimmed. + +This means those executables will automatically be included on the path. +Shim generation runs whether the package is self-contained or uses automation +scripts. + +By default, these are considered console applications. + +If the application is a GUI, you should create an empty file next to the exe +named 'name.exe.gui' e.g. 'bob.exe' would need a file named 'bob.exe.gui'. +See https://github.com/chocolatey/choco/wiki/CreatePackages#how-do-i-set-up-batch-redirects-for-applications-that-have-a-gui + +If you want to ignore the executable, create an empty file next to the exe +named 'name.exe.ignore' e.g. 'bob.exe' would need a file named +'bob.exe.ignore'. +See https://github.com/chocolatey/choco/wiki/CreatePackages#how-do-i-exclude-executables-from-getting-batch-redirects + +## Self-Contained? +If you have a self-contained package, you can remove the automation scripts +entirely and just include the executables, they will automatically get shimmed, +which puts them on the path. Ensure you have the legal right to distribute +the application though. See https://github.com/chocolatey/choco/wiki/Legal. + +You should read up on the Shim Generation section to familiarize yourself +on what to do with GUI applications and/or ignoring shims. + +## Automation Scripts +You have a powerful use of Chocolatey, as you are using PowerShell. So you +can do just about anything you need. Choco has some very handy built-in +functions that you can use, these are sometimes called the helpers. + +### Built-In Functions +https://github.com/chocolatey/choco/wiki/HelpersReference + +A note about a couple: +* Get-BinRoot - this is a horribly named function that doesn't do what new folks think it does. It gets you the 'tools' root, which by default is set to 'c:\tools', not the chocolateyInstall bin folder. +* Install-BinFile - used for non-exe files - executables are automatically shimmed... +* Uninstall-BinFile - used for non-exe files - executables are automatically shimmed + +### Getting package specific information +Use the package parameters pattern - see https://github.com/chocolatey/choco/wiki/How-To-Parse-PackageParameters-Argument + +### Need to mount an ISO? +https://github.com/chocolatey/choco/wiki/How-To-Mount-An-Iso-In-Chocolatey-Package + + +### Environment Variables +Chocolatey makes a number of environment variables available (You can access any of these with $env:TheVariableNameBelow): + + * TEMP = Overridden to the CacheLocation, but may be the same as the original TEMP folder + * ChocolateyInstall = Top level folder where Chocolatey is installed + * chocolateyPackageName = The name of the package, equivalent to the id in the nuspec (0.9.9+) + * chocolateyPackageVersion = The version of the package, equivalent to the version in the nuspec (0.9.9+) + * chocolateyPackageFolder = The top level location of the package folder + +#### Advanced Environment Variables +The following are more advanced settings: + + * chocolateyPackageParameters = (0.9.8.22+) + * CHOCOLATEY_VERSION = The version of Choco you normally see. Use if you are 'lighting' things up based on choco version. (0.9.9+) + - Otherwise take a dependency on the specific version you need. + * chocolateyForceX86 = If available and set to 'true', then user has requested 32bit version. (0.9.9+) + - Automatically handled in built in Choco functions. + * OS_PLATFORM = Like Windows, OSX, Linux. (0.9.9+) + * OS_VERSION = The version of OS, like 6.1 something something for Windows. (0.9.9+) + * OS_NAME = The reported name of the OS. (0.9.9+) + * IS_PROCESSELEVATED = Is the process elevated? (0.9.9+) + +#### Experimental Environment Variables +The following are experimental or use not recommended: + + * OS_IS64BIT = This may not return correctly - it may depend on the process the app is running under (0.9.9+) + * CHOCOLATEY_VERSION_PRODUCT = the version of Choco that may match CHOCOLATEY_VERSION but may be different (0.9.9+) + - it's based on git describe + * IS_ADMIN = Is the user an administrator? But doesn't tell you if the process is elevated. (0.9.9+) + * chocolateyInstallOverride = Not for use in package automation scripts. (0.9.9+) + * chocolateyInstallArguments = the installer arguments meant for the native installer. You should use chocolateyPackageParameters intead. (0.9.9+) + diff --git a/QuikPak/packages.config b/QuikPak/packages.config new file mode 100644 index 0000000..3a6e6fd --- /dev/null +++ b/QuikPak/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/QuikPak/readme.md b/QuikPak/readme.md new file mode 100644 index 0000000..75cd6fc --- /dev/null +++ b/QuikPak/readme.md @@ -0,0 +1 @@ +this website is installed via an MSI please do not alter it \ No newline at end of file diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..4dc22f2 --- /dev/null +++ b/Readme.md @@ -0,0 +1,26 @@ +QuikPak is a CLI tool that will take a directory and create an msi that will install a website into IIS with said directory... + +## How to use + +Create a json config file that looks something like this + + +```json + +{ + "Id": "d372b142-ea42-4cc9-8dd6-cb4ba2b0c0f3", + "UpgradeCode": "317e4313-2314-46e9-ae7e-6cdfee60c05d", + "Name": "MyWebsite", + "Version": "1.0.0.0", + "Endpoints": [ + { + "port": 80, + "DnsName": "mywebsite.com", + "Secure": false + } + ] +} + +``` + +then call QuikPak.exe -c path\to\your\config.json -x path\to\your\web\content diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..b1d49b1 --- /dev/null +++ b/build.cmd @@ -0,0 +1,2 @@ +"C:\Program Files (x86)\msbuild\14.0\Bin\msbuild.exe" /p:Configuration=Release +chocolatey pack QuikPak\choco\quikpak.nuspec \ No newline at end of file