Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate_Conceptual_Help: Creates additional CIM class definitions #27

Open
johlju opened this issue Mar 5, 2020 · 2 comments
Open
Labels
needs more information The issue needs more information from the author or the community.

Comments

@johlju
Copy link
Member

johlju commented Mar 5, 2020

Details of the scenario you tried and the problem that is occurring

This was discovered when triaging issue #26.

When running the build task there are additional CIM clss definitions created linked to temporary files.

ERROR: A second CIM class definition for 'MSFT_xDnsServerConditionalForwarder' was found while processing the schema file 'C:\Users\JOHAN~1.LJU\AppData\Local\Temp\DscMofHelper_18a4e1cb-5944-4ca4-adf1-63a4dcaa7fdb.tmp'. This class was already defined in the file(s) 'C:\Users\JOHAN~1.LJU\AppData\Local\Temp\DscMofHelper_6c51dbaf-ba93-4d88-8f36-b6a85fc5aa0e.tmp,C:\Users\JOHAN~1.LJU\AppData\Local\Temp\DscMofHelper_d5588485-e327-412b-abdc-d2c8a950fee2.tmp,C:\Users\JOHAN~1.LJU\AppData\Local\Temp\DscMofHelper_2e9e6ee5-ae42-4c62-910c-e943f7487c69.tmp,C:\Users\JOHAN~1.LJU\AppData\Local\Temp\DscMofHelper_914e5a1a-eb8b-4036-9f6d-82797d62ecd4.tmp,C:\Users\JOHAN~1.LJU\AppData\Local\Temp\DscMofHelper_2bcb41fe-7625-4bdb-bdf5-250d1d02ef70.tmp'. Remove the redundant definition, and then try again.
At C:\source\xDnsServer\output\RequiredModules\DscResource.DocGenerator\0.4.0\DscResource.DocGenerator.psm1:505 char:9

Steps to reproduce the problem

Unsure. Might be when debugging Get-MofSchema and stopping the debug session without letting the code run through which maybe let it clean after it self. I got these errors after triaging issue #26 and after I fixed the double whitespace issue mentioned in that issue..

Although, when running the build step multiple times in a row it seemed to "repair" it self step by step, and after like the 6-7 run I cannot reproduce it no longer.

Expected behavior

For it to not throw an error for this error.

Current behavior

Do throw this error (at least when quick-fix for issue #26 is present).

Suggested solution to the issue

Maybe we can forcibly remove the CIM class definition before removing the temporary file?

The operating system the target node is running

Windows 10

Version and build of PowerShell the target node is running

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version of the module that was used

0.4.0

@johlju johlju added the needs more information The issue needs more information from the author or the community. label Mar 5, 2020
@johlju
Copy link
Member Author

johlju commented Mar 5, 2020

Labeling this as needs more information since we don't know how to reproduce this yet.

@gaelcolas
Copy link
Member

This is when you import a class that's already imported.
So when this:

$class = [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ImportClasses(
            $tempFilePath, $moduleInfo, $exceptionCollection
        )

Is ran twice (I think).
I'm not sure using ImportClasses static method is the best choice here.

You may have to rebuild the cache before being able to do so:

 [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ClearCache()
     $functionsToDefine = [System.Collections.Generic.Dictionary[string,ScriptBlock]]::new(([System.StringComparer]::OrdinalIgnoreCase))
     $builtinModules = @('PSDesiredStateConfiguration'.'PSDesiredStateConfigurationEngine')

     [Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::LoadDefaultCimKeywords($functionsToDefine)

Or use the ImportInstances method instead, without checking the cache/structure (maybe, not sure if it's better or worse).

[Microsoft.PowerShell.DesiredStateConfiguration.Internal.DscClassCache]::ImportInstances('C:\src\PSDesiredStateConfiguration\DSCResources\YourresourceMof\YourResourceMof.mof', 4)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more information The issue needs more information from the author or the community.
Projects
None yet
Development

No branches or pull requests

2 participants