Skip to content

Can't import DSC resources in dotnet core #4493

@erwinwildenburg

Description

@erwinwildenburg

When trying to build a configuration in a dotnet core application, I can't get it to import the required modules.

Running the following script in a PSCore console works but when running it in a dotnet application it can't find the module:

Configuration Test {
	Import-DscResource -ModuleName PolicyFileEditor
}

Running the following command in the dotnet core application works perfectly, so the problem seems to be limited the the dsc resources:
Import-Module PolicyFileEditor

Steps to reproduce

using (PowerShell ps = PowerShell.Create())
{
	string configScript = "Configuration Test { Import-DscResource -ModuleName PolicyFileEditor }";
	ps.AddScript(configScript);
	ps.Invoke();
}

Expected behavior

The DSC module is imported

Actual behavior

At line:2 char:1
+ Import-DscResource -ModuleName PolicyFileEditor
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Could not find the module 'PolicyFileEditor'.

Environment data

Name                           Value
----                           -----
PSVersion                      6.0.0-beta
PSEdition                      Core
GitCommitId                    v6.0.0-beta.4
OS                             Microsoft Windows 10.0.15063
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-DSCDesired State Configuration issuesResolution-FixedThe issue is fixed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions