Skip to content

Commit 722fbfd

Browse files
authored
Merge pull request #5697 from MiYanni/NetCoreCore
NetCore PSD1 conversion tool
2 parents 60ce7fa + c580c81 commit 722fbfd

18 files changed

+1070
-7
lines changed

.gitignore

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,10 @@ groupMapping*.json
222222
*.wixpdb
223223

224224
.vscode/
225-
/tools/AutomationTestFramework/RunBooks
226-
/tools/AutomationTestFramework/TestHelpers/TestHelpers.zip
225+
/tools/AutomationTestFramework/Runbooks
227226
Results
228227
Package
229228
.DS_Store
230229
.idea
231-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Logger/bin
232-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Models/bin
233-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Helpers/bin
234-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.Providers/bin
235-
/src/ResourceManager/RecoveryServices.Backup/Commands.RecoveryServices.Backup.ServiceClientAdapter/bin
230+
/src/ResourceManager/RecoveryServices.Backup/**/bin
231+
launchSettings.json
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27130.2027
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetCorePsd1Sync", "NetCorePsd1Sync\NetCorePsd1Sync.csproj", "{A2A13F2A-7E1A-4E16-B933-B7CAC2AC6B7A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A2A13F2A-7E1A-4E16-B933-B7CAC2AC6B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A2A13F2A-7E1A-4E16-B933-B7CAC2AC6B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A2A13F2A-7E1A-4E16-B933-B7CAC2AC6B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A2A13F2A-7E1A-4E16-B933-B7CAC2AC6B7A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {A1F9EDFD-FA4D-487E-B740-AD26183A6E47}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
3+
<s:String x:Key="/Default/Environment/Hierarchy/PsiConfigurationSettingsKey/CustomLocation/@EntryValue">C:\Users\miyanni\AppData\Local\JetBrains\Transient\ReSharperPlatformVs15\v09_53a45c4a\SolutionCaches</s:String></wpf:ResourceDictionary>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.ComponentModel;
17+
using NetCorePsd1Sync.Utility;
18+
using static NetCorePsd1Sync.Model.PsDefinitionConstants;
19+
20+
namespace NetCorePsd1Sync.Model
21+
{
22+
public class ModuleReference
23+
{
24+
[DisplayName("ModuleName")]
25+
public string ModuleName { get; set; }
26+
27+
[DisplayName("ModuleVersion")]
28+
public Version ModuleVersion { get; set; }
29+
30+
[DisplayName("GUID")]
31+
public Guid? Guid { get; set; }
32+
33+
public override string ToString()
34+
{
35+
if (String.IsNullOrEmpty(ModuleName))
36+
{
37+
throw new ArgumentException($"{nameof(ModuleName)} cannot be null or empty");
38+
}
39+
40+
if (ModuleVersion == null && Guid == null)
41+
{
42+
return $"{ElementPrefix}{ModuleName}{ElementPostfix}";
43+
}
44+
45+
var moduleDisplayName = AttributeHelper.GetPropertyAttributeValue<ModuleReference, string, DisplayNameAttribute, string>(mr => mr.ModuleName, attr => attr.DisplayName, nameof(ModuleName));
46+
var line = $"{ObjectPrefix}{moduleDisplayName}{NameValueDelimiter}{ElementPrefix}{ModuleName}{ElementPostfix}{NameValuePostfix}";
47+
if (ModuleVersion != null)
48+
{
49+
var versionDisplayName = AttributeHelper.GetPropertyAttributeValue<ModuleReference, Version, DisplayNameAttribute, string>(mr => mr.ModuleVersion, attr => attr.DisplayName, nameof(ModuleVersion));
50+
line += $"{versionDisplayName}{NameValueDelimiter}{ElementPrefix}{ModuleVersion}{ElementPostfix}{NameValuePostfix}";
51+
}
52+
// ReSharper disable once InvertIf
53+
if (Guid != null)
54+
{
55+
var guidDisplayName = AttributeHelper.GetPropertyAttributeValue<ModuleReference, Guid?, DisplayNameAttribute, string>(mr => mr.Guid, attr => attr.DisplayName, nameof(Guid));
56+
line += $"{guidDisplayName}{NameValueDelimiter}{ElementPrefix}{Guid}{ElementPostfix}{NameValuePostfix}";
57+
}
58+
return $"{line}{ObjectPostfix}";
59+
}
60+
}
61+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System.ComponentModel;
16+
17+
namespace NetCorePsd1Sync.Model
18+
{
19+
public class PrivateData
20+
{
21+
[DisplayName("PSData")]
22+
public PsData PsData { get; set; } = new PsData();
23+
}
24+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.ComponentModel;
18+
19+
namespace NetCorePsd1Sync.Model
20+
{
21+
public class PsData
22+
{
23+
[DisplayName("Tags")]
24+
[Description("Tags applied to this module. These help with module discovery in online galleries.")]
25+
public List<string> Tags { get; set; }
26+
27+
[DisplayName("LicenseUri")]
28+
[Description("A URL to the license for this module.")]
29+
public Uri LicenseUri { get; set; }
30+
31+
[DisplayName("ProjectUri")]
32+
[Description("A URL to the main website for this project.")]
33+
public Uri ProjectUri { get; set; }
34+
35+
[DisplayName("IconUri")]
36+
[Description("A URL to an icon representing this module.")]
37+
public Uri IconUri { get; set; }
38+
39+
[DisplayName("ReleaseNotes")]
40+
[Description("ReleaseNotes of this module")]
41+
public string ReleaseNotes { get; set; }
42+
43+
[DisplayName("Prerelease")]
44+
[Description("Prerelease string of this module")]
45+
public string Prerelease { get; set; }
46+
47+
[DisplayName("RequireLicenseAcceptance")]
48+
[Description("Flag to indicate whether the module requires explicit user acceptance for install/update/save")]
49+
public bool? RequireLicenseAcceptance { get; set; }
50+
51+
[DisplayName("ExternalModuleDependencies")]
52+
[Description("External dependent modules of this module")]
53+
public List<ModuleReference> ExternalModuleDependencies { get; set; }
54+
}
55+
}
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.ComponentModel;
18+
using System.Reflection;
19+
20+
namespace NetCorePsd1Sync.Model
21+
{
22+
public class PsDefinition
23+
{
24+
public PsDefinitionHeader ManifestHeader { get; set; } = new PsDefinitionHeader();
25+
26+
[DisplayName("RootModule")]
27+
[Description("Script module or binary module file associated with this manifest.")]
28+
public string RootModule { get; set; }
29+
30+
[DisplayName("ModuleVersion")]
31+
[Description("Version number of this module.")]
32+
public Version ModuleVersion { get; set; } = new Version(1, 0);
33+
34+
[DisplayName("CompatiblePSEditions")]
35+
[Description("Supported PSEditions")]
36+
public List<string> CompatiblePsEditions { get; set; }
37+
38+
[DisplayName("GUID")]
39+
[Description("ID used to uniquely identify this module")]
40+
public Guid Guid { get; set; } = Guid.NewGuid();
41+
42+
[DisplayName("Author")]
43+
[Description("Author of this module")]
44+
public string Author { get; set; } = Environment.UserName;
45+
46+
[DisplayName("CompanyName")]
47+
[Description("Company or vendor of this module")]
48+
public string CompanyName { get; set; } = "Unknown";
49+
50+
[DisplayName("Copyright")]
51+
[Description("Copyright statement for this module")]
52+
public string Copyright { get; set; } = $"(c) {DateTime.Now.Year} {Environment.UserName}. All rights reserved.";
53+
54+
[DisplayName("Description")]
55+
[Description("Description of the functionality provided by this module")]
56+
public string Description { get; set; }
57+
58+
[DisplayName("PowerShellVersion")]
59+
[Description("Minimum version of the Windows PowerShell engine required by this module")]
60+
public Version PowerShellVersion { get; set; }
61+
62+
[DisplayName("PowerShellHostName")]
63+
[Description("Name of the Windows PowerShell host required by this module")]
64+
public string PowerShellHostName { get; set; }
65+
66+
[DisplayName("PowerShellHostVersion")]
67+
[Description("Minimum version of the Windows PowerShell host required by this module")]
68+
public Version PowerShellHostVersion { get; set; }
69+
70+
[DisplayName("DotNetFrameworkVersion")]
71+
[Description("Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.")]
72+
public Version DotNetFrameworkVersion { get; set; }
73+
74+
[DisplayName("CLRVersion")]
75+
[Description("Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.")]
76+
public Version ClrVersion { get; set; }
77+
78+
[DisplayName("ProcessorArchitecture")]
79+
[Description("Processor architecture (None, X86, Amd64) required by this module")]
80+
public ProcessorArchitecture? ProcessorArchitecture { get; set; }
81+
82+
[DisplayName("RequiredModules")]
83+
[Description("Modules that must be imported into the global environment prior to importing this module")]
84+
public List<ModuleReference> RequiredModules { get; set; }
85+
86+
[DisplayName("RequiredAssemblies")]
87+
[Description("Assemblies that must be loaded prior to importing this module")]
88+
public List<string> RequiredAssemblies { get; set; }
89+
90+
[DisplayName("ScriptsToProcess")]
91+
[Description("Script files (.ps1) that are run in the caller's environment prior to importing this module.")]
92+
public List<string> ScriptsToProcess { get; set; }
93+
94+
[DisplayName("TypesToProcess")]
95+
[Description("Type files (.ps1xml) to be loaded when importing this module")]
96+
public List<string> TypesToProcess { get; set; }
97+
98+
[DisplayName("FormatsToProcess")]
99+
[Description("Format files (.ps1xml) to be loaded when importing this module")]
100+
public List<string> FormatsToProcess { get; set; }
101+
102+
[DisplayName("NestedModules")]
103+
[Description("Modules to import as nested modules of the module specified in RootModule/ModuleToProcess")]
104+
public List<ModuleReference> NestedModules { get; set; }
105+
106+
[DisplayName("FunctionsToExport")]
107+
[Description("Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.")]
108+
public List<string> FunctionsToExport { get; set; } = new List<string>();
109+
110+
[DisplayName("CmdletsToExport")]
111+
[Description("Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.")]
112+
public List<string> CmdletsToExport { get; set; } = new List<string>();
113+
114+
[DisplayName("VariablesToExport")]
115+
[Description("Variables to export from this module")]
116+
public List<string> VariablesToExport { get; set; } = new List<string> { "*" };
117+
118+
[DisplayName("AliasesToExport")]
119+
[Description("Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.")]
120+
public List<string> AliasesToExport { get; set; } = new List<string>();
121+
122+
[DisplayName("DscResourcesToExport")]
123+
[Description("DSC resources to export from this module")]
124+
public List<string> DscResourcesToExport { get; set; }
125+
126+
[DisplayName("ModuleList")]
127+
[Description("List of all modules packaged with this module")]
128+
public List<ModuleReference> ModuleList { get; set; }
129+
130+
[DisplayName("FileList")]
131+
[Description("List of all files packaged with this module")]
132+
public List<string> FileList { get; set; }
133+
134+
[DisplayName("PrivateData")]
135+
[Description("Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.")]
136+
public PrivateData PrivateData { get; set; } = new PrivateData();
137+
138+
[DisplayName("HelpInfoURI")]
139+
[Description("HelpInfo URI of this module")]
140+
public string HelpInfoUri { get; set; }
141+
142+
[DisplayName("DefaultCommandPrefix")]
143+
[Description("Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.")]
144+
public string DefaultCommandPrefix { get; set; }
145+
}
146+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace NetCorePsd1Sync.Model
16+
{
17+
internal static class PsDefinitionConstants
18+
{
19+
public const string CommentToken = "#";
20+
public const string CommentPrefix = CommentToken + " ";
21+
public const string ElementPrefix = "'";
22+
public const string ElementPostfix = "'";
23+
public const string ObjectListPrefix = "@(";
24+
public const string ObjectListPostfix = ")";
25+
public const string ObjectPrefix = "@{";
26+
public const string ObjectPostfix = "}";
27+
public const string NameValueDelimiter = " = ";
28+
public const string NameValuePostfix = "; ";
29+
public const string Indent = " ";
30+
public const string HeaderDelimiter = ": ";
31+
}
32+
}

0 commit comments

Comments
 (0)