Skip to content

Commit

Permalink
Merge branch 'release/1.2.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
max-eroshkin committed May 5, 2022
2 parents fd496f1 + 11a2995 commit 4a39273
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,4 @@ projectfiles.tar

global.json
.nuke/temp
.nuke/temp
.nuke/build.schema.json
9 changes: 9 additions & 0 deletions DemoApp/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="DemoApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:DemoApp"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
17 changes: 17 additions & 0 deletions DemoApp/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace DemoApp
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
10 changes: 10 additions & 0 deletions DemoApp/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
15 changes: 15 additions & 0 deletions DemoApp/DemoApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<IncludeNativeLibrariesInSingleFile>true</IncludeNativeLibrariesInSingleFile>
<ApplicationIcon>app.ico</ApplicationIcon>
</PropertyGroup>

</Project>
17 changes: 17 additions & 0 deletions DemoApp/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Window x:Class="DemoApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:DemoApp"
mc:Ignorable="d"
Title="InnoSetup ScriptBuilder Demo" Height="200" Width="330">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Demo" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="24" />
<Button Grid.Row="1" Width="50" Content="Close" HorizontalAlignment="Right" Click="CloseButtonOnClick" Margin="0 0 5 5"/>
</Grid>
</Window>
33 changes: 33 additions & 0 deletions DemoApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DemoApp
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void CloseButtonOnClick(object sender, RoutedEventArgs e)
{
Close();
}
}
}
Binary file added DemoApp/app.ico
Binary file not shown.
6 changes: 6 additions & 0 deletions InnoSetup.ScriptBuilder.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{7F0D61ED-5B52-4D98-833F-D92BF4FEF417}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DemoApp", "DemoApp\DemoApp.csproj", "{8CB3E76F-5A4E-4EC1-B6C3-A40745F2A905}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -33,5 +35,9 @@ Global
{7F0D61ED-5B52-4D98-833F-D92BF4FEF417}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F0D61ED-5B52-4D98-833F-D92BF4FEF417}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F0D61ED-5B52-4D98-833F-D92BF4FEF417}.Release|Any CPU.Build.0 = Release|Any CPU
{8CB3E76F-5A4E-4EC1-B6C3-A40745F2A905}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8CB3E76F-5A4E-4EC1-B6C3-A40745F2A905}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8CB3E76F-5A4E-4EC1-B6C3-A40745F2A905}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8CB3E76F-5A4E-4EC1-B6C3-A40745F2A905}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
73 changes: 73 additions & 0 deletions build/Build.Demo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using System;
using System.IO;
using Bimlab.Nuke.Components;
using InnoSetup.ScriptBuilder;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.InnoSetup;

partial class Build
{
Target BuildScript => _ => _
.Description("Builds an iss script file.")
.Executes(() =>
{
var programFiles = (RelativePath)InnoConstants.ProgramFiles64;
var group = (RelativePath)InnoConstants.Group;
var appDir = (RelativePath)InnoConstants.App;

BuilderUtils.Build(builder =>
{
var now = DateTime.UtcNow;
builder.Setup.Create("InnoSetup.ScriptBuilder Demo")
.AppId("{{53A6910D-931A-4FD7-AAA3-DA94DCAD62B6}")
.AppVersion("1.0.0")
.DefaultDirName(programFiles / "IssBuilder Demo")
.DefaultGroupName("InnoSetup ScriptBuilder Demo")
.OutputBaseFilename($"InnoSetup.Builder.Demo_{now:yyyyMMdd}.{now:hhmm}")
.ArchitecturesAllowed(Architectures.X64)
.ArchitecturesInstallIn64BitMode(ArchitecturesInstallIn64BitMode.X64)
.SolidCompression(YesNo.Yes)
.Compression("lzma2")
.DisableDirPage(YesNo.No)
.DisableProgramGroupPage(YesNo.No);

builder.Files
.CreateEntry(OutputDir / "*", InnoConstants.App)
.Flags(FileFlags.IgnoreVersion | FileFlags.RecurseSubdirs);

builder.Icons
.CreateEntry(group / "InnoSetup.ScriptBuilder Demo", appDir / "DemoApp.exe");

builder.Code.CreateEntry(File.ReadAllText(RootDirectory / "build" / "setup.pas"));
}, IssPath);

Console.WriteLine(File.ReadAllText(IssPath));
});

/// <summary>
/// Run <code>.\build.cmd</code> in the solution folder to build Demo setup.
/// </summary>
Target BuildSetup => _ => _
.Description("Builds Demo application installation package.")
.DependsOn(PublishDemoApp, BuildScript)
.Executes(() =>
{
InnoSetupTasks.InnoSetup(config => config
.SetProcessToolPath(ToolPathResolver.GetPackageExecutable("Tools.InnoSetup", "ISCC.exe"))
.SetScriptFile(IssPath)
.SetOutputDir(From<IPack>().ArtifactsDirectory));
});

Target PublishDemoApp => _ => _
.Description("Publishes Demo application.")
.Executes(() =>
{
DotNetTasks.DotNetPublish(x => x
.SetConfiguration("Release")
.SetOutput(OutputDir)
.SetProject(Solution.GetProject("DemoApp")!.Path));
});
}
49 changes: 5 additions & 44 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bimlab.Nuke.Components;
using InnoSetup.ScriptBuilder;
using JetBrains.Annotations;
using Nuke.Common;
using Nuke.Common.CI.GitHubActions;
Expand All @@ -12,7 +10,6 @@
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.InnoSetup;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
Expand All @@ -30,25 +27,19 @@
OnPushBranches = new[] { MasterBranch, "release/**" },
InvokedTargets = new[] { nameof(Test), nameof(IPublish.Publish) },
ImportSecrets = new[] { "NUGET_API_KEY", "ALL_PACKAGES" })]
partial class Build : NukeBuild,
IHazSolution,
IRestore,
ICompile,
IHazGitRepository,
IPack,
IPublish
partial class Build : NukeBuild, IPublish
{
const string MasterBranch = "master";
const string DevelopBranch = "develop";

/// <summary>
/// Solution
/// </summary>
[Solution]
public readonly Solution Solution;

Solution IHazSolution.Solution => Solution;

readonly AbsolutePath OutputDir = TemporaryDirectory / "output";
readonly AbsolutePath IssPath = TemporaryDirectory / "setup.iss";

[UsedImplicitly]
Target Clean => _ => _
.Before<IRestore>()
Expand All @@ -69,43 +60,13 @@ partial class Build : NukeBuild,
.SetConfiguration(From<IHazConfiguration>().Configuration));
});

public Target Inno => _ => _
.DependsOn<ICompile>()
.Executes(() =>
{
var iss = TemporaryDirectory / "package.iss";
var userdata = (RelativePath)"{userappdata}";
var outDir = Solution.GetProject("InnoSetup.ScriptBuilder").Directory / "bin" /
From<IHazConfiguration>().Configuration / "netstandard2.0";

BuilderUtils.Build(s =>
{
var now = DateTime.UtcNow;
s.Setup.Create("InnoSetup Script Builder")
.AppVersion("0.1.0")
.DefaultDirName(userdata / "IssBuilder")
.PrivilegesRequired(PrivilegesRequired.Lowest)
.OutputBaseFilename($"InnoSetup.Builder_{now:yyyyMMdd}.{now:hhmm}")
.DisableDirPage(YesNo.Yes);
s.Files
.CreateEntry(outDir / "*", InnoConstants.App)
.Flags(FileFlags.IgnoreVersion | FileFlags.RecurseSubdirs);
}, iss);

InnoSetupTasks.InnoSetup(config => config
.SetProcessToolPath(ToolPathResolver.GetPackageExecutable("Tools.InnoSetup", "ISCC.exe"))
.SetScriptFile(iss)
.SetOutputDir(From<IPack>().ArtifactsDirectory));
});

public Build()
{
Console.OutputEncoding = Encoding.UTF8;
}

static int Main() => Execute<Build>(x => x.From<IPublish>().List);
static int Main() => Execute<Build>(x => x.BuildSetup);


public Configure<DotNetPackSettings> PackSettings => _ => _
.SetProperty("Copyright", $"Copyright ©{DateTime.UtcNow.Year} Reactive BIM");

Expand Down
2 changes: 1 addition & 1 deletion build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Tools.InnoSetup" Version="6.2.0" IncludeAssets="All" />
<PackageReference Include="Tools.InnoSetup" Version="6.2.1" IncludeAssets="All" />
</ItemGroup>

<ItemGroup>
Expand Down
52 changes: 52 additions & 0 deletions build/setup.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
function GetUninstallString(): String;
var
sUnInstPath: String;
sUnInstallString: String;
begin
sUnInstPath := ExpandConstant('Software\Microsoft\Windows\CurrentVersion\Uninstall\{#emit SetupSetting("AppId")}_is1');
sUnInstallString := '';
if not RegQueryStringValue(HKLM, sUnInstPath, 'UninstallString', sUnInstallString) then
RegQueryStringValue(HKCU, sUnInstPath, 'UninstallString', sUnInstallString);
Result := sUnInstallString;
end;

function IsUpgrade(): Boolean;
begin
Result := (GetUninstallString() <> '');
end;

function UnInstallOldVersion(): Integer;
var
sUnInstallString: String;
iResultCode: Integer;
begin
{ Return Values: }
{ 1 - uninstall string is empty }
{ 2 - error executing the UnInstallString }
{ 3 - successfully executed the UnInstallString }

{ default return value }
Result := 0;

{ get the uninstall string of the old app }
sUnInstallString := GetUninstallString();
if sUnInstallString <> '' then begin
sUnInstallString := RemoveQuotes(sUnInstallString);
if Exec(sUnInstallString, '/SILENT /NORESTART /SUPPRESSMSGBOXES','', SW_HIDE, ewWaitUntilTerminated, iResultCode) then
Result := 3
else
Result := 2;
end else
Result := 1;
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
if (CurStep=ssInstall) then
begin
if (IsUpgrade()) then
begin
UnInstallOldVersion();
end;
end;
end;
6 changes: 3 additions & 3 deletions source/Directory.Build.Props
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
</PropertyGroup>

<ItemGroup Condition="'$(IsPackable)' != 'False'">
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<Version>1.2.1</Version>
<Version>1.2.2</Version>
<Company>Reactive BIM</Company>
<Authors>Reactive BIM</Authors>
<Product>InnoSetup Script Builder</Product>
<PackageTags>InnoSetup Builder RxBIM</PackageTags>
<PackageTags>installer innosetup inno script builder</PackageTags>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PackageProjectUrl>https://github.com/ReactiveBIM/InnoSetup.ScriptBuilder</PackageProjectUrl>
<RepositoryUrl>https://github.com:ReactiveBIM/InnoSetup.ScriptBuilder.git</RepositoryUrl>
Expand Down

0 comments on commit 4a39273

Please sign in to comment.