Skip to content

Commit fb8aef7

Browse files
committed
Merge master into copilot/add-reset-functionality-to-repository-store
2 parents b6b3bc9 + 06b4384 commit fb8aef7

28 files changed

+385
-80
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# the repo. Unless a later match takes precedence,
55
# the following owners will be requested for
66
# review when someone opens a pull request.
7-
* @anamnavi @alerickson @adityapatwardhan @SydneyhSmith
7+
* @anamnavi @alerickson @adityapatwardhan @SydneyhSmith @shammu1

CHANGELOG/preview.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# Preview Changelog
22

3+
## [1.2.0-preview4](https://github.com/PowerShell/PSResourceGet/compare/v1.2.0-preview3..v1.2.0-preview4) - 2025-11-04
4+
5+
## Bug fix
6+
7+
- Fix typos in numerous files (#1875 Thanks @SamErde!)
8+
- MAR fails to parse RequiredVersion for dependencies (#1876 Thanks @o-l-a-v!)
9+
- Get-InstalledPSResource -Path don't throw if no subdirectories were found (#1877 Thanks @o-l-a-v!)
10+
- Handle boolean correctly in RequiredResourceFile for prerelease key (#1843 Thanks @o-l-a-v!)
11+
- Fix CodeQL configuration (#1886)
12+
- Add cmdlet aliases: gres, usres, and svres (#1888)
13+
- Add warning when AuthenticodeCheck is used on non-Windows platforms (#1891)
14+
- Fix Compress-PSResource ignoring .gitkeep and other dotfiles (#1889)
15+
- Add CodeQL suppression for ContainerRegistryServerAPICalls (#1897)
16+
- Fix broken Install-PSResource test with warning condition incorrect (#1899)
17+
- Uninstall-PSResource should not fail silently when resource was not found or prerelease criteria not met (#1898)
18+
- Uninstall-PSResource should delete subdirectories without Access Denied error on OneDrive (#1860)
19+
320
## [1.2.0-preview3](https://github.com/PowerShell/PSResourceGet/compare/v1.2.0-preview2..v1.2.0-preview3) - 2025-09-12
421

522
### New Features

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "8.0.414"
3+
"version": "8.0.415"
44
}
55
}

src/Microsoft.PowerShell.PSResourceGet.psd1

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@
4242
AliasesToExport = @(
4343
'Get-PSResource',
4444
'fdres',
45+
'gres',
4546
'isres',
4647
'pbres',
47-
'udres')
48+
'svres',
49+
'udres',
50+
'usres')
4851
PrivateData = @{
4952
PSData = @{
50-
Prerelease = 'preview3'
53+
Prerelease = 'preview4'
5154
Tags = @('PackageManagement',
5255
'PSEdition_Desktop',
5356
'PSEdition_Core',
@@ -57,6 +60,23 @@
5760
ProjectUri = 'https://go.microsoft.com/fwlink/?LinkId=828955'
5861
LicenseUri = 'https://go.microsoft.com/fwlink/?LinkId=829061'
5962
ReleaseNotes = @'
63+
## 1.2.0-preview4
64+
65+
## Bug fix
66+
67+
- Fix typos in numerous files (#1875 Thanks @SamErde!)
68+
- MAR fails to parse RequiredVersion for dependencies (#1876 Thanks @o-l-a-v!)
69+
- Get-InstalledPSResource -Path don't throw if no subdirectories were found (#1877 Thanks @o-l-a-v!)
70+
- Handle boolean correctly in RequiredResourceFile for prerelease key (#1843 Thanks @o-l-a-v!)
71+
- Fix CodeQL configuration (#1886)
72+
- Add cmdlet aliases: gres, usres, and svres (#1888)
73+
- Add warning when AuthenticodeCheck is used on non-Windows platforms (#1891)
74+
- Fix Compress-PSResource ignoring .gitkeep and other dotfiles (#1889)
75+
- Add CodeQL suppression for ContainerRegistryServerAPICalls (#1897)
76+
- Fix broken Install-PSResource test with warning condition incorrect (#1899)
77+
- Uninstall-PSResource should not fail silently when resource was not found or prerelease criteria not met (#1898)
78+
- Uninstall-PSResource should delete subdirectories without Access Denied error on OneDrive (#1860)
79+
6080
## 1.2.0-preview3
6181
6282
### New Features

src/code/ContainerRegistryServerAPICalls.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ internal class ContainerRegistryServerAPICalls : ServerApiCall
5454

5555
const string containerRegistryRepositoryListTemplate = "https://{0}/v2/_catalog"; // 0 - registry
5656

57+
private string _cachedContainterRegistryToken = null;
58+
5759
#endregion
5860

5961
#region Constructor
@@ -68,6 +70,8 @@ public ContainerRegistryServerAPICalls(PSRepositoryInfo repository, PSCmdlet cmd
6870
Credentials = networkCredential
6971
};
7072

73+
_cachedContainterRegistryToken = null;
74+
7175
_sessionClient = new HttpClient(handler);
7276
_sessionClient.Timeout = TimeSpan.FromMinutes(10);
7377
_sessionClient.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", userAgentString);
@@ -384,6 +388,12 @@ internal string GetContainerRegistryAccessToken(bool needCatalogAccess, out Erro
384388
string tenantID = string.Empty;
385389
errRecord = null;
386390

391+
if (!string.IsNullOrEmpty(_cachedContainterRegistryToken))
392+
{
393+
_cmdletPassedIn.WriteVerbose("Using cached container registry access token.");
394+
return _cachedContainterRegistryToken;
395+
}
396+
387397
var repositoryCredentialInfo = Repository.CredentialInfo;
388398
if (repositoryCredentialInfo != null)
389399
{
@@ -445,6 +455,9 @@ internal string GetContainerRegistryAccessToken(bool needCatalogAccess, out Erro
445455
return null;
446456
}
447457

458+
_cmdletPassedIn.WriteVerbose("Container registry access token retrieved.");
459+
_cachedContainterRegistryToken = containerRegistryAccessToken;
460+
448461
return containerRegistryAccessToken;
449462
}
450463

@@ -739,7 +752,7 @@ internal Hashtable GetContainerRegistryMetadata(string packageName, string exact
739752
{
740753
using (JsonDocument metadataJSONDoc = JsonDocument.Parse(serverPkgInfo.Metadata))
741754
{
742-
string pkgVersionString = String.Empty;
755+
string pkgVersionString = String.Empty;
743756
JsonElement rootDom = metadataJSONDoc.RootElement;
744757

745758
if (rootDom.TryGetProperty("ModuleVersion", out JsonElement pkgVersionElement))
@@ -1014,6 +1027,7 @@ internal JObject GetHttpResponseJObjectUsingContentHeaders(string url, HttpMetho
10141027
return null;
10151028
}
10161029

1030+
// codeql[cs/sensitive-data-transmission] This is expected PSResourceGet behavior to create the content of the request which is only transmitted to the server, not the user. This information is also not exposed back to the user via error or verbose messaging.
10171031
request.Content = new StringContent(content);
10181032
request.Content.Headers.Clear();
10191033
if (contentHeaders != null)

src/code/GetInstalledPSResource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
1515
/// Returns a single resource or multiple resource.
1616
/// </summary>
1717
[Cmdlet(VerbsCommon.Get, "InstalledPSResource")]
18-
[Alias("Get-PSResource")]
18+
[Alias("Get-PSResource", "gres")]
1919
[OutputType(typeof(PSResourceInfo))]
2020
public sealed class GetInstalledPSResourceCommand : PSCmdlet
2121
{

src/code/InstallHelper.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ private List<PSResourceInfo> InstallPackages(
587587
}
588588
}
589589

590+
string depPkgNameVersion = $"{depPkg.Name}{depPkg.Version.ToString()}";
591+
if (_packagesOnMachine.Contains(depPkgNameVersion) && !depPkg.IsPrerelease)
592+
{
593+
// if a dependency package is already installed, do not install it again.
594+
// to determine if the package version is already installed, _packagesOnMachine is used but it only contains name, version info, not version with prerelease info
595+
// if the dependency package is found to be prerelease, it is safer to install it (and worse case it reinstalls)
596+
_cmdletPassedIn.WriteVerbose($"Dependency '{depPkg.Name}' with version '{depPkg.Version}' is already installed.");
597+
continue;
598+
}
599+
590600
packagesHash = BeginPackageInstall(
591601
searchVersionType: VersionType.SpecificVersion,
592602
specificVersion: depVersion,

src/code/InstallPSResource.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,9 +487,9 @@ private void RequiredResourceHelper(Hashtable reqResourceHash)
487487
}
488488
}
489489

490-
if (pkgParams.Scope == ScopeType.AllUsers)
490+
if (pkgParams.Scope.HasValue && pkgParams.Scope.Value == ScopeType.AllUsers)
491491
{
492-
_pathsToInstallPkg = Utils.GetAllInstallationPaths(this, pkgParams.Scope);
492+
_pathsToInstallPkg = Utils.GetAllInstallationPaths(this, pkgParams.Scope.Value);
493493
}
494494

495495
pkgVersion = pkgInstallInfo["version"] == null ? String.Empty : pkgInstallInfo["version"].ToString();
@@ -565,6 +565,16 @@ private void ProcessInstallHelper(string[] pkgNames, string pkgVersion, bool pkg
565565
this));
566566
}
567567

568+
// When reqResourceParams is provided (via -RequiredResource), use its properties
569+
// instead of the cmdlet-level parameters. Only use the property if it was explicitly set (not null).
570+
bool acceptLicense = reqResourceParams?.AcceptLicense ?? AcceptLicense;
571+
bool quiet = reqResourceParams?.Quiet ?? Quiet;
572+
bool reinstall = reqResourceParams?.Reinstall ?? Reinstall;
573+
bool trustRepository = reqResourceParams?.TrustRepository ?? TrustRepository;
574+
bool noClobber = reqResourceParams?.NoClobber ?? NoClobber;
575+
bool skipDependencyCheck = reqResourceParams?.SkipDependencyCheck ?? SkipDependencyCheck;
576+
ScopeType scope = reqResourceParams?.Scope ?? Scope;
577+
568578
IEnumerable<PSResourceInfo> installedPkgs = _installHelper.BeginInstallPackages(
569579
names: pkgNames,
570580
versionRange: versionRange,
@@ -573,19 +583,19 @@ private void ProcessInstallHelper(string[] pkgNames, string pkgVersion, bool pkg
573583
versionString: Version,
574584
prerelease: pkgPrerelease,
575585
repository: pkgRepository,
576-
acceptLicense: AcceptLicense,
577-
quiet: Quiet,
578-
reinstall: Reinstall,
586+
acceptLicense: acceptLicense,
587+
quiet: quiet,
588+
reinstall: reinstall,
579589
force: false,
580-
trustRepository: TrustRepository,
581-
noClobber: NoClobber,
590+
trustRepository: trustRepository,
591+
noClobber: noClobber,
582592
asNupkg: false,
583593
includeXml: true,
584-
skipDependencyCheck: SkipDependencyCheck,
594+
skipDependencyCheck: skipDependencyCheck,
585595
authenticodeCheck: AuthenticodeCheck,
586596
savePkg: false,
587597
pathsToInstallPkg: _pathsToInstallPkg,
588-
scope: Scope,
598+
scope: scope,
589599
tmpPath: _tmpPath,
590600
pkgsInstalled: _packagesOnMachine);
591601

src/code/InstallPkgParams.cs

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ public class InstallPkgParams
1111
public string Name { get; set; }
1212
public VersionRange Version { get; set; }
1313
public string Repository { get; set; }
14-
public bool AcceptLicense { get; set; }
14+
public bool? AcceptLicense { get; set; }
1515
public bool Prerelease { get; set; }
16-
public ScopeType Scope { get; set; }
17-
public bool Quiet { get; set; }
18-
public bool Reinstall { get; set; }
16+
public ScopeType? Scope { get; set; }
17+
public bool? Quiet { get; set; }
18+
public bool? Reinstall { get; set; }
1919
public bool Force { get; set; }
20-
public bool TrustRepository { get; set; }
21-
public bool NoClobber { get; set; }
22-
public bool SkipDependencyCheck { get; set; }
20+
public bool? TrustRepository { get; set; }
21+
public bool? NoClobber { get; set; }
22+
public bool? SkipDependencyCheck { get; set; }
2323

2424

2525

@@ -67,8 +67,10 @@ public void SetProperty(string propertyName, string propertyValue, out ErrorReco
6767
break;
6868

6969
case "acceptlicense":
70-
bool.TryParse(propertyValue, out bool acceptLicenseTmp);
71-
AcceptLicense = acceptLicenseTmp;
70+
if (!string.IsNullOrWhiteSpace(propertyValue) && bool.TryParse(propertyValue, out bool acceptLicenseTmp))
71+
{
72+
AcceptLicense = acceptLicenseTmp;
73+
}
7274
break;
7375

7476
case "prerelease":
@@ -82,28 +84,38 @@ public void SetProperty(string propertyName, string propertyValue, out ErrorReco
8284
break;
8385

8486
case "quiet":
85-
bool.TryParse(propertyValue, out bool quietTmp);
86-
Quiet = quietTmp;
87+
if (!string.IsNullOrWhiteSpace(propertyValue) && bool.TryParse(propertyValue, out bool quietTmp))
88+
{
89+
Quiet = quietTmp;
90+
}
8791
break;
8892

8993
case "reinstall":
90-
bool.TryParse(propertyValue, out bool reinstallTmp);
91-
Reinstall = reinstallTmp;
94+
if (!string.IsNullOrWhiteSpace(propertyValue) && bool.TryParse(propertyValue, out bool reinstallTmp))
95+
{
96+
Reinstall = reinstallTmp;
97+
}
9298
break;
9399

94100
case "trustrepository":
95-
bool.TryParse(propertyValue, out bool trustRepositoryTmp);
96-
TrustRepository = trustRepositoryTmp;
101+
if (!string.IsNullOrWhiteSpace(propertyValue) && bool.TryParse(propertyValue, out bool trustRepositoryTmp))
102+
{
103+
TrustRepository = trustRepositoryTmp;
104+
}
97105
break;
98106

99107
case "noclobber":
100-
bool.TryParse(propertyValue, out bool noClobberTmp);
101-
NoClobber = noClobberTmp;
108+
if (!string.IsNullOrWhiteSpace(propertyValue) && bool.TryParse(propertyValue, out bool noClobberTmp))
109+
{
110+
NoClobber = noClobberTmp;
111+
}
102112
break;
103113

104114
case "skipdependencycheck":
105-
bool.TryParse(propertyValue, out bool skipDependencyCheckTmp);
106-
SkipDependencyCheck = skipDependencyCheckTmp;
115+
if (!string.IsNullOrWhiteSpace(propertyValue) && bool.TryParse(propertyValue, out bool skipDependencyCheckTmp))
116+
{
117+
SkipDependencyCheck = skipDependencyCheckTmp;
118+
}
107119
break;
108120

109121
default:

src/code/Microsoft.PowerShell.PSResourceGet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
<PackageReference Include="NuGet.Protocol" Version="6.9.1" />
2323
<PackageReference Include="PowerShellStandard.Library" Version="7.0.0-preview.1" />
2424
<PackageReference Include="System.Net.Http" Version="4.3.4" />
25-
<PackageReference Include="System.Text.Json" Version="8.0.5" />
25+
<PackageReference Include="System.Text.Json" Version="8.0.6" />
2626
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
27-
<PackageReference Include="Azure.Identity" Version="1.14.0" />
27+
<PackageReference Include="Azure.Identity" Version="1.14.2" />
2828
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="6.0.5" />
2929
<Reference Include="System.Web" />
3030
</ItemGroup>

0 commit comments

Comments
 (0)