Skip to content

Commit 9438f98

Browse files
Merge pull request #12 from atc-net/feature/improve-workflow
feat: WIP on pre-integration
2 parents c060214 + 30381ce commit 9438f98

File tree

8 files changed

+174
-113
lines changed

8 files changed

+174
-113
lines changed

.github/workflows/post-integration.yml

+16-21
Original file line numberDiff line numberDiff line change
@@ -48,32 +48,27 @@ jobs:
4848
- name: 🔁 Restore packages
4949
run: dotnet restore Atc.Installer-WithoutSetup.sln
5050

51-
# - name: 🛠️ Build
52-
# run: dotnet build Atc.Installer-WithoutSetup.sln -c Release --no-restore /p:UseSourceLink=true
53-
54-
# - name: 🧪 Run unit tests
55-
# run: dotnet test Atc.Installer-WithoutSetup.sln -c Release --no-build --filter "Category!=Integration"
56-
57-
# - name: 🌩️ SonarCloud install scanner
58-
# run: dotnet tool install --global dotnet-sonarscanner
51+
- name: 🛠️ Building library in release mode with MSBuild
52+
run: |
53+
$vsWhereExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
54+
$vsInstallationPath = & $vsWhereExePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
55+
$msBuildExePath = Join-Path $vsInstallationPath "MSBuild\Current\Bin\MSBuild.exe"
56+
& $msBuildExePath Atc.Installer-WithoutSetup.sln -p:Configuration=Release -p:Platform="Any CPU" -m
57+
shell: pwsh
5958

60-
# - name: 🌩️ SonarCloud analyze
61-
# env:
62-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
64-
# shell: pwsh
65-
# run: |
66-
# dotnet sonarscanner begin /k:"atc-wpf" /o:"atc-net" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
67-
# dotnet build Atc.Installer-WithoutSetup.sln -c Release /p:UseSourceLink=true --no-restore
68-
# dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
59+
# - name: 🧪 Run unit tests with MSBuild
60+
# run: |
61+
# $vsWhereExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
62+
# $vsInstallationPath = & $vsWhereExePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
63+
# $vstestPath = Join-Path $vsInstallationPath "Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
64+
# $testAssemblies = (Get-ChildItem -Recurse -Filter *.Test.dll).FullName
65+
# & $vstestPath $testAssemblies
66+
# shell: pwsh
6967

7068
- name: ⏩ Merge to stable-branch
7169
run: |
7270
git config --local user.email ${{ env.ATC_EMAIL }}
7371
git config --local user.name ${{ env.ATC_NAME }}
7472
git checkout stable
7573
git merge --ff-only main
76-
git push origin stable
77-
78-
# - name: 🗳️ Creating library package for pre-release
79-
# run: dotnet pack Atc.Installer-WithoutSetup.sln -c Release --no-restore -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH_NAME
74+
git push origin stable

.github/workflows/pre-integration.yml

+49-33
Original file line numberDiff line numberDiff line change
@@ -16,45 +16,61 @@ jobs:
1616
with:
1717
fetch-depth: 0
1818

19-
# - name: ⚙️ Setup dotnet 7.0.x
20-
# uses: actions/setup-dotnet@v1
21-
# with:
22-
# dotnet-version: '7.0.x'
19+
- name: ⚙️ Setup dotnet 7.0.x
20+
uses: actions/setup-dotnet@v1
21+
with:
22+
dotnet-version: '7.0.x'
2323

24-
# - name: 📐 Ensure nuget.org added as package source on Windows
25-
# run: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org --configfile $env:APPDATA\NuGet\NuGet.Config
26-
# continue-on-error: true
24+
- name: 📐 Ensure nuget.org added as package source on Windows
25+
run: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org --configfile $env:APPDATA\NuGet\NuGet.Config
26+
continue-on-error: true
2727

28-
# - name: 🔁 Restore packages
29-
# run: dotnet restore Atc.Installer-WithoutSetup.sln
28+
- name: 🔁 Restore packages
29+
run: dotnet restore Atc.Installer-WithoutSetup.sln
3030

31-
# - name: 🛠️ Building library in release mode
32-
# run: dotnet build Atc.Installer-WithoutSetup.sln -c Release --no-restore
31+
- name: 🛠️ Building library in release mode with MSBuild
32+
run: |
33+
$vsWhereExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
34+
$vsInstallationPath = & $vsWhereExePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
35+
$msBuildExePath = Join-Path $vsInstallationPath "MSBuild\Current\Bin\MSBuild.exe"
36+
& $msBuildExePath Atc.Installer-WithoutSetup.sln -p:Configuration=Release -p:Platform="Any CPU" -m
37+
shell: pwsh
3338

34-
dotnet-test:
35-
runs-on: windows-latest
36-
needs:
37-
- dotnet-build
38-
steps:
39-
- name: 🛒 Checkout repository
40-
uses: actions/checkout@v2
41-
with:
42-
fetch-depth: 0
39+
# dotnet-test:
40+
# runs-on: windows-latest
41+
# needs:
42+
# - dotnet-build
43+
# steps:
44+
# - name: 🛒 Checkout repository
45+
# uses: actions/checkout@v2
46+
# with:
47+
# fetch-depth: 0
4348

44-
# - name: ⚙️ Setup dotnet 7.0.x
45-
# uses: actions/setup-dotnet@v1
46-
# with:
47-
# dotnet-version: '7.0.x'
49+
# - name: ⚙️ Setup dotnet 7.0.x
50+
# uses: actions/setup-dotnet@v1
51+
# with:
52+
# dotnet-version: '7.0.x'
4853

49-
# - name: 📐 Ensure nuget.org added as package source on Windows
50-
# run: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org --configfile $env:APPDATA\NuGet\NuGet.Config
51-
# continue-on-error: true
54+
# - name: 📐 Ensure nuget.org added as package source on Windows
55+
# run: dotnet nuget add source https://api.nuget.org/v3/index.json -n nuget.org --configfile $env:APPDATA\NuGet\NuGet.Config
56+
# continue-on-error: true
5257

53-
# - name: 🔁 Restore packages
54-
# run: dotnet restore Atc.Installer-WithoutSetup.sln
58+
# - name: 🔁 Restore packages
59+
# run: dotnet restore Atc.Installer-WithoutSetup.sln
5560

56-
# - name: 🛠️ Build
57-
# run: dotnet build Atc.Installer-WithoutSetup.sln -c Release --no-restore /p:UseSourceLink=true
61+
# - name: 🛠️ Building library in release mode with MSBuild
62+
# run: |
63+
# $vsWhereExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
64+
# $vsInstallationPath = & $vsWhereExePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
65+
# $msBuildExePath = Join-Path $vsInstallationPath "MSBuild\Current\Bin\MSBuild.exe"
66+
# & $msBuildExePath Atc.Installer-WithoutSetup.sln -p:Configuration=Release -p:Platform="Any CPU" -m
67+
# shell: pwsh
5868

59-
# - name: 🧪 Run unit tests
60-
# run: dotnet test Atc.Installer-WithoutSetup.sln -c Release --no-build --filter "Category!=Integration"
69+
# - name: 🧪 Run unit tests with MSBuild
70+
# run: |
71+
# $vsWhereExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
72+
# $vsInstallationPath = & $vsWhereExePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
73+
# $vstestPath = Join-Path $vsInstallationPath "Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
74+
# $testAssemblies = (Get-ChildItem -Recurse -Filter *.Test.dll).FullName
75+
# & $vstestPath $testAssemblies
76+
# shell: pwsh

.github/workflows/release.yml

+17-6
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,27 @@ jobs:
4343
- name: 🔁 Restore packages
4444
run: dotnet restore Atc.Installer-WithoutSetup.sln
4545

46-
- name: 🛠️ Building library in release mode
47-
run: dotnet build Atc.Installer-WithoutSetup.sln -c Release --no-restore /p:UseSourceLink=true
46+
- name: 🛠️ Building library in release mode with MSBuild
47+
run: |
48+
$vsWhereExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
49+
$vsInstallationPath = & $vsWhereExePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
50+
$msBuildExePath = Join-Path $vsInstallationPath "MSBuild\Current\Bin\MSBuild.exe"
51+
& $msBuildExePath Atc.Installer-WithoutSetup.sln -p:Configuration=Release -p:Platform="Any CPU" -m
52+
shell: pwsh
53+
54+
# - name: 🧪 Run unit tests with MSBuild
55+
# run: |
56+
# $vsWhereExePath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
57+
# $vsInstallationPath = & $vsWhereExePath -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
58+
# $vstestPath = Join-Path $vsInstallationPath "Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
59+
# $testAssemblies = (Get-ChildItem -Recurse -Filter *.Test.dll).FullName
60+
# & $vstestPath $testAssemblies
61+
# shell: pwsh
4862

4963
- name: ⏩ Merge to release-branch
5064
run: |
5165
git config --local user.email ${{ env.ATC_EMAIL }}
5266
git config --local user.name ${{ env.ATC_NAME }}
5367
git checkout release
5468
git merge --ff-only stable
55-
git push origin release
56-
57-
- name: 🗳️ Creating library package for release
58-
run: dotnet pack Atc.Installer-WithoutSetup.sln -c Release --no-restore -o ${GITHUB_WORKSPACE}/packages -p:RepositoryBranch=$BRANCH_NAME /p:PublicRelease=true
69+
git push origin release

src/Atc.Installer.Integration/Extensions/DirectoryInfoExtensions.cs

+9
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,13 @@ public static IList<FileInfo> SearchForFiles(
304304

305305
return result;
306306
}
307+
308+
public static long GetTotalFilesLength(
309+
this DirectoryInfo directoryInfo,
310+
string searchPattern = "*",
311+
bool useRecursive = true)
312+
{
313+
var files = SearchForFiles(directoryInfo, searchPattern, useRecursive);
314+
return files.Sum(file => file.Length);
315+
}
307316
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
namespace Atc.Installer.Integration.Helpers;
2+
3+
public static class VersionHelper
4+
{
5+
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "OK.")]
6+
public static bool IsSourceNewerThanDestination(
7+
string? sourceVersion,
8+
string? destinationVersion)
9+
{
10+
if (sourceVersion is null ||
11+
destinationVersion is null ||
12+
sourceVersion == destinationVersion)
13+
{
14+
return false;
15+
}
16+
17+
try
18+
{
19+
return IsSourceNewerThanDestination(
20+
new Version(sourceVersion),
21+
new Version(destinationVersion));
22+
}
23+
catch
24+
{
25+
var sortedSet = new SortedSet<string>(StringComparer.Ordinal)
26+
{
27+
sourceVersion,
28+
destinationVersion,
29+
};
30+
31+
return destinationVersion == sortedSet.First();
32+
}
33+
}
34+
35+
public static bool IsSourceNewerThanDestination(
36+
Version? sourceVersion,
37+
Version? destinationVersion)
38+
{
39+
if (sourceVersion is null ||
40+
destinationVersion is null ||
41+
sourceVersion == destinationVersion)
42+
{
43+
return false;
44+
}
45+
46+
return sourceVersion.IsNewerThan(destinationVersion);
47+
}
48+
49+
public static bool IsDefault(
50+
Version? sourceVersion,
51+
Version? destinationVersion)
52+
{
53+
if (sourceVersion is null ||
54+
destinationVersion is null)
55+
{
56+
return false;
57+
}
58+
59+
return "1.0.0.0".Equals(sourceVersion.ToString(), StringComparison.Ordinal) &&
60+
"1.0.0.0".Equals(destinationVersion.ToString(), StringComparison.Ordinal);
61+
}
62+
}

src/Atc.Installer.Wpf.ComponentProvider.InternetInformationServer/GlobalUsings.cs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
global using System.Text.Json;
66
global using System.Windows;
77
global using System.Windows.Data;
8-
global using System.Windows.Media;
98
global using System.Xml;
109

1110
global using Atc.Helpers;

src/Atc.Installer.Wpf.ComponentProvider/ComponentProviderViewModel_LogicBase.cs

+17-25
Original file line numberDiff line numberDiff line change
@@ -1000,13 +1000,14 @@ private void WorkOnAnalyzeAndUpdateStatesForDotNetVersion()
10001000
installationMainFile = Path.Combine(installationMainPath, $"{Name}.dll");
10011001
}
10021002

1003-
if (!File.Exists(InstalledMainFilePath.GetValueAsString()))
1003+
var resolvedInstalledMainFilePath = InstalledMainFilePath.GetValueAsString();
1004+
if (!File.Exists(resolvedInstalledMainFilePath))
10041005
{
10051006
InstallationState = ComponentInstallationState.NotInstalled;
10061007
}
10071008

10081009
if (File.Exists(installationMainFile) &&
1009-
File.Exists(InstalledMainFilePath.GetValueAsString()))
1010+
File.Exists(resolvedInstalledMainFilePath))
10101011
{
10111012
Version? sourceVersion = null;
10121013
var installationMainFileVersion = FileVersionInfo.GetVersionInfo(installationMainFile);
@@ -1017,16 +1018,23 @@ private void WorkOnAnalyzeAndUpdateStatesForDotNetVersion()
10171018
}
10181019

10191020
Version? destinationVersion = null;
1020-
var installedMainFileVersion = FileVersionInfo.GetVersionInfo(InstalledMainFilePath.GetValueAsString());
1021+
var installedMainFileVersion = FileVersionInfo.GetVersionInfo(resolvedInstalledMainFilePath);
10211022
if (installedMainFileVersion?.FileVersion is not null)
10221023
{
10231024
destinationVersion = new Version(installedMainFileVersion.FileVersion);
10241025
InstalledVersion = installedMainFileVersion.FileVersion;
10251026
}
10261027

1027-
if (sourceVersion is not null &&
1028-
destinationVersion is not null &&
1029-
sourceVersion.IsNewerThan(destinationVersion))
1028+
if (VersionHelper.IsDefault(sourceVersion, destinationVersion))
1029+
{
1030+
var sourcePath = new DirectoryInfo(installationMainFile).Parent!;
1031+
var destinationPath = new DirectoryInfo(resolvedInstalledMainFilePath).Parent!;
1032+
if (sourcePath.GetTotalFilesLength("*.dll") != destinationPath.GetTotalFilesLength("*.dll"))
1033+
{
1034+
InstallationState = ComponentInstallationState.InstalledWithOldVersion;
1035+
}
1036+
}
1037+
else if (VersionHelper.IsSourceNewerThanDestination(sourceVersion, destinationVersion))
10301038
{
10311039
InstallationState = ComponentInstallationState.InstalledWithOldVersion;
10321040
}
@@ -1083,25 +1091,9 @@ private void WorkOnAnalyzeAndUpdateStatesForNodeJsVersion()
10831091
}
10841092
else
10851093
{
1086-
try
1087-
{
1088-
var isNewerThan = new Version(sourceVersion).IsNewerThan(new Version(destinationVersion));
1089-
InstallationState = isNewerThan
1090-
? ComponentInstallationState.InstalledWithOldVersion
1091-
: ComponentInstallationState.Installed;
1092-
}
1093-
catch
1094-
{
1095-
var sortedSet = new SortedSet<string>(StringComparer.Ordinal)
1096-
{
1097-
sourceVersion,
1098-
destinationVersion,
1099-
};
1100-
1101-
InstallationState = destinationVersion == sortedSet.First()
1102-
? ComponentInstallationState.InstalledWithOldVersion
1103-
: ComponentInstallationState.Installed;
1104-
}
1094+
InstallationState = VersionHelper.IsSourceNewerThanDestination(sourceVersion, destinationVersion)
1095+
? ComponentInstallationState.InstalledWithOldVersion
1096+
: ComponentInstallationState.Installed;
11051097
}
11061098
}
11071099
}

src/Atc.Installer.Wpf.ComponentProvider/ValueConverters/ComponentProviderVersionCompareVisibilityVisibleValueConverter.cs

+4-27
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ HostingFrameworkType.DonNetFramework48 or
2525
HostingFrameworkType.DotNet7 or
2626
HostingFrameworkType.DotNet8)
2727
{
28-
return AnalyzeForForDotNet(vm);
28+
return AnalyzeVersion(vm);
2929
}
3030

3131
return vm.ComponentType == ComponentType.InternetInformationService
32-
? AnalyzeForJsVersion(vm)
32+
? AnalyzeVersion(vm)
3333
: Visibility.Collapsed;
3434
}
3535

@@ -39,32 +39,9 @@ HostingFrameworkType.DotNet7 or
3939
object? parameter,
4040
CultureInfo culture) => null;
4141

42-
private static Visibility AnalyzeForJsVersion(
42+
private static Visibility AnalyzeVersion(
4343
ComponentProviderViewModel vm)
44-
{
45-
if (vm.InstallationVersion == vm.InstalledVersion)
46-
{
47-
return Visibility.Collapsed;
48-
}
49-
50-
var sortedSet = new SortedSet<string>(StringComparer.Ordinal)
51-
{
52-
vm.InstallationVersion!,
53-
vm.InstalledVersion!,
54-
};
55-
56-
return vm.InstalledVersion == sortedSet.First()
44+
=> VersionHelper.IsSourceNewerThanDestination(vm.InstallationVersion, vm.InstalledVersion)
5745
? Visibility.Visible
5846
: Visibility.Collapsed;
59-
}
60-
61-
private static Visibility AnalyzeForForDotNet(
62-
ComponentProviderViewModel vm)
63-
{
64-
var sourceVersion = new Version(vm.InstallationVersion!);
65-
var destinationVersion = new Version(vm.InstalledVersion!);
66-
return sourceVersion.IsNewerThan(destinationVersion)
67-
? Visibility.Visible
68-
: Visibility.Collapsed;
69-
}
7047
}

0 commit comments

Comments
 (0)