Skip to content

Fix for Install-PSResource always reinstall issue #525

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

Merged
merged 2 commits into from
Nov 3, 2021
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
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License
Copyright (c) Microsoft Corporation.

Copyright (c) 2020 PowerShell Team
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
57 changes: 23 additions & 34 deletions doBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ function DoBuild
Write-Verbose -Verbose -Message "Copying help files to '$BuildOutPath'"
Copy-Item -Path "${HelpPath}/${Culture}" -Dest "$BuildOutPath" -Recurse -Force

# Copy license
Write-Verbose -Verbose -Message "Copying LICENSE file to '$BuildOutPath'"
Copy-Item -Path "./LICENSE" -Dest "$BuildOutPath"

# Copy notice
# Write-Verbose -Verbose -Message "Copying ThirdPartyNotices.txt to '$BuildOutPath'"
# Copy-Item -Path "./ThirdPartyNotices.txt" -Dest "$BuildOutPath"

#
# Copy DSC resources
# TODO: This should not be part of PowerShellGet build/publish and should be moved to its own project
Expand Down Expand Up @@ -65,40 +73,21 @@ function DoBuild
}

# Place build results
if ($BuildFramework -eq "netstandard2.0") {
$assemblyNames = @(
'PowerShellGet'
'Microsoft.Extensions.Logging.Abstractions'
'MoreLinq'
'NuGet.Commands'
'NuGet.Common'
'NuGet.Configuration'
'NuGet.Frameworks'
'NuGet.Packaging'
'NuGet.ProjectModel'
'NuGet.Protocol'
'NuGet.Repositories'
'NuGet.Versioning'
'Newtonsoft.Json'
)
} elseif ($BuildFramework -eq 'net472') {
$assemblyNames = @(
'PowerShellGet'
'Microsoft.Extensions.Logging.Abstractions'
'MoreLinq'
'NuGet.Commands'
'NuGet.Common'
'NuGet.Configuration'
'NuGet.Frameworks'
'NuGet.Packaging'
'NuGet.ProjectModel'
'NuGet.Protocol'
'NuGet.Repositories'
'NuGet.Versioning'
'Newtonsoft.Json'
'System.Security.Principal.Windows'
)
}
$assemblyNames = @(
'PowerShellGet'
'Microsoft.Extensions.Logging.Abstractions'
'MoreLinq'
'NuGet.Commands'
'NuGet.Common'
'NuGet.Configuration'
'NuGet.Frameworks'
'NuGet.Packaging'
'NuGet.ProjectModel'
'NuGet.Protocol'
'NuGet.Repositories'
'NuGet.Versioning'
'Newtonsoft.Json'
)

$buildSuccess = $true
foreach ($fileName in $assemblyNames)
Expand Down
2 changes: 1 addition & 1 deletion src/PowerShellGet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@{
RootModule = './netstandard2.0/PowerShellGet.dll'
ModuleVersion = '3.0.11'
ModuleVersion = '3.0.12'
GUID = '1d73a601-4a6c-43c5-ba3f-619b18bbb404'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Expand Down
41 changes: 29 additions & 12 deletions src/code/FindHelper.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.PowerShell.PowerShellGet.UtilClasses;
using MoreLinq.Extensions;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;
using System;
using System.Collections.Generic;
using System.Data;
using Dbg = System.Diagnostics.Debug;
using System.Linq;
using System.Management.Automation;
using System.Net;
using System.Net.Http;
using System.Threading;
using MoreLinq.Extensions;
using Microsoft.PowerShell.PowerShellGet.UtilClasses;
using static Microsoft.PowerShell.PowerShellGet.UtilClasses.PSResourceInfo;
using NuGet.Common;
using NuGet.Configuration;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
using NuGet.Versioning;

using Dbg = System.Diagnostics.Debug;

namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
{
Expand All @@ -26,6 +26,8 @@ namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
/// </summary>
internal class FindHelper
{
#region Members

private CancellationToken _cancellationToken;
private readonly PSCmdlet _cmdletPassedIn;
private List<string> _pkgsLeftToFind;
Expand All @@ -50,12 +52,22 @@ internal class FindHelper
private const int SearchAsyncMaxReturned = 5990;
private const int GalleryMax = 12000;

#endregion

#region Constructor

private FindHelper() { }

public FindHelper(CancellationToken cancellationToken, PSCmdlet cmdletPassedIn)
{
_cancellationToken = cancellationToken;
_cmdletPassedIn = cmdletPassedIn;
}

#endregion

#region Public methods

public IEnumerable<PSResourceInfo> FindByResourceName(
string[] name,
ResourceType type,
Expand Down Expand Up @@ -175,7 +187,11 @@ public IEnumerable<PSResourceInfo> FindByResourceName(
}
}

public IEnumerable<PSResourceInfo> SearchFromRepository(
#endregion

#region Private methods

private IEnumerable<PSResourceInfo> SearchFromRepository(
string repositoryName,
Uri repositoryUrl)
{
Expand Down Expand Up @@ -255,7 +271,7 @@ public IEnumerable<PSResourceInfo> SearchFromRepository(
}
}

public IEnumerable<PSResourceInfo> SearchAcrossNamesInRepository(
private IEnumerable<PSResourceInfo> SearchAcrossNamesInRepository(
string repositoryName,
PackageSearchResource pkgSearchResource,
PackageMetadataResource pkgMetadataResource,
Expand Down Expand Up @@ -637,5 +653,6 @@ SourceCacheContext sourceCacheContext
}
}
}
#endregion
}
}
}
13 changes: 6 additions & 7 deletions src/code/GetHelper.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.PowerShell.PowerShellGet.UtilClasses;
using NuGet.Versioning;
using System;
using System.Collections.Generic;
using Dbg = System.Diagnostics.Debug;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Threading;
using MoreLinq.Extensions;
using Microsoft.PowerShell.PowerShellGet.UtilClasses;

using Dbg = System.Diagnostics.Debug;
using static Microsoft.PowerShell.PowerShellGet.UtilClasses.PSResourceInfo;
using NuGet.Versioning;

namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
{
Expand Down Expand Up @@ -38,7 +37,7 @@ public GetHelper(PSCmdlet cmdletPassedIn)

#region Public methods

public IEnumerable<PSResourceInfo> FilterPkgPaths(
public IEnumerable<PSResourceInfo> GetPackagesFromPath(
string[] name,
VersionRange versionRange,
List<string> pathsToSearch)
Expand Down
8 changes: 3 additions & 5 deletions src/code/GetInstalledPSResource.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.PowerShell.PowerShellGet.UtilClasses;
using NuGet.Versioning;
using System;
using System.Collections.Generic;
using System.IO;
using System.Management.Automation;
using System.Threading;
using Microsoft.PowerShell.PowerShellGet.UtilClasses;
using NuGet.Versioning;

namespace Microsoft.PowerShell.PowerShellGet.Cmdlets
{
Expand Down Expand Up @@ -130,7 +128,7 @@ protected override void ProcessRecord()
}

GetHelper getHelper = new GetHelper(this);
foreach (PSResourceInfo pkg in getHelper.FilterPkgPaths(namesToSearch, _versionRange, _pathsToSearch))
foreach (PSResourceInfo pkg in getHelper.GetPackagesFromPath(namesToSearch, _versionRange, _pathsToSearch))
{
WriteObject(pkg);
}
Expand Down
Loading