Skip to content

Commit 7cc2949

Browse files
committed
Merge branch 'release/2.1.0'
* release/2.1.0: (maint) Update to latest version of chocolatey.lib (maint) Update GRM configuration file (maint) Remove version bump in nuspec file (build) Use latest Chocolatey.Cake.Recipe package (maint) Switch to Http for variable names (#1014) Add advanced option to ignore cached items (#1014) Ignore cached files on forced outdated check (build) Make build files consistent with others (#993) (fix) Correct syntax in KTS file (#993) Add TC schedule trigger (maint) Fix StyleCop warnings (#980) Use assembly location when debugging (maint) Update to released alpha package (#1003) Handle null keys during source translation (#1005) Normalize version numbers (maint) Add banned api analyzer (maint) Remove usage of obsolete methods (maint) Update to latest Chocolatey.Lib package
2 parents a0082c2 + d9823b0 commit 7cc2949

32 files changed

+287
-87
lines changed

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,5 @@ csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
7373
csharp_style_inlined_variable_declaration = true:suggestion
7474
csharp_style_throw_expression = true:suggestion
7575
csharp_style_conditional_delegate_call = true:suggestion
76+
dotnet_diagnostic.RS0030.severity = error
77+
dotnet_diagnostic.RS0031.severity = error

.teamcity/settings.kts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.script
33
import jetbrains.buildServer.configs.kotlin.v2019_2.buildSteps.powerShell
44
import jetbrains.buildServer.configs.kotlin.v2019_2.buildFeatures.pullRequests
55
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.vcs
6+
import jetbrains.buildServer.configs.kotlin.v2019_2.triggers.schedule
67
import jetbrains.buildServer.configs.kotlin.v2019_2.vcs.GitVcsRoot
78

8-
version = "2021.2"
9-
109
project {
1110
buildType(ChocolateyGUI)
1211
}
@@ -62,14 +61,28 @@ object ChocolateyGUI : BuildType({
6261

6362
script {
6463
name = "Call Cake"
65-
scriptContent = "call build.official.bat"
64+
scriptContent = """
65+
IF "%teamcity.build.triggeredBy%" == "Schedule Trigger" (SET TestType=all) ELSE (SET TestType=unit)
66+
call build.official.bat --verbosity=diagnostic --target=CI --testExecutionType=%%TestType%% --shouldRunOpenCover=false
67+
""".trimIndent()
6668
}
6769
}
6870

6971
triggers {
7072
vcs {
7173
branchFilter = ""
7274
}
75+
schedule {
76+
schedulingPolicy = daily {
77+
hour = 2
78+
minute = 0
79+
}
80+
branchFilter = """
81+
+:<default>
82+
""".trimIndent()
83+
triggerBuild = always()
84+
withPendingChangesOnly = false
85+
}
7386
}
7487

7588
features {

GitReleaseManager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ issue-labels-include:
88
- Documentation
99
issue-labels-exclude:
1010
- Internal Refactoring
11-
- Build
11+
- BuildAutomation
1212
- NO RELEASE NOTES
1313
issue-labels-alias:
1414
- name: Documentation

Source/ChocolateyGui.Common.Windows/ChocolateyGui.Common.Windows.csproj

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
44
<PropertyGroup>
@@ -68,7 +68,7 @@
6868
<HintPath>..\packages\Caliburn.Micro.3.2.0\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
6969
</Reference>
7070
<Reference Include="chocolatey">
71-
<HintPath>..\packages\chocolatey.lib.2.0.0\lib\net48\chocolatey.dll</HintPath>
71+
<HintPath>..\packages\chocolatey.lib.2.1.0\lib\net48\chocolatey.dll</HintPath>
7272
<SpecificVersion>False</SpecificVersion>
7373
<Private Condition="'$(Configuration)' != 'Debug'">False</Private>
7474
</Reference>
@@ -235,6 +235,7 @@
235235
<Compile Include="Services\IPackageArgumentsService.cs" />
236236
<Compile Include="Services\PackageArgumentsService.cs" />
237237
<Compile Include="Utilities\Converters\LocalizationConverter.cs" />
238+
<Compile Include="Utilities\Converters\NuGetVersionToString.cs" />
238239
<Compile Include="Utilities\Extensions\LocalizeExtension.cs" />
239240
<Compile Include="Utilities\Converters\NullToInverseBool.cs" />
240241
<Compile Include="Utilities\ToolTipBehavior.cs" />
@@ -422,9 +423,16 @@
422423
<SourceRoot Include="$(MSBuildThisFileDirectory)/../" />
423424
</ItemGroup>
424425
<ItemGroup>
426+
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.4\analyzers\dotnet\cs\Microsoft.CodeAnalysis.BannedApiAnalyzers.dll" />
427+
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.BannedApiAnalyzers.3.3.4\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.BannedApiAnalyzers.dll" />
425428
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
426429
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
427430
</ItemGroup>
431+
<ItemGroup>
432+
<AdditionalFiles Include="..\ChocolateyGui\BannedSymbols.txt">
433+
<Link>BannedSymbols.txt</Link>
434+
</AdditionalFiles>
435+
</ItemGroup>
428436
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
429437
<Import Project="..\packages\HarfBuzzSharp.2.6.1.4\build\net462\HarfBuzzSharp.targets" Condition="Exists('..\packages\HarfBuzzSharp.2.6.1.4\build\net462\HarfBuzzSharp.targets')" />
430438
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

Source/ChocolateyGui.Common.Windows/Services/ChocolateyService.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ public async Task<IReadOnlyList<OutdatedPackage>> GetOutdatedPackages(bool inclu
132132
config.RegularOutput = false;
133133
config.QuietOutput = true;
134134
config.Prerelease = false;
135+
136+
if (forceCheckForOutdatedPackages)
137+
{
138+
config.SetCacheExpirationInMinutes(0);
139+
}
135140
});
136141
var chocoConfig = choco.GetConfiguration();
137142

@@ -195,7 +200,7 @@ public async Task<PackageOperationResult> InstallPackage(
195200

196201
if (version != null)
197202
{
198-
config.Version = version.ToString();
203+
config.Version = version;
199204
}
200205

201206
if (source != null)
@@ -248,6 +253,11 @@ public async Task<PackageOperationResult> InstallPackage(
248253
config.DownloadChecksum64 = advancedInstallOptions.DownloadChecksum64bit;
249254
config.DownloadChecksumType = advancedInstallOptions.DownloadChecksumType;
250255
config.DownloadChecksumType64 = advancedInstallOptions.DownloadChecksumType64bit;
256+
257+
if (advancedInstallOptions.IgnoreHttpCache)
258+
{
259+
config.SetCacheExpirationInMinutes(0);
260+
}
251261
}
252262
});
253263

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// --------------------------------------------------------------------------------------------------------------------
2+
// <copyright company="Chocolatey" file="NuGetVersionToString.cs">
3+
// Copyright 2017 - Present Chocolatey Software, LLC
4+
// Copyright 2014 - 2017 Rob Reynolds, the maintainers of Chocolatey, and RealDimensions Software, LLC
5+
// </copyright>
6+
// --------------------------------------------------------------------------------------------------------------------
7+
8+
namespace ChocolateyGui.Common.Windows.Utilities.Converters
9+
{
10+
using System;
11+
using System.Collections.Generic;
12+
using System.Globalization;
13+
using System.Linq;
14+
using System.Text;
15+
using System.Threading.Tasks;
16+
using System.Windows;
17+
using System.Windows.Data;
18+
using chocolatey;
19+
using NuGet.Versioning;
20+
21+
public class NuGetVersionToString : DependencyObject, IValueConverter
22+
{
23+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
24+
{
25+
if (value is NuGetVersion version)
26+
{
27+
return version.ToNormalizedStringChecked();
28+
}
29+
30+
return value;
31+
}
32+
33+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
34+
{
35+
if (value is string sValue && NuGetVersion.TryParse(sValue, out var version))
36+
{
37+
return version;
38+
}
39+
40+
throw new InvalidOperationException("The passed in value is not a parseable string version!");
41+
}
42+
}
43+
}

Source/ChocolateyGui.Common.Windows/ViewModels/AdvancedInstallViewModel.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class AdvancedInstallViewModel : ObservableBase, IClosableChildWindow<Adv
4242
private bool _applyInstallArgumentsToDependencies;
4343
private bool _applyPackageParametersToDependencies;
4444
private bool _allowDowngrade;
45+
private bool _ignoreHttpCache;
4546
private bool _ignoreDependencies;
4647
private bool _forceDependencies;
4748
private bool _skipPowerShell;
@@ -66,7 +67,7 @@ public AdvancedInstallViewModel(
6667

6768
_cts = new CancellationTokenSource();
6869

69-
_packageVersion = packageVersion.ToString();
70+
_packageVersion = packageVersion.ToNormalizedStringChecked();
7071
SelectedVersion = _packageVersion;
7172

7273
FetchAvailableVersions();
@@ -225,6 +226,17 @@ public bool AllowDowngrade
225226
set { SetPropertyValue(ref _allowDowngrade, value); }
226227
}
227228

229+
public bool IgnoreHttpCache
230+
{
231+
get { return _ignoreHttpCache; }
232+
set { SetPropertyValue(ref _ignoreHttpCache, value); }
233+
}
234+
235+
public bool IgnoreHttpCacheIsAvailable
236+
{
237+
get { return ChocolateyConfigurationExtensions.HasCacheExpirationInMinutes(); }
238+
}
239+
228240
public bool IgnoreDependencies
229241
{
230242
get

Source/ChocolateyGui.Common.Windows/ViewModels/Items/PackageViewModel.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System.Threading.Tasks;
1212
using AutoMapper;
1313
using Caliburn.Micro;
14+
using chocolatey;
1415
using ChocolateyGui.Common.Base;
1516
using ChocolateyGui.Common.Models;
1617
using ChocolateyGui.Common.Models.Messages;
@@ -405,7 +406,8 @@ public bool IsPackageSizeAvailable
405406

406407
public async Task ShowArguments()
407408
{
408-
var decryptedArguments = _packageArgumentsService.DecryptPackageArgumentsFile(Id, Version.ToString()).ToList();
409+
// TODO: Add legacy handling for packages installed prior to v2.0.0.
410+
var decryptedArguments = _packageArgumentsService.DecryptPackageArgumentsFile(Id, Version.ToNormalizedStringChecked()).ToList();
409411

410412
if (decryptedArguments.Count == 0)
411413
{
@@ -423,7 +425,7 @@ await _dialogService.ShowMessageAsync(
423425

424426
public async Task Install()
425427
{
426-
await InstallPackage(Version.ToString());
428+
await InstallPackage(Version.ToNormalizedStringChecked());
427429
}
428430

429431
public async Task InstallAdvanced()
@@ -465,7 +467,7 @@ public async Task Reinstall()
465467
{
466468
using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_ReinstallingPackage)), L(nameof(Resources.PackageViewModel_ReinstallingPackage)), Id))
467469
{
468-
await _chocolateyService.InstallPackage(Id, Version.ToString(), Source, true);
470+
await _chocolateyService.InstallPackage(Id, Version.ToNormalizedStringChecked(), Source, true);
469471
_chocolateyGuiCacheService.PurgeOutdatedPackages();
470472
await _eventAggregator.PublishOnUIThreadAsync(new PackageChangedMessage(Id, PackageChangeType.Installed, Version));
471473
}
@@ -496,7 +498,7 @@ public async Task Uninstall()
496498
{
497499
using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_UninstallingPackage)), L(nameof(Resources.PackageViewModel_UninstallingPackage)), Id))
498500
{
499-
var result = await _chocolateyService.UninstallPackage(Id, Version.ToString(), true);
501+
var result = await _chocolateyService.UninstallPackage(Id, Version.ToNormalizedStringChecked(), true);
500502

501503
if (!result.Successful)
502504
{
@@ -584,7 +586,7 @@ public async Task Pin()
584586
{
585587
using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_PinningPackage)), L(nameof(Resources.PackageViewModel_PinningPackage)), Id))
586588
{
587-
var result = await _chocolateyService.PinPackage(Id, Version.ToString());
589+
var result = await _chocolateyService.PinPackage(Id, Version.ToNormalizedStringChecked());
588590

589591
if (!result.Successful)
590592
{
@@ -628,7 +630,7 @@ public async Task Unpin()
628630
{
629631
using (await StartProgressDialog(L(nameof(Resources.PackageViewModel_UnpinningPackage)), L(nameof(Resources.PackageViewModel_UnpinningPackage)), Id))
630632
{
631-
var result = await _chocolateyService.UnpinPackage(Id, Version.ToString());
633+
var result = await _chocolateyService.UnpinPackage(Id, Version.ToNormalizedStringChecked());
632634

633635
if (!result.Successful)
634636
{

Source/ChocolateyGui.Common.Windows/Views/AdvancedInstallView.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<converters:BooleanToVisibilityInverted x:Key="BooleanToVisibilityInverted" />
2020
<converters:NullToInverseBool x:Key="NullToInverseBool" />
2121
<converters:BooleanInverter x:Key="BooleanInverter" />
22+
<converters:BooleanToVisibility x:Key="BooleanToVisibilty" />
2223
<GridLength x:Key="ToggleSwitchPreContentMargin">0</GridLength>
2324
<GridLength x:Key="ToggleSwitchPostContentMargin">0</GridLength>
2425

@@ -247,6 +248,9 @@
247248
<Button Grid.Column="1" Content="{lang:Localize AdvancedChocolateyDialog_Browse}" Command="{Binding BrowseLogFileCommand}" />
248249
</Grid>
249250
</mah:MetroHeader>
251+
<mah:MetroHeader Header="{lang:Localize AdvancedChocolateyDialog_IgnoreHttpCache_Header}" Tag="{lang:Localize AdvancedChocolateyDialog_IgnoreHttpCache_ToolTip}" Visibility="{Binding IgnoreHttpCacheIsAvailable, Converter={StaticResource BooleanToVisibilty}}">
252+
<mah:ToggleSwitch VerticalAlignment="Center" IsOn="{Binding IgnoreHttpCache}" />
253+
</mah:MetroHeader>
250254
<mah:MetroHeader Header="{lang:Localize AdvancedChocolateyDialog_OverrideArguments_Header}" Tag="{lang:Localize AdvancedChocolateyDialog_OverrideArguments_ToolTip}">
251255
<mah:ToggleSwitch VerticalAlignment="Center" IsOn="{Binding OverrideArguments}">
252256
<mah:ToggleSwitch.IsEnabled>

Source/ChocolateyGui.Common.Windows/Views/LocalSourceView.xaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
xmlns:commands="clr-namespace:ChocolateyGui.Common.Windows.Commands"
1515
xmlns:controls="clr-namespace:ChocolateyGui.Common.Windows.Controls"
1616
xmlns:theming="clr-namespace:ChocolateyGui.Common.Windows.Theming"
17+
xmlns:converters="clr-namespace:ChocolateyGui.Common.Windows.Utilities.Converters"
1718
mc:Ignorable="d"
1819
d:DesignHeight="768" d:DesignWidth="1366"
19-
d:DataContext="{d:DesignInstance viewModels:LocalSourceViewModel}"
20+
d:DataContext="{d:DesignInstance {x:Type viewModels:LocalSourceViewModel}}"
2021
Background="{DynamicResource MahApps.Brushes.ThemeBackground}">
2122

2223
<UserControl.Resources>
24+
<converters:NuGetVersionToString x:Key="NuGetVersionToString"/>
2325
<utilities:BindingProxy x:Key="BindingProxy" Data="{Binding}" />
2426
<utilities:PackageAuthorsComparer x:Key="PackageAuthorsComparer" />
2527

@@ -59,12 +61,12 @@
5961
<TextBlock Grid.Row="2"
6062
Margin="4 0"
6163
Style="{DynamicResource TileLatestVersionTextStyle}"
62-
Text="{Binding LatestVersion, Mode=OneWay}" />
64+
Text="{Binding LatestVersion, Converter={StaticResource NuGetVersionToString}, Mode=OneWay}" />
6365

6466
<TextBlock Grid.Row="3"
6567
Margin="4 0 4 1"
6668
Style="{DynamicResource TileVersionTextStyle}"
67-
Text="{Binding Version, Mode=OneWay}" />
69+
Text="{Binding Version, Converter={StaticResource NuGetVersionToString}, Mode=OneWay}" />
6870

6971
<ContentControl x:Name="OutOfDateOverlay" Grid.Row="0" Grid.RowSpan="4"
7072
Visibility="Collapsed"
@@ -320,7 +322,7 @@
320322
<ColumnDefinition Width="*" />
321323
</Grid.ColumnDefinitions>
322324
<TextBlock Grid.Column="0"
323-
Text="{Binding LatestVersion, IsAsync=True}"
325+
Text="{Binding LatestVersion, Converter={StaticResource NuGetVersionToString}, IsAsync=True}"
324326
Padding="3 3 2 3"
325327
VerticalAlignment="Stretch"
326328
HorizontalAlignment="Left"

0 commit comments

Comments
 (0)