Skip to content

Commit b375a0f

Browse files
PaulHiginadityapatwardhan
authored andcommitted
Ifdefs to decouple PS Core plugin from Windows dependencies. (#35)
1 parent 88c6b4c commit b375a0f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/powershell-native/nativemsh/pwrshplugin/pwrshplugin.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,16 @@ class PwrshPlugInMediator
584584
return g_MANAGED_PLUGIN_ALREADY_LOADED;
585585
}
586586

587+
// Not used for CORECLR plugins
588+
#if !CORECLR
589+
587590
if ((NULL == wszVCLRVersion) || (NULL == wszVAppBase))
588591
{
589592
return g_INVALID_INPUT;
590593
}
591594

595+
#endif
596+
592597
do
593598
{
594599
// Setting global AppBase and CLR Version
@@ -646,6 +651,10 @@ class PwrshPlugInMediator
646651

647652
void LoadPowerShell(PCWSTR version) throw (...)
648653
{
654+
unsigned int exitCode = EXIT_CODE_SUCCESS;
655+
656+
// PowerShell core plugin does not depend on registered Windows PowerShell version.
657+
#if !CORECLR
649658
// Verify incoming powershell version format.
650659
int iPSMajorVersion = 0;
651660
int iPSMinorVersion = 0;
@@ -671,16 +680,18 @@ class PwrshPlugInMediator
671680
{
672681
requestedMonadMajorVersion = 1;
673682
}
683+
#endif
674684

675685
wchar_t* wszMonadVersion = NULL; // Allocated via ConstructPowerShellVersion || GetRegistryInfo
676686
wchar_t* wszTempCLRVersion = NULL; // Allocated via GetRegistryInfo
677687
wchar_t* wszTempAppBase = NULL; // Allocated via GetRegistryInfo
678688
PWSTR wszMgdPlugInFileName = NULL; // Allocated in CreateMgdPluginFileName
679-
unsigned int exitCode = EXIT_CODE_SUCCESS;
680689
PlugInException* pErrorMsg = NULL;
681690

682691
do
683692
{
693+
// PowerShell core plugin does not depend on registered Windows PowerShell version.
694+
#if !CORECLR
684695
exitCode = ConstructPowerShellVersion(iPSMajorVersion, iPSMinorVersion, &wszMonadVersion);
685696
if (exitCode != EXIT_CODE_SUCCESS)
686697
{
@@ -711,16 +722,19 @@ class PwrshPlugInMediator
711722
{
712723
break;
713724
}
725+
#endif
714726

715727
if (!bIsPluginLoaded)
716728
{
729+
// wszMgdPlugInFileName is ignored for CORECLR.
717730
this->powerShellClrHost = PowerShellClrWorkerFactory(wszMgdPlugInFileName);
718731
if (NULL == this->powerShellClrHost)
719732
{
720733
exitCode = ERROR_NOT_ENOUGH_MEMORY;
721734
break;
722735
}
723736

737+
// wszMonadVersion, wszTempCLRVersion ignored for CORECLR.
724738
exitCode = powerShellClrHost->LaunchClr(wszMonadVersion, wszTempCLRVersion, "PwrshPlugin");
725739
if (EXIT_CODE_SUCCESS != exitCode)
726740
{
@@ -730,8 +744,10 @@ class PwrshPlugInMediator
730744
break;
731745
}
732746

747+
// wszMgdPlugInFileName, wszTempCLRVersion, wszTempAppBase ignored for CORECLR.
733748
exitCode = LoadManagedPlugIn(wszMgdPlugInFileName, wszTempCLRVersion, wszTempAppBase, &pErrorMsg);
734749
}
750+
#if !CORECLR
735751
else
736752
{
737753
if (requestedMonadMajorVersion != iMajorVersion)
@@ -747,6 +763,7 @@ class PwrshPlugInMediator
747763
exitCode = g_OPTION_SET_APP_BASE_NOT_MATCH;
748764
}
749765
}
766+
#endif
750767
} while (false);
751768

752769
if (NULL != wszMonadVersion)

0 commit comments

Comments
 (0)