This commit is contained in:
Tommy Parnell
2016-04-27 10:46:08 -04:00
parent 7eb84ad843
commit 47eddeb53f
14 changed files with 466 additions and 0 deletions

22
QuikPak.sln Normal file
View File

@@ -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

6
QuikPak/App.config Normal file
View File

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

24
QuikPak/Config.cs Normal file
View File

@@ -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<Endpoint> Endpoints { get; set; }
}
public class Endpoint
{
public string Port { get; set; }
public string DnsName { get; set; }
public bool Secure { get; set; } = false;
}
}

13
QuikPak/Config.json Normal file
View File

@@ -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
}
]
}

17
QuikPak/Options.cs Normal file
View File

@@ -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; }
}
}

84
QuikPak/Program.cs Normal file
View File

@@ -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<Config>(System.IO.File.ReadAllText(options.Config));
var addresses = new List<WebSite.WebAddress>();
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);
}
}
}

View File

@@ -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")]

104
QuikPak/QuikPak.csproj Normal file
View File

@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" 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>{906448E0-73EA-4283-BAB1-4C81EEFC4EFA}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QuikPak</RootNamespace>
<AssemblyName>QuikPak</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BootstrapperCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.0.35.3\lib\BootstrapperCore.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Deployment.WindowsInstaller, Version=3.0.0.0, Culture=neutral, PublicKeyToken=ce35f76fcda82bad, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.0.35.3\lib\Microsoft.Deployment.WindowsInstaller.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<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" />
<Reference Include="WixSharp, Version=1.0.35.3, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.0.35.3\lib\WixSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WixSharp.Msi, Version=1.0.35.0, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.0.35.3\lib\WixSharp.Msi.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WixSharp.UI, Version=1.0.35.2, Culture=neutral, PublicKeyToken=3775edd25acc43c2, processorArchitecture=MSIL">
<HintPath>..\packages\WixSharp.bin.1.0.35.3\lib\WixSharp.UI.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Config.cs" />
<Compile Include="Options.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Config.json" />
<None Include="packages.config" />
<None Include="readme.md">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\WixSharp.1.0.35.3\build\WixSharp.targets" Condition="Exists('..\packages\WixSharp.1.0.35.3\build\WixSharp.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.1.0.35.3\build\WixSharp.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\WixSharp.1.0.35.3\build\WixSharp.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<UsingTask AssemblyFile="packages\WixSharp.1.0.35.3\build\SetEnvVar.dll" TaskName="SetEnvVar" />
</Project>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Do not remove this test for UTF-8: if “Ω” doesnt appear as greek uppercase omega letter enclosed in quotation marks, you should use an editor that supports UTF-8, not this one. -->
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<!-- Read this before publishing packages to chocolatey.org: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
<id>quikpak</id>
<title>QuikPak (Install)</title>
<version>0.2.0</version>
<authors>Tommy Parnell</authors>
<owners>Tommy Parnell</owners>
<summary>quickly pack directory's as IIS websites</summary>
<description>quickly pack directory's as IIS websites
</description>
<projectUrl>https://github.com/tparnell8/QuikPak</projectUrl>
<packageSourceUrl>https://github.com/tparnell8/QuikPak</packageSourceUrl>
<!--<projectSourceUrl></projectSourceUrl>
<docsUrl></docsUrl>
<mailingListUrl></mailingListUrl>
<bugTrackerUrl></bugTrackerUrl>-->
<tags>MSI creation IIS</tags>
<copyright></copyright>
<licenseUrl>https://github.com/tparnell8/QuikPak</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<dependencies>
<dependency id="wixtoolset" />
</dependencies>
<!--<provides></provides>-->
</metadata>
<files>
<file src="tools\**" target="tools" />
<file src="..\bin\Release\**" target="" />
</files>
</package>

View File

@@ -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+)

7
QuikPak/packages.config Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
<package id="WixSharp" version="1.0.35.3" targetFramework="net45" />
<package id="WixSharp.bin" version="1.0.35.3" targetFramework="net45" />
</packages>

1
QuikPak/readme.md Normal file
View File

@@ -0,0 +1 @@
this website is installed via an MSI please do not alter it

26
Readme.md Normal file
View File

@@ -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

2
build.cmd Normal file
View File

@@ -0,0 +1,2 @@
"C:\Program Files (x86)\msbuild\14.0\Bin\msbuild.exe" /p:Configuration=Release
chocolatey pack QuikPak\choco\quikpak.nuspec