Merged in pull request #9, updated chocolatey uninstall to extract product GUID
This commit is contained in:
107
TimberWinR.ExtractID/Program.cs
Normal file
107
TimberWinR.ExtractID/Program.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace TimberWinR.ExtractID
|
||||
{
|
||||
class MsiHandle : SafeHandleMinusOneIsInvalid
|
||||
{
|
||||
public MsiHandle()
|
||||
: base(true)
|
||||
{ }
|
||||
|
||||
protected override bool ReleaseHandle()
|
||||
{
|
||||
return NativeMethods.MsiCloseHandle(handle) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
class NativeMethods
|
||||
{
|
||||
const string MsiDll = "Msi.dll";
|
||||
|
||||
[DllImport(MsiDll, CharSet = CharSet.Unicode, ExactSpelling = true)]
|
||||
public extern static uint MsiOpenPackageW(string szPackagePath, out MsiHandle product);
|
||||
|
||||
[DllImport(MsiDll, ExactSpelling = true)]
|
||||
public extern static uint MsiCloseHandle(IntPtr hAny);
|
||||
|
||||
[DllImport(MsiDll, CharSet = CharSet.Unicode, ExactSpelling = true)]
|
||||
static extern uint MsiGetProductPropertyW(MsiHandle hProduct, string szProperty, StringBuilder value, ref int length);
|
||||
|
||||
|
||||
[DllImport(MsiDll, ExactSpelling = true)]
|
||||
public static extern int MsiSetInternalUI(int value, IntPtr hwnd);
|
||||
|
||||
public static uint MsiGetProductProperty(MsiHandle hProduct, string szProperty, out string value)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder(1024);
|
||||
int length = sb.Capacity;
|
||||
uint err;
|
||||
value = null;
|
||||
if (0 == (err = MsiGetProductPropertyW(hProduct, szProperty, sb, ref length)))
|
||||
{
|
||||
sb.Length = length;
|
||||
value = sb.ToString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Program
|
||||
{
|
||||
[STAThread]
|
||||
static int Main(string[] args)
|
||||
{
|
||||
if (args.Length < 2)
|
||||
{
|
||||
Console.Error.WriteLine("Expecting MSI and Tempolate file arguments");
|
||||
return 1;
|
||||
}
|
||||
|
||||
string msiDirectory = args[0];
|
||||
string updateFile = args[1];
|
||||
string newFile = args[2];
|
||||
|
||||
string msiFile = Directory.GetFiles(msiDirectory, "TimberWinR*.msi").FirstOrDefault();
|
||||
|
||||
NativeMethods.MsiSetInternalUI(2, IntPtr.Zero); // Hide all UI. Without this you get a MSI dialog
|
||||
|
||||
MsiHandle msi;
|
||||
uint err;
|
||||
if (0 != (err = NativeMethods.MsiOpenPackageW(msiFile, out msi)))
|
||||
{
|
||||
Console.Error.WriteLine("Can't open MSI, error {0}", err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Strings available in all MSIs
|
||||
string productCode;
|
||||
using (msi)
|
||||
{
|
||||
if (0 != NativeMethods.MsiGetProductProperty(msi, "ProductCode", out productCode))
|
||||
throw new InvalidOperationException("Can't obtain product code");
|
||||
|
||||
string contents = File.ReadAllText(args[1]);
|
||||
|
||||
contents = contents.Replace("${PROJECTGUID}", productCode);
|
||||
|
||||
File.WriteAllText(args[2], contents);
|
||||
|
||||
Console.WriteLine("Updated {0} ProductID: {1}", args[2], productCode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Console.Error.WriteLine("Failed for some reason");
|
||||
}
|
||||
}
|
||||
}
|
||||
36
TimberWinR.ExtractID/Properties/AssemblyInfo.cs
Normal file
36
TimberWinR.ExtractID/Properties/AssemblyInfo.cs
Normal 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("TimberWinR.ExtractID")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TimberWinR.ExtractID")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[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("cfb670ee-743d-49c7-b2bf-456bac3a88ef")]
|
||||
|
||||
// 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")]
|
||||
55
TimberWinR.ExtractID/TimberWinR.ExtractID.csproj
Normal file
55
TimberWinR.ExtractID/TimberWinR.ExtractID.csproj
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.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>{99096939-E9DD-4499-883D-4726745A5843}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TimberWinR.ExtractID</RootNamespace>
|
||||
<AssemblyName>TimberWinR.ExtractID</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</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="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.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 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>
|
||||
-->
|
||||
</Project>
|
||||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// 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.3.9.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.9.0")]
|
||||
[assembly: AssemblyVersion("1.3.10.0")]
|
||||
[assembly: AssemblyFileVersion("1.3.10.0")]
|
||||
|
||||
@@ -26,6 +26,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "TimberWinR.Wix", "TimberWix\TimberWinR.Wix.wixproj", "{82A39B31-61EC-468D-AA71-0D949AC6528F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{99096939-E9DD-4499-883D-4726745A5843} = {99096939-E9DD-4499-883D-4726745A5843}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimberWinR.ExtractID", "TimberWinR.ExtractID\TimberWinR.ExtractID.csproj", "{99096939-E9DD-4499-883D-4726745A5843}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -79,6 +84,16 @@ Global
|
||||
{82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|Mixed Platforms.Build.0 = Release|x86
|
||||
{82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|x86.ActiveCfg = Release|x86
|
||||
{82A39B31-61EC-468D-AA71-0D949AC6528F}.Release|x86.Build.0 = Release|x86
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{99096939-E9DD-4499-883D-4726745A5843}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -6,6 +6,12 @@
|
||||
<Property Id="LOGDIR">c:\logs</Property>
|
||||
<Property Id="LOGLEVEL">Info</Property>
|
||||
<Property Id="DIAGPORT">5141</Property>
|
||||
|
||||
<PropertyRef Id="NETFRAMEWORK40FULL"/>
|
||||
<Condition Message="This application requires Microsoft .NET Framework 4.0 Runtime in order to run. Please install the .NET Framework and then run this installer again.">
|
||||
<![CDATA[Installed OR NETFRAMEWORK40FULL]]>
|
||||
</Condition>
|
||||
|
||||
<UIRef Id="WixUI_InstallDir" />
|
||||
|
||||
<!--
|
||||
|
||||
@@ -53,15 +53,16 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WixExtension Include="WixNetFxExtension">
|
||||
<HintPath>$(WixExtDir)\WixNetFxExtension.dll</HintPath>
|
||||
<Name>WixNetFxExtension</Name>
|
||||
</WixExtension>
|
||||
<WixExtension Include="WixUIExtension">
|
||||
<HintPath>$(WixExtDir)\WixUIExtension.dll</HintPath>
|
||||
<Name>WixUIExtension</Name>
|
||||
</WixExtension>
|
||||
</ItemGroup>
|
||||
<Import Project="$(WixTargetsPath)" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent />
|
||||
</PropertyGroup>
|
||||
@@ -99,6 +100,9 @@
|
||||
<Output TaskParameter="Value" PropertyName="ProjectDefineConstants" />
|
||||
</CreateProperty>
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>$(SolutionDir)\TimberWinR.ExtractID\$(OutDir)\TimberWinR.ExtractID.exe $(TargetDir) $(SolutionDir)chocolateyUninstall.ps1.guid $(SolutionDir)chocolateyUninstall.ps1.template</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!--
|
||||
To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Wix.targets.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
$packageName = 'TimberWinR-${version}' # arbitrary name for the package, used in messages
|
||||
$installerType = 'msi' #only one of these: exe, msi, msu
|
||||
$url = 'http://www.ericfontana.com/TimberWinR/TimberWinR-${version}.0.msi' # download url
|
||||
$packageName = 'TimberWinR-${version}'
|
||||
$installerType = 'msi'
|
||||
$url = 'http://www.ericfontana.com/TimberWinR/TimberWinR-${version}.0.msi'
|
||||
$silentArgs = '/quiet'
|
||||
$validExitCodes = @(0) #please insert other valid exit codes here, exit codes for ms http://msdn.microsoft.com/en-us/library/aa368542(VS.85).aspx
|
||||
$validExitCodes = @(0)
|
||||
Install-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" "$url64" -validExitCodes $validExitCodes
|
||||
|
||||
|
||||
|
||||
8
chocolateyUninstall.ps1.guid
Normal file
8
chocolateyUninstall.ps1.guid
Normal file
@@ -0,0 +1,8 @@
|
||||
$packageName = 'TimberWinR-${version}' # arbitrary name for the package, used in messages
|
||||
$installerType = 'msi' #only one of these: exe, msi, msu
|
||||
$url = 'http://www.ericfontana.com/TimberWinR/TimberWinR-${version}.0.msi' # download url
|
||||
$silentArgs = '{86CA5678-4687-4352-99EB-783CDB7C8D82} /quiet'
|
||||
$validExitCodes = @(0) #please insert other valid exit codes here, exit codes for ms http://msdn.microsoft.com/en-us/library/aa368542(VS.85).aspx
|
||||
UnInstall-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" -validExitCodes $validExitCodes
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
$packageName = 'TimberWinR-${version}' # arbitrary name for the package, used in messages
|
||||
$installerType = 'msi' #only one of these: exe, msi, msu
|
||||
$url = 'http://www.ericfontana.com/TimberWinR/TimberWinR-${version}.0.msi' # download url
|
||||
$packageName = 'TimberWinR-${version}'
|
||||
$installerType = 'msi'
|
||||
$url = 'http://www.ericfontana.com/TimberWinR/TimberWinR-${version}.0.msi'
|
||||
$silentArgs = '{86CA5678-4687-4352-99EB-783CDB7C8D82} /quiet'
|
||||
$validExitCodes = @(0) #please insert other valid exit codes here, exit codes for ms http://msdn.microsoft.com/en-us/library/aa368542(VS.85).aspx
|
||||
$validExitCodes = @(0)
|
||||
UnInstall-ChocolateyPackage "$packageName" "$installerType" "$silentArgs" "$url" -validExitCodes $validExitCodes
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user