Skip to content

Error when Build-Module params are specified but no Build.psd1 present #44

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

Closed
gaelcolas opened this issue Jan 16, 2019 · 5 comments
Closed
Labels
12 - Discussion Input requested from the PoshCode team 20 - Enhancement
Milestone

Comments

@gaelcolas
Copy link
Contributor

When invoking the command Build-Module with required Parameters like this:
Build-Module -Path .\Source\ModuleBuilder.psd1 -OutputDirectory ..\ -VersionedOutputDirectory
but the Build.psd1 file is absent, we get the error below.
The only way to work around it is to create a Build.psd1 with an empty hashtable.

I think we should make that file optional when required parameters are provided, and clearer error when not.

> build-module -Path .\Source\ModuleBuilder.psd1 -OutputDirectory ..\ -VersionedOutputDirectory
Import-Metadata : Can't find file C:\src\ModuleBuilder\Source\[Bb]uild.psd1
At C:\src\ModuleBuilder\output\ModuleBuilder\1.0.0\ModuleBuilder.psm1:83 char:18
+ ... BuildInfo = Import-Metadata -Path (Join-Path $ModuleSource [Bb]uild.p ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Import-Metadata], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Metadata\Import-Metadata,Import-Metadata

InitializeBuild : You cannot call a method on a null-valued expression.
At C:\src\ModuleBuilder\output\ModuleBuilder\1.0.0\ModuleBuilder.psm1:610 char:27
+             $ModuleInfo = InitializeBuild $SourcePath
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [InitializeBuild], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull,InitializeBuild
gaelcolas added a commit to gaelcolas/ModuleBuilder that referenced this issue Jan 16, 2019
@Jaykul
Copy link
Member

Jaykul commented Jan 22, 2019

Ultimately, build.psd1 is basically our project file -- we're even calculating relative paths relative to the build.psd1 -- if it was called build.psproj would you still be trying to get rid of it? I suppose you would.

I don't know.

One problem with this is: what is -OutputDirectory ..\ relative to, if there's no build.psd1 file?

@Jaykul Jaykul added 20 - Enhancement 12 - Discussion Input requested from the PoshCode team labels Jan 22, 2019
@Jaykul
Copy link
Member

Jaykul commented Aug 8, 2019

So, now that all the paths are relative to the module.psd1 instead of the build.psd1 ...

@gaelcolas
Copy link
Contributor Author

I'm waiting for the current version to be released before tackling this one, as I need it for my current project.
/cc @Jaykul

@Jaykul
Copy link
Member

Jaykul commented Oct 6, 2019

Sorry that took so long.

@johlju
Copy link
Contributor

johlju commented Feb 29, 2020

@gaelcolas This issue should be resolved once the PR #90 is merged?

@Jaykul Jaykul closed this as completed in cfc29c0 Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
12 - Discussion Input requested from the PoshCode team 20 - Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants