Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix auto updating package in use #1317

Merged
merged 6 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/fw-lite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,14 @@ jobs:
- name: Publish Windows MAUI portable app
working-directory: backend/FwLite/FwLiteDesktop
run: |
dotnet publish -r win-x64 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }}
dotnet publish -r win-arm64 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }}
dotnet publish -r win-x64 --artifacts-path ../artifacts -p:WindowsPackageType=None -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }}
mkdir -p ../artifacts/sign/portable
cp -r ../artifacts/publish/FwLiteDesktop/* ../artifacts/sign/portable/

- name: Publish Windows MAUI msix app
working-directory: backend/FwLite/FwLiteDesktop
run: |
dotnet publish -r win-x64 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }}
dotnet publish -r win-arm64 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }}
dotnet publish -r win-x64 --artifacts-path ../artifacts -p:ApplicationDisplayVersion=${{ needs.build-and-test.outputs.semver-version }} -p:InformationalVersion=${{ needs.build-and-test.outputs.version }}
mkdir -p ../artifacts/msix
cp ../artifacts/bin/FwLiteDesktop/*/AppPackages/*/*.msix ../artifacts/msix/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<InformationalVersion>$(ApplicationDisplayVersion)</InformationalVersion>
<FileVersion>$(ApplicationDisplayVersion)</FileVersion>
<FileVersion>$(ApplicationDisplayVersion)</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
Expand Down
15 changes: 13 additions & 2 deletions backend/FwLite/FwLiteDesktop/AppVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ namespace FwLiteDesktop;

public class AppVersion
{
public static readonly string Version = typeof(AppVersion).Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "dev";
static AppVersion()
{
var infoVersion = typeof(AppVersion).Assembly
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion;
//info version may look like v2024-12-12-3073dd1c+3073dd1ce2ff5510f54a9411366f55c958b9ea45. We want to strip off everything after the +, so we can compare versions
if (infoVersion is not null && infoVersion.Contains('+'))
{
infoVersion = infoVersion[..infoVersion.IndexOf('+')];
}
Version = infoVersion ?? "dev";
}

public static readonly string Version;
}
6 changes: 2 additions & 4 deletions backend/FwLite/FwLiteDesktop/FwLiteDesktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<!-- version used in AppVersion.cs-->
<InformationalVersion>$(ApplicationDisplayVersion)</InformationalVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.19041.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug' ">
Expand Down
16 changes: 13 additions & 3 deletions backend/FwLite/FwLiteDesktop/Platforms/Windows/AppUpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,24 @@ private async Task TryUpdate()

private async Task ApplyUpdate(FwLiteRelease latestRelease)
{
logger.LogInformation("New version available: {Version}", latestRelease.Version);
logger.LogInformation("New version available: {Version}, Current version: {CurrentVersion}", latestRelease.Version, AppVersion.Version);
var packageManager = new PackageManager();
var asyncOperation = packageManager.AddPackageAsync(new Uri(latestRelease.Url), [], DeploymentOptions.None);
var asyncOperation = packageManager.AddPackageByUriAsync(new Uri(latestRelease.Url),
new AddPackageOptions()
{
DeferRegistrationWhenPackagesAreInUse = true,
ForceUpdateFromAnyVersion = true
});
asyncOperation.Progress = (info, progressInfo) =>
{
if (progressInfo.state == DeploymentProgressState.Queued)
{
logger.LogInformation("Queued update");
return;
}
logger.LogInformation("Downloading update: {ProgressPercentage}%", progressInfo.percentage);
};
var result = await asyncOperation.AsTask();
var result = await asyncOperation;
if (!string.IsNullOrEmpty(result.ErrorText))
{
logger.LogError(result.ExtendedErrorCode, "Failed to download update: {ErrorText}", result.ErrorText);
Expand Down
1 change: 0 additions & 1 deletion backend/FwLite/FwLiteProjectSync/FwLiteProjectSync.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<InformationalVersion>$(ApplicationDisplayVersion)</InformationalVersion>
<FileVersion>$(ApplicationDisplayVersion)</FileVersion>
</PropertyGroup>

Expand Down
1 change: 0 additions & 1 deletion backend/FwLite/LcmCrdt/LcmCrdt.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<InformationalVersion>$(ApplicationDisplayVersion)</InformationalVersion>
<FileVersion>$(ApplicationDisplayVersion)</FileVersion>
</PropertyGroup>

Expand Down
1 change: 0 additions & 1 deletion backend/FwLite/LocalWebApp/LocalWebApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<ServerGarbageCollection>false</ServerGarbageCollection>
<SelfContained>true</SelfContained>
<InformationalVersion>$(ApplicationDisplayVersion)</InformationalVersion>
<FileVersion>$(ApplicationDisplayVersion)</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release' ">
Expand Down
1 change: 0 additions & 1 deletion backend/FwLite/MiniLcm/MiniLcm.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<InformationalVersion>$(ApplicationDisplayVersion)</InformationalVersion>
<FileVersion>$(ApplicationDisplayVersion)</FileVersion>
</PropertyGroup>

Expand Down
Loading