Skip to content

Commit 2bfe3b1

Browse files
committed
Improved VSCode packaging microsoft#1755
1 parent 308a89b commit 2bfe3b1

24 files changed

+3249
-146
lines changed

PSRule.sln

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.BuildTool", "src\PSR
1515
EndProject
1616
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.SDK", "src\PSRule.SDK\PSRule.SDK.csproj", "{07A84E67-1CA3-4766-B9EA-1FDD9DF6516F}"
1717
EndProject
18-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.Tool", "src\PSRule.Tool\PSRule.Tool.csproj", "{F6CFCA60-72D5-474E-8B8B-1AB973434569}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.Tool", "src\PSRule.Tool\PSRule.Tool.csproj", "{BDDBFDB8-614F-4B8A-930C-DCB60144598C}"
1919
EndProject
2020
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F5173A23-CCEA-4C39-AB8D-EF6E86C11BD7}"
2121
ProjectSection(SolutionItems) = preProject
@@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{E0EA0CBA
3030
EndProject
3131
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.Tool.Tests", "tests\PSRule.Tool.Tests\PSRule.Tool.Tests.csproj", "{DA46C891-08F1-4D01-9F98-1F8BB10CAFEC}"
3232
EndProject
33+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSRule.CommandLine", "src\PSRule.CommandLine\PSRule.CommandLine.csproj", "{9A556814-8E9D-4C76-8F6D-1AF2DA23A9E0}"
34+
EndProject
3335
Global
3436
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3537
Debug|Any CPU = Debug|Any CPU
@@ -60,10 +62,10 @@ Global
6062
{07A84E67-1CA3-4766-B9EA-1FDD9DF6516F}.Debug|Any CPU.Build.0 = Debug|Any CPU
6163
{07A84E67-1CA3-4766-B9EA-1FDD9DF6516F}.Release|Any CPU.ActiveCfg = Release|Any CPU
6264
{07A84E67-1CA3-4766-B9EA-1FDD9DF6516F}.Release|Any CPU.Build.0 = Release|Any CPU
63-
{F6CFCA60-72D5-474E-8B8B-1AB973434569}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
64-
{F6CFCA60-72D5-474E-8B8B-1AB973434569}.Debug|Any CPU.Build.0 = Debug|Any CPU
65-
{F6CFCA60-72D5-474E-8B8B-1AB973434569}.Release|Any CPU.ActiveCfg = Release|Any CPU
66-
{F6CFCA60-72D5-474E-8B8B-1AB973434569}.Release|Any CPU.Build.0 = Release|Any CPU
65+
{BDDBFDB8-614F-4B8A-930C-DCB60144598C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
66+
{BDDBFDB8-614F-4B8A-930C-DCB60144598C}.Debug|Any CPU.Build.0 = Debug|Any CPU
67+
{BDDBFDB8-614F-4B8A-930C-DCB60144598C}.Release|Any CPU.ActiveCfg = Release|Any CPU
68+
{BDDBFDB8-614F-4B8A-930C-DCB60144598C}.Release|Any CPU.Build.0 = Release|Any CPU
6769
{5FE4DB0B-63D1-4DDB-9762-9C0D29168BC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
6870
{5FE4DB0B-63D1-4DDB-9762-9C0D29168BC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
6971
{5FE4DB0B-63D1-4DDB-9762-9C0D29168BC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -76,6 +78,10 @@ Global
7678
{DA46C891-08F1-4D01-9F98-1F8BB10CAFEC}.Debug|Any CPU.Build.0 = Debug|Any CPU
7779
{DA46C891-08F1-4D01-9F98-1F8BB10CAFEC}.Release|Any CPU.ActiveCfg = Release|Any CPU
7880
{DA46C891-08F1-4D01-9F98-1F8BB10CAFEC}.Release|Any CPU.Build.0 = Release|Any CPU
81+
{9A556814-8E9D-4C76-8F6D-1AF2DA23A9E0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
82+
{9A556814-8E9D-4C76-8F6D-1AF2DA23A9E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
83+
{9A556814-8E9D-4C76-8F6D-1AF2DA23A9E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
84+
{9A556814-8E9D-4C76-8F6D-1AF2DA23A9E0}.Release|Any CPU.Build.0 = Release|Any CPU
7985
EndGlobalSection
8086
GlobalSection(SolutionProperties) = preSolution
8187
HideSolutionNode = FALSE

docs/CHANGELOG-v3.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers
2929

3030
What's changed since pre-release v3.0.0-B0141:
3131

32+
- General improvements:
33+
- Improved support for packaging with Visual Studio Code by @BernieWhite.
34+
[#1755](https://github.com/microsoft/PSRule/issues/1755)
3235
- Engineering:
3336
- **Breaking change:** Bump development tools to .NET 8.0 SDK by @BernieWhite.
3437
[#1673](https://github.com/microsoft/PSRule/pull/1673)

src/PSRule.Tool/ClientContext.cs renamed to src/PSRule.CommandLine/ClientContext.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,21 @@
44
using System.CommandLine.Invocation;
55
using PSRule.Configuration;
66

7-
namespace PSRule.Tool;
7+
namespace PSRule.CommandLine;
88

9-
internal sealed class ClientContext
9+
/// <summary>
10+
///
11+
/// </summary>
12+
public sealed class ClientContext
1013
{
14+
/// <summary>
15+
///
16+
/// </summary>
17+
/// <param name="invocation"></param>
18+
/// <param name="option"></param>
19+
/// <param name="verbose"></param>
20+
/// <param name="debug"></param>
21+
/// <exception cref="ArgumentNullException"></exception>
1122
public ClientContext(InvocationContext invocation, string? option, bool verbose, bool debug)
1223
{
1324
Path = AppDomain.CurrentDomain.BaseDirectory;
@@ -18,16 +29,34 @@ public ClientContext(InvocationContext invocation, string? option, bool verbose,
1829
Option = GetOption(Host, option);
1930
}
2031

32+
/// <summary>
33+
///
34+
/// </summary>
2135
public string Path { get; }
2236

37+
/// <summary>
38+
///
39+
/// </summary>
2340
public InvocationContext Invocation { get; }
2441

42+
/// <summary>
43+
///
44+
/// </summary>
2545
public ClientHost Host { get; }
2646

47+
/// <summary>
48+
///
49+
/// </summary>
2750
public PSRuleOption Option { get; }
2851

52+
/// <summary>
53+
///
54+
/// </summary>
2955
public bool Verbose { get; }
3056

57+
/// <summary>
58+
///
59+
/// </summary>
3160
public bool Debug { get; }
3261

3362
private static PSRuleOption GetOption(ClientHost host, string? path)

src/PSRule.Tool/ClientContextExtensions.cs renamed to src/PSRule.CommandLine/ClientContextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.CommandLine;
55
using System.CommandLine.IO;
66

7-
namespace PSRule.Tool;
7+
namespace PSRule.CommandLine;
88

99
internal static class ClientContextExtensions
1010
{

src/PSRule.Tool/ClientHost.cs renamed to src/PSRule.CommandLine/ClientHost.cs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,25 @@
66
using System.Management.Automation;
77
using PSRule.Pipeline;
88

9-
namespace PSRule.Tool;
9+
namespace PSRule.CommandLine;
1010

11-
internal sealed class ClientHost : HostContext
11+
/// <summary>
12+
///
13+
/// </summary>
14+
public sealed class ClientHost : HostContext
1215
{
1316
private readonly ClientContext _Context;
1417
private readonly bool _Verbose;
1518
private readonly bool _Debug;
1619
private readonly ConsoleColor _BackgroundColor;
1720
private readonly ConsoleColor _ForegroundColor;
1821

22+
/// <summary>
23+
///
24+
/// </summary>
25+
/// <param name="context"></param>
26+
/// <param name="verbose"></param>
27+
/// <param name="debug"></param>
1928
public ClientHost(ClientContext context, bool verbose, bool debug)
2029
{
2130
_Context = context;
@@ -27,6 +36,11 @@ public ClientHost(ClientContext context, bool verbose, bool debug)
2736
Verbose($"Using working path: {Directory.GetCurrentDirectory()}");
2837
}
2938

39+
/// <summary>
40+
///
41+
/// </summary>
42+
/// <param name="variableName"></param>
43+
/// <returns></returns>
3044
public override ActionPreference GetPreferenceVariable(string variableName)
3145
{
3246
if (variableName == "VerbosePreference")
@@ -38,22 +52,40 @@ public override ActionPreference GetPreferenceVariable(string variableName)
3852
return base.GetPreferenceVariable(variableName);
3953
}
4054

55+
/// <summary>
56+
///
57+
/// </summary>
58+
/// <param name="errorRecord"></param>
4159
public override void Error(ErrorRecord errorRecord)
4260
{
4361
_Context.LogError(errorRecord.Exception.Message);
4462
base.Error(errorRecord);
4563
}
4664

65+
/// <summary>
66+
///
67+
/// </summary>
68+
/// <param name="text"></param>
4769
public override void Warning(string text)
4870
{
4971
_Context.Invocation.Console.WriteLine(text);
5072
}
5173

74+
/// <summary>
75+
///
76+
/// </summary>
77+
/// <param name="target"></param>
78+
/// <param name="action"></param>
79+
/// <returns></returns>
5280
public override bool ShouldProcess(string target, string action)
5381
{
5482
return true;
5583
}
5684

85+
/// <summary>
86+
///
87+
/// </summary>
88+
/// <param name="informationRecord"></param>
5789
public override void Information(InformationRecord informationRecord)
5890
{
5991
if (informationRecord?.MessageData is HostInformationMessage info)
@@ -80,6 +112,10 @@ private void RevertConsole()
80112
Console.ForegroundColor = _ForegroundColor;
81113
}
82114

115+
/// <summary>
116+
///
117+
/// </summary>
118+
/// <param name="text"></param>
83119
public override void Verbose(string text)
84120
{
85121
if (!_Verbose)
@@ -88,6 +124,10 @@ public override void Verbose(string text)
88124
_Context.LogVerbose(text);
89125
}
90126

127+
/// <summary>
128+
///
129+
/// </summary>
130+
/// <param name="text"></param>
91131
public override void Debug(string text)
92132
{
93133
if (!_Debug)

src/PSRule.Tool/Commands/ModuleCommand.cs renamed to src/PSRule.CommandLine/Commands/ModuleCommand.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
using System.Diagnostics.CodeAnalysis;
66
using System.Management.Automation;
77
using Newtonsoft.Json;
8+
using PSRule.CommandLine.Resources;
89
using PSRule.Configuration;
910
using PSRule.Data;
1011
using PSRule.Pipeline.Dependencies;
11-
using PSRule.Tool.Models;
12-
using PSRule.Tool.Resources;
12+
using PSRule.CommandLine.Models;
1313
using SemanticVersion = PSRule.Data.SemanticVersion;
1414

15-
namespace PSRule.Tool.Commands;
15+
namespace PSRule.CommandLine.Commands;
1616

1717
/// <summary>
1818
/// Execute features of the <c>module</c> command through the CLI.
1919
/// </summary>
20-
internal sealed class ModuleCommand
20+
public sealed class ModuleCommand
2121
{
2222
/// <summary>
2323
/// Failed to install a module.
@@ -35,6 +35,9 @@ internal sealed class ModuleCommand
3535
private const string FIELD_PSDATA = "PSData";
3636
private const string PRERELEASE_SEPARATOR = "-";
3737

38+
/// <summary>
39+
/// Call <c>module restore</c>.
40+
/// </summary>
3841
public static int ModuleRestore(RestoreOptions operationOptions, ClientContext clientContext)
3942
{
4043
var exitCode = 0;

src/PSRule.Tool/Commands/RunCommand.cs renamed to src/PSRule.CommandLine/Commands/RunCommand.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
using PSRule.CommandLine.Models;
45
using PSRule.Configuration;
56
using PSRule.Pipeline;
67
using PSRule.Pipeline.Dependencies;
7-
using PSRule.Tool.Models;
88

9-
namespace PSRule.Tool.Commands;
9+
namespace PSRule.CommandLine.Commands;
1010

1111
/// <summary>
1212
/// Execute features of the <c>run</c> command through the CLI.
1313
/// </summary>
14-
internal sealed class RunCommand
14+
public sealed class RunCommand
1515
{
1616
private const string PUBLISHER = "CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US";
1717

@@ -25,12 +25,15 @@ internal sealed class RunCommand
2525
/// </summary>
2626
private const int ERROR_BREAK_ON_FAILURE = 100;
2727

28+
/// <summary>
29+
/// Call <c>run</c>.
30+
/// </summary>
2831
public static int Run(RunOptions operationOptions, ClientContext clientContext)
2932
{
3033
var exitCode = 0;
3134
var file = LockFile.Read(null);
3235
var inputPath = operationOptions.InputPath == null || operationOptions.InputPath.Length == 0 ?
33-
new string[] { Environment.GetWorkingPath() } : operationOptions.InputPath;
36+
[Environment.GetWorkingPath()] : operationOptions.InputPath;
3437

3538
if (operationOptions.Path != null)
3639
clientContext.Option.Include.Path = operationOptions.Path;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace PSRule.CommandLine.Models;
5+
6+
/// <summary>
7+
///
8+
/// </summary>
9+
public sealed class ModuleOptions
10+
{
11+
/// <summary>
12+
///
13+
/// </summary>
14+
public string[]? Path { get; set; }
15+
16+
/// <summary>
17+
///
18+
/// </summary>
19+
public string[]? Module { get; set; }
20+
21+
/// <summary>
22+
///
23+
/// </summary>
24+
public bool Force { get; set; }
25+
26+
/// <summary>
27+
///
28+
/// </summary>
29+
public string? Version { get; set; }
30+
31+
/// <summary>
32+
///
33+
/// </summary>
34+
public bool SkipVerification { get; set; }
35+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
namespace PSRule.Tool.Models;
4+
namespace PSRule.CommandLine.Models;
55

66
/// <summary>
77
/// A record of a module within the lock file.
@@ -10,4 +10,4 @@ namespace PSRule.Tool.Models;
1010
/// <param name="Version">The version of the module.</param>
1111
/// <param name="Installed">Is the version is installed.</param>
1212
/// <param name="Locked">Is the module tracked.</param>
13-
internal sealed record ModuleRecord(string Name, string Version, bool Installed, bool Locked);
13+
public sealed record ModuleRecord(string Name, string Version, bool Installed, bool Locked);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace PSRule.CommandLine.Models;
5+
6+
/// <summary>
7+
///
8+
/// </summary>
9+
public sealed class RestoreOptions
10+
{
11+
/// <summary>
12+
///
13+
/// </summary>
14+
public string[]? Path { get; set; }
15+
16+
/// <summary>
17+
///
18+
/// </summary>
19+
public bool Force { get; set; }
20+
}

0 commit comments

Comments
 (0)