lib/makit/wix.rb in makit-0.0.53 vs lib/makit/wix.rb in makit-0.0.54

- old
+ new

@@ -1,95 +1,95 @@ -require "securerandom" - -module Makit - # This class provide methods for working with the Nuget package cache - # - # Example: - # - # Makit::Directory.cache("Google.Protobuf", "3.27.2") - # - # dotnet nuget locals all --list - # dotnet nuget locals all --clear - # - class Wix - def self.setup - if (Makit::Environment.is_windows?) - # test if dotnet is installed - if !Makit::DotNet::is_installed? # !File.exist?(Makit::Environment.which("dotnet")) - puts "dotnet does not appear to be installed" - else - # test if wix is already installed - if !`dotnet tool list --global`.include?("wix") - "dotnet tool install --global wix".run - end - puts " Wix version " + "#{Wix::version}".colorize(:green) - # display the link to https://wixtoolset.org/ - puts " https://wixtoolset.org/".colorize(:green) - # display the link to https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17 - puts " https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17".colorize(:green) - end - else - puts "Wix is not supported on non-Windows platforms" - end - end - - def self.version - `wix --version`.strip.split("+").first - end - - def self.setup_package(name, path, files) - # create the path if it does not exist - FileUtils.mkdir_p(path) unless File.directory?(path) - # create the #{name}.wixproj file - File.open("#{path}/#{name}.wixproj", "w") do |f| - f.puts "<Project Sdk=\"WixToolset.Sdk/#{Wix::version}\">" - f.puts "</Project>" - end - # create the Package.wxs file - File.open("#{path}/Package.wxs", "w") do |f| - f.puts "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">" - f.puts " <Package Name=\"#{name}\" Manufacturer=\"Acme\" Version=\"0.0.0.0\" UpgradeCode=\"#{SecureRandom.uuid}\">" - #f.puts " <MajorUpgrade DowngradeErrorMessage=\"!(loc.DowngradeError)\" />" - f.puts " <Files Include=\"#{files}\" />" - #f.puts " <Feature Id=\"Main\">" - #f.puts " <ComponentGroupRef Id=\"Components\" />" - #f.puts " </Feature>" - f.puts " </Package>" - f.puts "</Wix>" - end - end - end # class Wix -end # module Makit - -# Package.wxs with File harvesting -#<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> -# <Package Name="MyProduct" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B0B15C00-1DC4-0374-A1D1-E902240936D5"> -# <Files Include="path\to\files\**" /> -# </Package> -#</Wix> - -#<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> -# <Package Name="Msi.Demo" Manufacturer="Acme" Version="1.0.0.0" UpgradeCode="a87571ec-8be3-447e-ae23-b3a94a85b727"> -# <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> - -# <Feature Id="Main"> -# <ComponentGroupRef Id="Components" /> -# </Feature> -# </Package> -#</Wix> - -#<Project Sdk="WixToolset.Sdk/5.0.1"> -#</Project> - -# Components.wxs -#<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> -# <Fragment> -# <ComponentGroup Id="Components" Directory="INSTALLFOLDER"> -# <Component Guid="b8085fb3-3718-46df-8bf6-ecf9f968dd3d"> -# <File Source="../../artifacts/Msi.Demo.exe" /> -# <File Source="../../artifacts/Msi.Demo.dll" /> -# <File Source="../../artifacts/Msi.Demo.deps.json" /> -# <File Source="../../artifacts/Msi.Demo.runtimeconfig.json" /> -# </Component> -# </ComponentGroup> -# </Fragment> -#</Wix> +require "securerandom" + +module Makit + # This class provide methods for working with the Nuget package cache + # + # Example: + # + # Makit::Directory.cache("Google.Protobuf", "3.27.2") + # + # dotnet nuget locals all --list + # dotnet nuget locals all --clear + # + class Wix + def self.setup + if (Makit::Environment.is_windows?) + # test if dotnet is installed + if !Makit::DotNet::is_installed? # !File.exist?(Makit::Environment.which("dotnet")) + puts "dotnet does not appear to be installed" + else + # test if wix is already installed + if !`dotnet tool list --global`.include?("wix") + "dotnet tool install --global wix".run + end + puts " Wix version " + "#{Wix::version}".colorize(:green) + # display the link to https://wixtoolset.org/ + puts " https://wixtoolset.org/".colorize(:green) + # display the link to https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17 + puts " https://marketplace.visualstudio.com/items?itemName=FireGiant.FireGiantHeatWaveDev17".colorize(:green) + end + else + puts "Wix is not supported on non-Windows platforms" + end + end + + def self.version + `wix --version`.strip.split("+").first + end + + def self.setup_package(name, path, files) + # create the path if it does not exist + FileUtils.mkdir_p(path) unless File.directory?(path) + # create the #{name}.wixproj file + File.open("#{path}/#{name}.wixproj", "w") do |f| + f.puts "<Project Sdk=\"WixToolset.Sdk/#{Wix::version}\">" + f.puts "</Project>" + end + # create the Package.wxs file + File.open("#{path}/Package.wxs", "w") do |f| + f.puts "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">" + f.puts " <Package Name=\"#{name}\" Manufacturer=\"Acme\" Version=\"0.0.0.0\" UpgradeCode=\"#{SecureRandom.uuid}\">" + #f.puts " <MajorUpgrade DowngradeErrorMessage=\"!(loc.DowngradeError)\" />" + f.puts " <Files Include=\"#{files}\" />" + #f.puts " <Feature Id=\"Main\">" + #f.puts " <ComponentGroupRef Id=\"Components\" />" + #f.puts " </Feature>" + f.puts " </Package>" + f.puts "</Wix>" + end + end + end # class Wix +end # module Makit + +# Package.wxs with File harvesting +#<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> +# <Package Name="MyProduct" Version="1.0.0.0" Manufacturer="Example Corporation" UpgradeCode="B0B15C00-1DC4-0374-A1D1-E902240936D5"> +# <Files Include="path\to\files\**" /> +# </Package> +#</Wix> + +#<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> +# <Package Name="Msi.Demo" Manufacturer="Acme" Version="1.0.0.0" UpgradeCode="a87571ec-8be3-447e-ae23-b3a94a85b727"> +# <MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" /> + +# <Feature Id="Main"> +# <ComponentGroupRef Id="Components" /> +# </Feature> +# </Package> +#</Wix> + +#<Project Sdk="WixToolset.Sdk/5.0.1"> +#</Project> + +# Components.wxs +#<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"> +# <Fragment> +# <ComponentGroup Id="Components" Directory="INSTALLFOLDER"> +# <Component Guid="b8085fb3-3718-46df-8bf6-ecf9f968dd3d"> +# <File Source="../../artifacts/Msi.Demo.exe" /> +# <File Source="../../artifacts/Msi.Demo.dll" /> +# <File Source="../../artifacts/Msi.Demo.deps.json" /> +# <File Source="../../artifacts/Msi.Demo.runtimeconfig.json" /> +# </Component> +# </ComponentGroup> +# </Fragment> +#</Wix>