gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
172 stars 42 forks source link

[ModuleBuilder] Module Manifest settings lost & others overwritten #278

Closed phbits closed 3 years ago

phbits commented 3 years ago

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

I followed the directions @johlju provided in the devops Discord chat to CICD a very simple module using Sampler ModuleType = SimpleModule. The target module is SocketHttpRequest which consists of just two functional files (excluding README, License, etc.):

When running .\build.ps1 -task build, the module manifest is rebuilt but in doing so settings are not carried over from the original manifest. Seems the only setting that should get modified by the build process are as follows. All other settings should be carried over 'as-is'.

Verbose logs showing the problem

I committed everything to the dev branch.

The original manifest: https://github.com/phbits/SocketHttpRequest/blob/dev/SocketHttpRequest.psd1 The built manifest: https://github.com/phbits/SocketHttpRequest/blob/dev/output/SocketHttpRequest/0.1.0/SocketHttpRequest.psd1

Console output from running build.ps1 is available here: https://github.com/phbits/SocketHttpRequest/blob/dev/build-output.txt

The operating system the target node is running

OsName               : Microsoft Windows Server 2019 Datacenter Evaluation
OsOperatingSystemSKU : 80
OsArchitecture       : 64-bit
WindowsVersion       : 1809
WindowsBuildLabEx    : 17763.1.amd64fre.rs5_release.180914-1434
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

Version and build of PowerShell the target node is running

Name                           Value
----                           -----
PSVersion                      5.1.17763.1852
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.1852
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Version of the Required Modules used ('dev' if using current dev branch)

All are listed at: https://github.com/phbits/SocketHttpRequest/tree/dev/output/RequiredModules

johlju commented 3 years ago

Th module manifest that is used as source is in https://github.com/phbits/SocketHttpRequest/blob/dev/source/SocketHttpRequest.psd1 and is defined in build.yaml.

You should also put the public functions as separate .ps1 files (one for each function) under 'source/Public', and private functions under 'source/Private'.

You should also clean out the content of https://github.com/phbits/SocketHttpRequest/blob/dev/source/SocketHttpRequest.psm1, I saw that now and added that to the list. That file should be empty, as it is built

If you don't want to use private/public folders then add the functions inside https://github.com/phbits/SocketHttpRequest/blob/dev/source/SocketHttpRequest.psm1 (although I have not tested this in a module for over a year, so it might not work since there have been many iterations of Sampler since then)

johlju commented 3 years ago

I see now that you changed this row, and it does not point to a existing file 🤔 https://github.com/phbits/SocketHttpRequest/blob/db375ab407f83fbd6f6d574bbee063858f14d0e2/build.yaml#L6

It should not be needed at all if module manifest is in source folder.

johlju commented 3 years ago

This should not be needed either, it is the default: https://github.com/phbits/SocketHttpRequest/blob/db375ab407f83fbd6f6d574bbee063858f14d0e2/build.yaml#L8

phbits commented 3 years ago

@johlju Many thanks for the feedback. After seeing all these issues, I started over from scratch and followed the steps you supplied in the devops chat. For some reason, I got carried away with modifying build.yaml and ended up with this mess. 🤦‍♂️

I started documentation at the following gist. Everything is going good using the steps you've already documented. I'm continuing on with tests which I want to include steps on including custom Pester tests. More to come.

https://gist.github.com/phbits/854343e658c4911bcbe6cec1b19a2f53

johlju commented 3 years ago

That gist looks like it's becoming a good blog post - let me know if you publish it to a blog.

johlju commented 3 years ago

Happy I could help 😃