Skip to content
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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -422,4 +422,7 @@ indent_size = 2
indent_size = 2

[*.json]
indent_size = 2

[*.yml]
indent_size = 2
49 changes: 11 additions & 38 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,10 @@ jobs:

- name: Setup wix
run: |
dotnet.exe tool install --global wix
dotnet.exe tool install --global wix --version 5.0.2 --verbosity diag

wix.exe extension add WixToolset.UI.wixext --global

nuget.exe install WixToolset.Heat -NonInteractive
Get-ChildItem -Path .\WixToolset.Heat* -Recurse |
Where-Object { $_.FullName.EndsWith('x64\heat.exe') } |
Select-Object -ExpandProperty DirectoryName |
Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
wix.exe extension add WixToolset.UI.wixext/5.0.2 --global
wix.exe extension list --global

- name: Generate version property
id: version
Expand All @@ -42,7 +37,7 @@ jobs:
echo "version=$version" >> $env:GITHUB_OUTPUT

- name: Run tests
run: dotnet.exe test .\src\PSDataProtection.sln
run: dotnet.exe test .\src\PSDataProtection.sln --configuration Release --runtime win-x64

- name: Clean solution
run: dotnet.exe clean .\src\PSDataProtection.sln --configuration Release
Expand All @@ -60,45 +55,22 @@ jobs:
Update-MarkdownHelp ./docs -UpdateInputOutput -Force -ErrorAction Stop
New-ExternalHelp ./docs -OutputPath ./publish -ErrorAction Stop

- name: Harvest installer
run: |
heat.exe `
dir `
.\publish `
-nologo `
-cg ProductComponents `
-dr INSTALLDIR `
-var var.ProductSource `
-g1 `
-ag `
-ke `
-srd `
-sfrag `
-sreg `
-o Fragment.wxs

- name: Build installer
run: |
wix.exe `
build `
-arch x64 `
-src Fragment.wxs src\Product.wxs `
-d ProductSource=publish `
-src src\Product.wxs `
-d ProductSource="$(Resolve-Path ./publish)" `
-d ProductVersion="${{ steps.version.outputs.version }}" `
-ext WixToolset.UI.wixext `
-out ps-data-protection.msi

- name: Update installer
run: |
$path = Resolve-Path 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\msiinfo.exe' -ErrorAction Stop

& $path ps-data-protection.msi -t "PowerShell Data Protection Module" -o "PSDataProtection v${{ steps.version.outputs.version }}"

- name: Validate installer
run: wix.exe msi validate ps-data-protection.msi

- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ps-data-protection
path: |
Expand Down Expand Up @@ -128,6 +100,7 @@ jobs:

- name: Publish release
if: github.ref_type == 'tag'
uses: ncipollo/release-action@v1
with:
artifacts: ps-data-protection.msi
run: gh.exe release create v${{ steps.version.outputs.version }} --title v${{ steps.version.outputs.version }} --notes 'PowerShell data protection module.' ps-data-protection.msi
env:
# Requires a personal access token with a fine-grained permission of contents:read/write.
GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion src/PSDataProtection/PSDataProtection.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.PowerShell.5.1.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="9.0.0" PrivateAssets="All" />
</ItemGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/PSDataProtection/ReadDataProtectionSecretCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace PSDataProtection;
using System.Security.Cryptography;

[Cmdlet(VerbsCommunications.Read, "DataProtectionSecret", DefaultParameterSetName = StringParameterSetName)]
[OutputType(typeof(string), ParameterSetName = new[] { StringParameterSetName })]
[OutputType(typeof(SecureString), ParameterSetName = new[] { SecureStringParameterSetName })]
[OutputType(typeof(string), ParameterSetName = [StringParameterSetName])]
[OutputType(typeof(SecureString), ParameterSetName = [SecureStringParameterSetName])]
public class ReadDataProtectionSecretCommand : PSCmdlet
{
private readonly System.Text.UTF8Encoding encoding = new();
Expand Down
6 changes: 5 additions & 1 deletion src/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Version="$(var.ProductVersion)"
Manufacturer="Joseph L. Casale"
UpgradeCode="12d8a258-6fad-4f0e-9f1d-6062ded1e8e9">
<SummaryInformation Description="A PowerShell module that utilizes Microsoft Data Protection to encrypt and decrypt secrets." />
<SummaryInformation Description="A PowerShell module that utilizes Microsoft Data Protection to encrypt and decrypt secrets." Comments="PSDataProtection v$(var.ProductVersion)" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<Media Id="1" Cabinet="Data.cab" EmbedCab="yes" CompressionLevel="high" />

Expand Down Expand Up @@ -40,5 +40,9 @@
</Directory>
</Directory>
</StandardDirectory>

<ComponentGroup Id="ProductComponents" Directory="INSTALLDIR">
<Files Include="$(var.ProductSource)\**" />
</ComponentGroup>
</Package>
</Wix>
9 changes: 4 additions & 5 deletions src/Tests/IntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Tests;

using System;
using System.Collections.Generic;
using System.Management.Automation;
using System.Management.Automation.Runspaces;
using System.Security;
Expand Down Expand Up @@ -31,11 +30,11 @@ public IntegrationTests()
this.powerShell.Runspace = this.runSpace;
}

public static IEnumerable<object[]> NewDataProtectionSecretArguments()
public static TheoryData<string, DataProtectionScope> NewDataProtectionSecretArguments() => new()
{
yield return new object[] { Guid.NewGuid().ToString(), DataProtectionScope.CurrentUser };
yield return new object[] { Guid.NewGuid().ToString(), DataProtectionScope.LocalMachine };
}
{ Guid.NewGuid().ToString(), DataProtectionScope.CurrentUser },
{ Guid.NewGuid().ToString(), DataProtectionScope.LocalMachine }
};

[Theory]
[MemberData(nameof(NewDataProtectionSecretArguments))]
Expand Down
8 changes: 4 additions & 4 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Microsoft.PowerShell.5.1.ReferenceAssemblies" Version="1.0.0" />
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="8.0.0" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PackageReference Include="System.Security.Cryptography.ProtectedData" Version="9.0.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down