Skip to content

Commit

Permalink
Merge pull request #34 from Freeesia/feature/installer
Browse files Browse the repository at this point in the history
インストーラー作成
  • Loading branch information
Freeesia authored Apr 3, 2024
2 parents 3ce3934 + 61c11c3 commit 4b96a2b
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 8 deletions.
52 changes: 46 additions & 6 deletions .github/workflows/dotnet-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:
# For a list of available runner types, refer to
# https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
runs-on: windows-latest
outputs:
version: ${{ steps.gitversion.outputs.assemblySemFileVer }}
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -94,19 +96,51 @@ jobs:
${{ runner.os }}-licenses-
- run: |
dotnet tool restore
dotnet project-licenses -t -u \
dotnet project-licenses -t -u -m -e \
--packages-filter /Analyzers$/ \
-m -i . \
--include-project-file \
--manual-package-information manual-package-information.json \
-i VdLabel \
-f licenses
- uses: actions/upload-artifact@v4
with:
name: licenses
path: licenses/
installer:
if: ${{ startsWith(github.ref, 'refs/tags/') }}
needs:
- build
- license
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files
restore-keys: |
${{ runner.os }}-nuget-
- uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- uses: actions/download-artifact@v4
with:
path: artifacts
pattern: VdLabel-full-*
merge-multiple: true
- uses: actions/download-artifact@v4
with:
path: artifacts/licenses
name: licenses
- run: dotnet build VdLabel.Wix -c Release
- uses: actions/upload-artifact@v4
with:
name: VdLabel-${{ needs.build.outputs.version }}.msi
path: publish\
release:
if: ${{ success() && startsWith(github.ref, 'refs/tags/') }}
needs:
- installer
- build
- license
runs-on: ubuntu-latest
Expand All @@ -118,13 +152,19 @@ jobs:
- run: |
for dir in VdLabel-*/; do
base=$(basename "$dir")
mkdir -p ${dir}licenses/
cp -r licenses/* ${dir}licenses/
(cd "$dir" && zip -r "../${base}.zip" .)
if ! find "$dir" -maxdepth 1 -type f -name "*.msi" | read; then
# .msiファイルが存在しない場合、既存の処理を実行
mkdir -p "${dir}licenses/"
cp -r licenses/* "${dir}licenses/"
(cd "$dir" && zip -r "../${base}.zip" .)
fi
# .msiファイルが存在する場合は何もしない
done
- uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
draft: true
prerelease: false
files: VdLabel-*.zip
files: |
VdLabel-*.zip
VdLabel-*.msi/VdLabel-*.msi
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,8 @@ MigrationBackup/
.ionide/

# Fody - auto-generated XML schema
FodyWeavers.xsd
FodyWeavers.xsd

# Wix
*.msi
*.g.wxs
Binary file renamed LICENSE.txt → LICENSE.rtf
Binary file not shown.
47 changes: 47 additions & 0 deletions VdLabel.Wix/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Diagnostics;
using WixSharp;
using Path = System.IO.Path;

const string App = "VdLabel";
const string ArtifactsDir = @"..\artifacts";
const string PublishDir = @"..\publish";
const string Executable = $"{App}.exe";

var exePath = Path.Combine(Environment.CurrentDirectory, ArtifactsDir, Executable);
var info = FileVersionInfo.GetVersionInfo(exePath);
var version = info.FileVersion;

var project = new ManagedProject(App,
new Dir(@$"%ProgramFiles%\StudioFreesia\{App}",
new File(exePath) { AddCloseAction = true },
new Files(Path.Combine(ArtifactsDir, "*.*"), p => !p.EndsWith(Executable))));

project.RebootSupressing = RebootSupressing.Suppress;
project.GUID = new("FE947636-81DB-4819-A5D9-939125903F4C");
project.Platform = Platform.x64;
project.Language = "ja-JP";
project.Version = new(version);

// どっちか片方しか設定できない
//project.MajorUpgrade = MajorUpgrade.Default;
project.MajorUpgradeStrategy = MajorUpgradeStrategy.Default;

project.BackgroundImage = @"..\assets\installer_back.png";
project.ValidateBackgroundImage = false;
project.BannerImage = @"..\assets\installer_bunner.png";

// ライセンスファイルの設定
project.LicenceFile = @"..\LICENSE.rtf";

// インストール後にアプリを起動するオプション
project.AfterInstall += static e =>
{
// アンインストール時には起動しない
if (!e.IsUninstalling)
{
Process.Start(e.InstallDir.PathCombine(Executable));
}
};

project.BuildMsi(Path.Combine(PublishDir, $"{App}-{version}.msi"));
26 changes: 26 additions & 0 deletions VdLabel.Wix/VdLabel.Wix.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>VdLavel.Wix</RootNamespace>
<TargetFramework>net472</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<None Remove="*.msi" />
<None Remove="*.exe" />
<None Remove="**\*.wxs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="WixSharp" Version="1.25.2" />
<PackageReference Include="WixSharp.bin" Version="1.25.2" />
<PackageReference Include="WixSharp.wix.bin" Version="3.14.0.1" />
</ItemGroup>

<ItemGroup>
<Reference Include="System.Windows.Forms" />
</ItemGroup>

</Project>
8 changes: 7 additions & 1 deletion VdLabel.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34701.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VdLabel", "VdLabel\VdLabel.csproj", "{550F365E-5537-4DEC-B4F4-9B3E4D904C05}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VdLabel", "VdLabel\VdLabel.csproj", "{550F365E-5537-4DEC-B4F4-9B3E4D904C05}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VdLabel.Wix", "VdLabel.Wix\VdLabel.Wix.csproj", "{35DAED9F-5BF2-47D4-A3B2-E329B11282F8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{550F365E-5537-4DEC-B4F4-9B3E4D904C05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{550F365E-5537-4DEC-B4F4-9B3E4D904C05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{550F365E-5537-4DEC-B4F4-9B3E4D904C05}.Release|Any CPU.Build.0 = Release|Any CPU
{35DAED9F-5BF2-47D4-A3B2-E329B11282F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35DAED9F-5BF2-47D4-A3B2-E329B11282F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35DAED9F-5BF2-47D4-A3B2-E329B11282F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35DAED9F-5BF2-47D4-A3B2-E329B11282F8}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Binary file added assets/installer_back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/installer_bunner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4b96a2b

Please sign in to comment.