Git Product home page Git Product logo

Comments (7)

xavierdecoster avatar xavierdecoster commented on August 14, 2024

Makes sense!

Regarding the first list item: AFAIK, the only way to "inherit" commands from another package (without relying on the file system, such as the package installation directory) is by exposing them in the NuGet PowerShell profile.

Having a dependency to PSBuild would not make its commands available to the scripts contained within the depending package (unless perhaps with the approach taken in the first list item below?).

Also:

  • The PSBuild NuGet package should install the module in the NuGet PowerShell profile only once, no matter how many times I install the package (or invoke the command that registers the module). The init.ps1 in my fork currently auto-injects the PSBuild module in the NuGet profile, and only if not already present. After installation, the NuGet Powershell profile is reloaded (so the commands should be available now to the other packages being installed? to be verified). I considered Install-Package PSBuild as the explicit command. Also, init.ps1 is only called once: when loading the solution or when installing the package.
  • As a dev I don't want to auto-enlist PSBuild as a package dependency if I package my consuming project. Making it a developmentDependency requires NuGet 2.8 (currently in beta): this would avoid consuming projects to list PSBuild as a dependency when the project is packaged.

Some stuff that can be accomplished today independent from the above:

  • Informing the user about PSBuild being loaded in the profile when initializing the pkg manager console
  • Some commands fail in the pkg manager console (likely because I forget to pass in params, such as project-path). Perhaps those parameter can be made optional and be derived from the project parameter?

from psbuild.

sayedihashimi avatar sayedihashimi commented on August 14, 2024
RE: How to create a NuGet pkg which has PS command that other NuGet pkgs can leverage via a NuGet pkg dependency

I have put together a sample in a gist at https://gist.github.com/sayedihashimi/8511756. There are two NuGet packages in this gist, sayed-module and consuming-module. sayed-module defines a new function New-Message inside of a PS module that is installed via init.ps1. consuming-module has a dependency on sayed-module and calls New-Message in it's install.ps1.

_Here is how to try out the sample_
You can build both using the build.ps1. After building the pkgs will be copied to c:\temp\nuget\localrepo\ you can setup a nuget local repo to that folder. Then use install-package consuming-module after that you should see that there is a message in the pkg manage console when consuming-module calls New-Message. Also you can call New-Message at this time as well.

More replies on your other comments coming later. Wanted to share this sample now though.

from psbuild.

xavierdecoster avatar xavierdecoster commented on August 14, 2024

Awesome! The gist verifies that dependent packages can inherit PowerShell functionality from another package, given the other package imports its module from within init.ps1.

FYI, you might also be interested in the following repository: https://github.com/peters/myget

from psbuild.

sayedihashimi avatar sayedihashimi commented on August 14, 2024

@xavierdecoster Were you still interested in this?

from psbuild.

xavierdecoster avatar xavierdecoster commented on August 14, 2024

I can still see the value in this (using psbuild in a PowerShell console that has knowledge about the current solution context can be interesting, eg Invoke-MsBuild )

from psbuild.

sayedihashimi avatar sayedihashimi commented on August 14, 2024

Ok I'm still working on it as well. If you are interested in contributing that would be great.

from psbuild.

xavierdecoster avatar xavierdecoster commented on August 14, 2024

Interested in contributing, but running a little short on time lately :( A short-list of smaller tasks might be a great help though

from psbuild.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.